Cargo

Rules for interoperating with tooling from the Cargo ecosystem — most importantly, Cargo build.rs scripts. These rules let a Bazel build consume the same crate-side conventions that Cargo uses (build scripts, generated env vars, [lints] tables) without switching build systems.

Rules

  • cargo_build_script — Compile and run a crate's build.rs at build time, then feed the emitted cargo:* directives (env vars, link args, rerun-if-changed inputs) into consumers of the crate.
  • cargo_env — Helper that returns Cargo's standard CARGO_* env-var dict, used by rules that need to reproduce Cargo's compilation environment.
  • extract_cargo_lints — Read the [lints] table from a Cargo.toml and produce a rust_lint_config target from it, so Cargo-defined lints apply to Bazel-built crates.