-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Problem
We are people interested in making rust support in Bazel better, and one of the requirements is we determine the dependency graph for a given workspace using the information provided by Cargo.
rules_rust implements a whole set of tools to accommodate for these shortcomings https://github.com/bazelbuild/rules_rust/tree/main/crate_universe
Proposed Solution
I am proposing to change cargo to record features in use for all the crates recorded in the lockfile.
[[package]]
name = "clap"
version = "4.5.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071"
dependencies = [
"clap_builder",
"clap_derive",
]
features = ["color", "default", "derive", "error-context", "help", "std", "suggestions", "usage", "wrap_help"]
Currently cargo.lock does not record the unified list of features (in use) for all the crates listed in the lockfile.
Listing clap in Cargo.toml
clap = { version = "4.5.37", features = ["derive", "env"] }
Gets recorded in the Cargo.lock as
[[package]]
name = "clap"
version = "4.5.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071"
dependencies = [
"clap_builder",
"clap_derive",
]
Currently, the lockfile entry does not record a crucial information about what features are in use by the crate making it not really useful for tools other than cargo itself.
Only place where the information about the features are recorded is target/<cfg>/.fingerprint/clap-<hash>/lib-clap.json, as a workaround we could read this file, due to nature of target folder being VCS ignored forces users to run cargo first whenever they invoke bazel.
Ideally Cargo.lock should be the only source of truth to go from set of dependencies into a full dependency graph.
Notes
No response