diff --git a/.cargo/config.toml b/.cargo/config.toml index 03f181d924..a9b4ba86ac 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,3 +4,4 @@ rustflags = [ "-Dclippy::nursery", "-Dclippy::pedantic", ] +target-dir = "build/rust-targets" diff --git a/taskfile.yaml b/taskfile.yaml index 53bc310aec..366893122d 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -10,7 +10,6 @@ includes: docs: "taskfiles/docs.yaml" lint: "taskfiles/lint.yaml" tests: "taskfiles/tests/main.yaml" - toolchains: "taskfiles/toolchains.yaml" utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" vars: diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index a5b81795f1..ecfb24279f 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -1,5 +1,8 @@ version: "3" +includes: + toolchains: "toolchains.yaml" + vars: # Ignore https://github.com/msgpack/msgpack-c/issues/1098 G_CLANG_TIDY_LINE_FILTER_IGNORE_MSGPACK_1098: >- @@ -796,55 +799,61 @@ tasks: check-rust-format: cmds: - - task: "rust-workspace-fmt" + - task: "cargo-workspace-fmt" vars: - RUSTFMT_FLAGS: "--check" + CARGO_FMT_FLAGS: "--check" fix-rust-format: cmds: - - task: "rust-workspace-fmt" + - task: "cargo-workspace-fmt" vars: - RUSTFMT_FLAGS: "" + CARGO_FMT_FLAGS: "" check-rust-static: cmds: - - task: "rust-workspace-clippy" + - task: "cargo-workspace-clippy" vars: - RUST_CLIPPY_FLAGS: "-- -D warnings" + CARGO_CLIPPY_FLAGS: "-- -D warnings" fix-rust-static: cmds: - - task: "rust-workspace-clippy" + - task: "cargo-workspace-clippy" vars: - RUST_CLIPPY_FLAGS: "--fix --allow-dirty --allow-staged" + CARGO_CLIPPY_FLAGS: "--fix --allow-dirty --allow-staged" rust-lint-configs: internal: true run: "once" - cmd: | + cmd: |- cp \ {{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/.rustfmt.toml \ {{.ROOT_DIR}}/.rustfmt.toml - rust-workspace-fmt: + # Runs `cargo +nightly fmt` in the root Rust workspace directory with the specified flags. + # + # @param {string} CARGO_FMT_FLAGS The flags to pass to the `cargo +nightly fmt` command. + cargo-workspace-fmt: internal: true - deps: ["rust-lint-configs", ":toolchains:rust"] - dir: "{{.ROOT_DIR}}" requires: - vars: ["RUSTFMT_FLAGS"] + vars: ["CARGO_FMT_FLAGS"] + dir: "{{.ROOT_DIR}}" + deps: ["rust-lint-configs", "toolchains:rust"] cmd: |- . "$HOME/.cargo/env" - cargo +nightly fmt --all -- {{.RUSTFMT_FLAGS}} + cargo +nightly fmt --all -- {{.CARGO_FMT_FLAGS}} - rust-workspace-clippy: + # Runs `cargo +nightly clippy` in the root Rust workspace directory with the specified flags. + # + # @param {string} CARGO_CLIPPY_FLAGS The flags to pass to the `cargo +nightly clippy` command. + cargo-workspace-clippy: internal: true - deps: [":toolchains:rust"] - dir: "{{.ROOT_DIR}}" requires: - vars: ["RUST_CLIPPY_FLAGS"] + vars: ["CARGO_CLIPPY_FLAGS"] + dir: "{{.ROOT_DIR}}" + deps: ["toolchains:rust"] cmd: |- . "$HOME/.cargo/env" - cargo +nightly clippy --all-targets --all-features {{.RUST_CLIPPY_FLAGS}} + cargo +nightly clippy --all-targets --all-features {{.CARGO_CLIPPY_FLAGS}} venv: internal: true diff --git a/taskfiles/tests/main.yaml b/taskfiles/tests/main.yaml index b2365a64fb..fa599cf428 100644 --- a/taskfiles/tests/main.yaml +++ b/taskfiles/tests/main.yaml @@ -2,10 +2,11 @@ version: "3" includes: integration: "integration.yaml" + toolchains: "../toolchains.yaml" tasks: rust-all: - deps: [":toolchains:rust"] + deps: ["toolchains:rust"] dir: "{{.ROOT_DIR}}" cmd: |- . "$HOME/.cargo/env"