Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ brew install llvm

This only needs to be done once. The build scripts locate it automatically in the standard Homebrew paths (`/opt/homebrew/opt/llvm` on Apple Silicon, `/usr/local/opt/llvm` on Intel).

### cmake (required for `cargo build --workspace`)

The `quarto-highlight` crate enables the `wasm` feature on `tree-sitter`, which pulls in `wasmtime-c-api-impl` as a transitive dependency. Its `build.rs` shells out to `cmake`, so `cmake` must be on `PATH` for any full workspace build. Any modern version works. `cargo dev-setup` checks this and warns if needed.

- **Windows**: `scoop install cmake` (or `winget install Kitware.CMake`)
- **macOS**: `brew install cmake` (separate from the `brew install llvm` step above)
- **Linux**: `apt install cmake` (Debian/Ubuntu) or `dnf install cmake` (Fedora/RHEL)

### Pandoc 3.6+ (optional)

Four tests in the `pampa` crate compare output against Pandoc. These tests require Pandoc 3.6 or later and will fail when Pandoc is missing or too old. `cargo dev-setup` checks this and warns if needed.
Expand Down
57 changes: 57 additions & 0 deletions crates/xtask/src/dev_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,68 @@ pub fn run() -> Result<()> {
println!("Installed {installed} tool(s), {already} already present.");
}

check_cmake();
check_pandoc();

Ok(())
}

/// Check for cmake (required — `cargo build --workspace` pulls in
/// wasmtime-c-api-impl transitively via quarto-highlight, and its build.rs
/// shells out to cmake).
fn check_cmake() {
let Ok(output) = Command::new("cmake").arg("--version").output() else {
warn_cmake_missing();
return;
};
if !output.status.success() {
warn_cmake_missing();
return;
}

let first_line = String::from_utf8_lossy(&output.stdout)
.lines()
.next()
.unwrap_or("cmake")
.trim()
.to_string();
println!("\n {first_line} — detected");
}

fn warn_cmake_missing() {
println!(
"\n Warning: cmake not found. `cargo build --workspace` will fail.\n \
cmake is required transitively by quarto-highlight (wasmtime-c-api-impl).\n \
Install:"
);
for line in cmake_install_hints() {
println!(" {line}");
}
}

/// Platform-specific cmake install commands. Order matters: preferred first.
fn cmake_install_hints() -> &'static [&'static str] {
#[cfg(windows)]
{
&["scoop install cmake", "winget install Kitware.CMake"]
}
#[cfg(target_os = "macos")]
{
&["brew install cmake"]
}
#[cfg(all(unix, not(target_os = "macos")))]
{
&[
"apt install cmake # Debian/Ubuntu",
"dnf install cmake # Fedora/RHEL",
]
}
#[cfg(not(any(windows, unix)))]
{
&["See https://cmake.org/download/"]
}
}

/// Check for Pandoc 3.6+ (optional — needed only for pampa comparison tests).
fn check_pandoc() {
let output = Command::new("pandoc").arg("--version").output();
Expand Down
24 changes: 23 additions & 1 deletion crates/xtask/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,35 @@ pub fn run(config: &VerifyConfig) -> Result<()> {
""
}
);
// On Windows, Cargo cannot re-link target/debug/xtask.exe while the
// currently-running xtask holds a file lock on it. Linux/macOS
// tolerate overwriting a running binary.
#[cfg(windows)]
let build_args: &[&str] = &["build", "--workspace", "--exclude", "xtask"];
#[cfg(not(windows))]
let build_args: &[&str] = &["build", "--workspace"];

run_command(
"cargo",
&["build", "--workspace"],
build_args,
&project_root,
rustflags,
"Rust build failed",
)?;

// On Windows we excluded xtask above; `cargo check -p xtask` still
// gives xtask the `-D warnings` pass without relinking the running
// exe (cargo check doesn't produce a binary). This keeps xtask
// validated even under `cargo xtask verify --skip-rust-tests`.
#[cfg(windows)]
run_command(
"cargo",
&["check", "-p", "xtask"],
&project_root,
rustflags,
"xtask check failed",
)?;

println!("✓ Rust build complete");
} else {
println!("\n━━━ Step 3/{}: Skipping Rust build ━━━\n", TOTAL_STEPS);
Expand Down