Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
cargo tree
to determine feature dependent optional deps (#2636)
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