Allow binary-only dependencies in metadata #9974
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A number of projects, such as https://github.com/google/cargo-raze
consume the output of
cargo metadata
when generating input to otherbuild systems, such as Bazel and Buck. Typically, these projects use a
Cargo.toml
file as the input to drive their work, and it can be usefulto express to these systems that a binary is required as part of the
build.
If such a dependency happens to have a lib target, sufficient dependency
information happens to be exposed via the resolve field to recreate the
dependency structure adequately.
However, for binary-only targets, that entire branch of the dependency
tree is cut off, making it hard to recreate this information.
This PR adds an option to
cargo metadata
to allow rendering thesesubtrees, describing these deps as of kind "binary". This isn't really a
concept in cargo-proper, but may become one via
rust-lang/rfcs#3168 and/or
rust-lang/rfcs#3028 - this output format is
forwards-compatible with these proposals.
In an RFC 3028 world, binary deps would appear as
dep_kind
"binary",and
cdylib
orstaticlib
deps would appear as newDepKind
variants.We'd probably add a new value of the flag,
declared
, and set that tobe the default. We may also want to deprecate the
include-if-no-library-dep
value, and make these ignored binary deps ahard error (replacing the existing warning log).
In an RFC 3168 world, there's an interesting metadata question to have -
there are (at least) three reasonable options in terms of handling
metadata:
being used from the crate which uses them - this gives a nicely
restricted search space, and allows for nicely curated metadata
output.
this may significantly expand the output produced, but would model
the implementation of the feature.
this looks a lot like RFC 3028, and would tend in that direction.