Skip to content

cargo_dependencies

Cacheable Cargo dependency set consumed by Rust targets.

Description

Runs cargo metadata --locked against the configured Cargo manifest, lowers resolved registry and git packages into cacheable Once Rust crate actions, and exposes the direct external dependencies Cargo reported for each workspace package.

Cargo.toml and Cargo.lock stay the source of truth. First-party Rust targets depend on this target and identify their Cargo package via CARGO_PKG_NAME or the cargo_package attribute.

Attributes

AttributeTypeRequiredDefaultDescription
manifeststringnoCargo.tomlWorkspace-relative Cargo manifest path passed to cargo metadata --manifest-path
lockfilestringnoCargo.lockWorkspace-relative Cargo lockfile path included in the dependency action key
vendor_dirstringnothird_party/rust/vendorWorkspace-relative directory containing vendored crate sources
packageslist<string>no[]Optional package names to expose from this dependency set. Defaults to all resolved external packages
featureslist<string>no[]Cargo features passed to cargo metadata --features
all_featuresboolnofalsePass --all-features to Cargo metadata
no_default_featuresboolnofalsePass --no-default-features to Cargo metadata
targetstringnohost targetRust target triple passed to Cargo as --filter-platform
dep_rustc_flagslist<string>no[]Additional rustc flags applied to resolved crate builds. Panic strategy flags are stripped for procedural macro and host-tool crates so they keep the compiler's unwind strategy

Providers

The target emits rust_dependency_set.

Capabilities

CapabilityOutput groups
buildnone

Example

toml
[[target]]
name = "cargo_dependencies"
kind = "cargo_dependencies"
srcs = [
  "Cargo.toml",
  "Cargo.lock",
  "apps/*/Cargo.toml",
]

[target.attrs]
manifest = "Cargo.toml"
lockfile = "Cargo.lock"
vendor_dir = "third_party/rust/vendor"

[[target]]
name = "hello"
kind = "rust_binary"
deps = ["cargo_dependencies"]
srcs = ["src/**/*.rs"]

[target.attrs]
crate_name = "hello"

[target.attrs.rustc_env]
CARGO_MANIFEST_DIR = "apps/hello"
CARGO_PKG_NAME = "hello"
CARGO_PKG_VERSION = "0.0.0"

Released under an open-source license.