Reorganize rust crates into a flat crates directory, simplify some CI steps (#4496)

* Move all rust crates (except lib) into crates dir, w/o nesting

* Remove stale path from .gitattributes

* Rename lib.rs files for easier navigation

* Rename mod.rs file for easier navigation

* Fix emscripten-version path

* Fix fixtures dir paths

* Use the default rustfmt settings

* Don't use nightly on CI
This commit is contained in:
Max Brunsfeld 2025-06-06 14:25:37 -07:00 committed by GitHub
parent a6e530b33d
commit 0fdf569571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 69 additions and 89 deletions

1
.gitattributes vendored
View file

@ -3,5 +3,4 @@
/lib/src/unicode/*.h linguist-vendored
/lib/src/unicode/LICENSE linguist-vendored
/cli/src/generate/prepare_grammar/*.json -diff
Cargo.lock -diff

View file

@ -73,7 +73,7 @@ jobs:
uses: actions/checkout@v4
- name: Read Emscripten version
run: printf 'EMSCRIPTEN_VERSION=%s\n' "$(<cli/loader/emscripten-version)" >> $GITHUB_ENV
run: printf 'EMSCRIPTEN_VERSION=%s\n' "$(<crates/loader/emscripten-version)" >> $GITHUB_ENV
- name: Install Emscripten
if: ${{ !matrix.no-run && !matrix.use-cross }}

View file

@ -34,22 +34,11 @@ jobs:
toolchain: stable
components: clippy, rustfmt
- name: Set up nightly Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: clippy, rustfmt
- name: Lint files
run: |
make lint
make lint-web
- name: Lint files (Rust nightly)
continue-on-error: true
run: |
make lint-nightly
sanitize:
uses: ./.github/workflows/sanitize.yml

View file

@ -1,15 +1,15 @@
[workspace]
default-members = ["cli"]
default-members = ["crates/cli"]
members = [
"cli",
"cli/config",
"cli/generate",
"cli/loader",
"crates/cli",
"crates/config",
"crates/generate",
"crates/highlight",
"crates/loader",
"crates/tags",
"crates/xtask",
"crates/language",
"lib",
"lib/language",
"tags",
"highlight",
"xtask",
]
resolver = "2"
@ -154,8 +154,9 @@ wasmparser = "0.224.1"
webbrowser = "1.0.4"
tree-sitter = { version = "0.26.0", path = "./lib" }
tree-sitter-generate = { version = "0.26.0", path = "./cli/generate" }
tree-sitter-loader = { version = "0.26.0", path = "./cli/loader" }
tree-sitter-config = { version = "0.26.0", path = "./cli/config" }
tree-sitter-highlight = { version = "0.26.0", path = "./highlight" }
tree-sitter-tags = { version = "0.26.0", path = "./tags" }
tree-sitter-generate = { version = "0.26.0", path = "./crates/generate" }
tree-sitter-language = { path = "./crates/language" }
tree-sitter-loader = { version = "0.26.0", path = "./crates/loader" }
tree-sitter-config = { version = "0.26.0", path = "./crates/config" }
tree-sitter-highlight = { version = "0.26.0", path = "./crates/highlight" }
tree-sitter-tags = { version = "0.26.0", path = "./crates/tags" }

View file

@ -106,21 +106,15 @@ test-wasm:
lint:
cargo update --workspace --locked --quiet
cargo check --workspace --all-targets
cargo +nightly fmt --all --check
cargo +stable clippy --workspace --all-targets -- -D warnings
lint-nightly:
cargo update --workspace --locked --quiet
cargo check --workspace --all-targets
cargo +nightly fmt --all --check
cargo +nightly clippy --workspace --all-targets -- -D warnings
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
lint-web:
npm --prefix lib/binding_web ci
npm --prefix lib/binding_web run lint
format:
cargo +nightly fmt --all
cargo fmt --all
changelog:
@git-cliff --config .github/cliff.toml --prepend CHANGELOG.md --latest --github-token $(shell gh auth token)

View file

@ -16,6 +16,9 @@ include = ["build.rs", "README.md", "benches/*", "src/**"]
[lints]
workspace = true
[lib]
path = "src/tree_sitter_cli.rs"
[[bin]]
name = "tree-sitter"
path = "src/main.rs"

View file

@ -229,7 +229,7 @@ fn tree_sitter_dir(tree_sitter_json: &str, name: &str) -> tempfile::TempDir {
.unwrap();
fs::write(
temp_dir.path().join("src/tree_sitter/parser.h"),
include_str!("../../../lib/src/parser.h"),
include_str!("../../../../lib/src/parser.h"),
)
.unwrap();
temp_dir

View file

@ -1,5 +1,7 @@
pub static ROOT_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap()
.to_owned()

View file

@ -12,6 +12,9 @@ license.workspace = true
keywords.workspace = true
categories.workspace = true
[lib]
path = "src/tree_sitter_config.rs"
[lints]
workspace = true

Some files were not shown because too many files have changed in this diff Show more