Skip to content

Improve cargo xtask dev-setup: cmake detection and xtask self-build lock#136

Open
cderv wants to merge 2 commits intomainfrom
feature/dev-setup-improvements
Open

Improve cargo xtask dev-setup: cmake detection and xtask self-build lock#136
cderv wants to merge 2 commits intomainfrom
feature/dev-setup-improvements

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented Apr 24, 2026

Two cross-platform dev-ergonomics fixes surfaced while verifying PR #109 on Windows. Both are orthogonal to the WASM work.

Background

quarto-highlight (already on main) enables the wasm feature on tree-sitter for native builds. That pulls in wasmtime-c-api-impl as a transitive dependency, whose build.rs shells out to cmake. Result: cmake is now a hard prerequisite for cargo build --workspace on every platform. GitHub Actions runners have it pre-installed. Local dev boxes frequently do not.

Fix 1 — check_cmake() in dev_setup.rs

Follows the existing check_pandoc() pattern. Detects cmake via cmake --version. If missing, prints a warning with platform-specific install commands (scoop/winget on Windows, brew on macOS, apt/dnf on Linux). No version floor — any modern cmake works for wasmtime-c-api. Warning only; cargo dev-setup still exits 0.

Fix 2 — cfg(windows)-gated --exclude xtask in verify.rs step 3

On Windows, Cargo could not re-link target/debug/xtask.exe while the currently-running xtask held a file lock on it (Accès refusé (os error 5)). Linux/macOS tolerate overwriting a running binary, so the fix is Windows-only.

To avoid creating a gap where cargo xtask verify --skip-rust-tests on Windows would never compile or check xtask at all, a follow-up cargo check -p xtask runs on Windows. cargo check does not relink, so no file lock, and xtask still gets the -D warnings pass.

Fix 3 — CONTRIBUTING.md cmake section

Added after the existing macOS Homebrew LLVM section, with per-platform install commands.

Test plan

  • cargo xtask dev-setup reports cmake version 4.3.2 — detected on Windows
  • cargo xtask verify --skip-rust-tests --skip-hub-build --skip-hub-tests --skip-treesitter-tests --skip-trace-viewer-build --skip-trace-viewer-tests completes step 3 on Windows without the os error 5 file lock
  • cargo nextest run -p xtask — 9/9 tests pass
  • RUSTFLAGS="-D warnings" cargo check -p xtask passes
  • Full cargo nextest run --workspace on Linux/macOS CI

Tracked in beads bd-tjbr.

cderv added 2 commits April 24, 2026 18:38
cmake became a hard prereq for `cargo build --workspace` after
quarto-highlight (commit 1fa33da) enabled the `wasm` feature on
tree-sitter, pulling in wasmtime-c-api-impl whose build.rs shells out
to cmake. CI runners ship with cmake; local dev boxes often do not.

check_cmake() in dev_setup.rs follows the check_pandoc() pattern. On
missing cmake, warns with platform-specific install commands
(scoop/winget on Windows, brew on macOS, apt/dnf on Linux). No version
floor — any modern cmake works for wasmtime-c-api. Warning is stronger
than pandoc's because missing cmake means the workspace build fails
entirely, not just four comparison tests.

verify.rs step 3 now skips the xtask crate on Windows. Cargo could not
re-link target/debug/xtask.exe while the currently-running xtask held
a file lock on it ("Accès refusé (os error 5)"). Linux/macOS tolerate
overwriting a running binary, so the fix is cfg(windows)-gated. Step 5
(nextest) still compiles xtask as a test binary on all platforms,
preserving warnings coverage.

CONTRIBUTING.md lists cmake as a prereq with per-platform install
commands, mirroring the existing macOS Homebrew LLVM section.
Review feedback on the prior commit:

verify.rs: the Windows `--exclude xtask` workaround left a gap —
`cargo xtask verify --skip-rust-tests` would now never compile or check
xtask at all, letting a broken xtask crate slip through. Added
`cargo check -p xtask` after step 3 on Windows so xtask still gets the
`-D warnings` pass. `cargo check` does not relink, so it sidesteps the
file lock that motivated the exclusion in the first place.

dev_setup.rs: `check_cmake()` now uses `let-else` to mirror the
neighbouring `check_pandoc()` helper, and the warning prefix is
`Warning:` instead of `WARNING:` for consistency. Extracted
`warn_cmake_missing()` so the early-return paths share one message.

CONTRIBUTING.md: `brew install cmake` is a separate formula from
`brew install llvm`, not bundled with it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant