Skip to content

Commit

Permalink
Use cargo tree to determine feature dependent optional deps (#2636)
Browse files Browse the repository at this point in the history
The Cargo [Feature Resolver version
2](https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2)
behavior is currently not supported by the `cargo metadata` sub command
(rust-lang/cargo#9863) which `crate_universe`
uses to determine the dependencies of a target, leading to inaccuracies
when dependencies are introduced via feature resolution for a particular
configuration.

In #1710 functionality was
added to use `cargo tree` to perform feature resolution for each
supported platform. This change expands on this trick to collect
dependency information at the same time and use that to determine
whether or not to include optional dependencies located in standard
`cargo metadata` output in the rendered Bazel targets. Non optional or
`target.cfg` (conditional) dependencies behave as they did before this
change.

Implementation details:
- `FeatureGenerator` was replaced by `TreeResolver`
- Optional dependencies are now rendered as selects on explicit
platforms. This will expand the size of `cargo-bazel-lock.json` files
but is expected to be more correct.
  • Loading branch information
UebelAndre committed May 8, 2024
1 parent 29aed66 commit f22926a
Show file tree
Hide file tree
Showing 168 changed files with 55,095 additions and 3,762 deletions.
6 changes: 3 additions & 3 deletions bindgen/3rdparty/crates/BUILD.anstream-0.3.2.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 34 additions & 34 deletions bindgen/3rdparty/crates/BUILD.io-lifetimes-1.0.11.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions bindgen/3rdparty/crates/BUILD.libc-0.2.146.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bindgen/3rdparty/crates/BUILD.linux-raw-sys-0.3.8.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f22926a

Please sign in to comment.