vaticle / bazel-distribution

Bazel rules for assembling and deploying software distributions (see @vaticle for usage example)
https://bazel.build
Apache License 2.0
155 stars 53 forks source link

Emit canonical dependency info when assembling crate #381

Closed dmitrii-ubskii closed 11 months ago

dmitrii-ubskii commented 11 months ago

What is the goal of this PR?

We improve the generated crate manifest by allowing to specify available crate features, and by enabling the features of dependencies.

What are the changes implemented in this PR?

We did not include enabled features in the crate dependencies before this change. Now, we parse the crate universe manifests and collect the crate_features attributes from the rust_library dependencies of the crate being assembled so that we can emit the correct dependency requirement in the generated Cargo.toml.

rules_rust must resolve the full list of features which were enabled explicitly or implicitly in order to correctly compile the dependency. That has the consequence of us ultimately explicitly depending on implementation details of other crates (see e.g. https://github.com/vaticle/typedb-driver-rust/issues/35), which is misleading on the crates.io page, and breaks across dependency versions. For this reason, we cannot simply rely on the crate_features attribute of the generated dependency files, but must instead parse the explicitly enabled features in the universe manifests.

vaticle-bot commented 11 months ago

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

Code

Architecture