For Contributors
Developing with Cargo
Pure Cargo workflow for NativeLink contributors who'd rather not run Bazel.
Every NativeLink crate compiles cleanly with plain Cargo. Use this workflow if you want a smaller dev shell, faster incremental builds during iteration, or just don't have Bazel installed.
Prerequisites
- A recent stable Rust toolchain. The exact version is pinned in
rust-toolchain.toml;rustupwill pick it up automatically. protoc3+ on$PATH(for the gRPC proto generation step).- On Linux:
moldis automatic if installed.
First build
git clone https://github.com/TraceMachina/nativelink
cd nativelink
cargo build --workspaceFirst build is a few minutes (dependency compilation); subsequent incremental builds are typically a few seconds.
Common commands
# Build everything.
cargo build --workspace
# Run all tests.
cargo test --workspace
# Run a specific crate's tests.
cargo test -p nativelink-store
# Run the server.
cargo run -p nativelink -- /path/to/config.json5
# Format.
cargo fmt --all
# Lint (CI runs this too).
cargo clippy --all-targets -- -D warningsFaster incremental builds
A few flags that help:
-
moldas linker (Linux):# ~/.cargo/config.toml [target.x86_64-unknown-linux-gnu] linker = "clang" rustflags = ["-C", "link-arg=-fuse-ld=mold"] -
CARGO_TARGET_DIRset to a shared directory across checkouts to reuse incremental artifacts. -
Pointing Cargo at a
sccachebacked by NativeLink:export RUSTC_WRAPPER=sccache export SCCACHE_BUCKET_URL=grpc://localhost:50051
Caveats
- Some Bazel-only crates (the LRE flake outputs, the Bazel-generated proto bindings) don't have Cargo equivalents. If you're touching those, you'll need Bazel.
- The CI image runs Bazel — your Cargo build passing doesn't
guarantee CI passes. Run
bazel test //...(ornix develop- based equivalent) before submitting.
For the Bazel-based workflow, see Develop with Bazel.