Support intra-workspace dependencies via all_crate_deps - #4239
Open
abezukor wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
abezukor
force-pushed
the
abe/all_crate_deps_intra_workspace_dependencies
branch
from
August 25, 2026 00:25
f2e08e4 to
a932fab
Compare
`crates_universe` drops dependency edges between crates of the same Cargo workspace, leaving users to restate them by hand in BUILD files while Cargo.toml already describes them. Track those edges instead of discarding them, and render them into their own `_FIRST_PARTY_*` maps that `all_crate_deps(first_party = True)` opts into. The choice is per target at load time rather than per repository at generation time, so it needs no configuration. A lockfile written before this change carries no such edges, so it must be repinned once before the flag returns anything. The Bazel repository holding the workspace's crates is derived from the rule's existing `cargo_lockfile` label, so there is no new user-facing attribute. That label stays out of the lockfile digest for the same reason `label_injection_mapping` does: canonical repository names are consumer-specific, and hashing one would demand a producer-side repin that a read-only bzlmod cache cannot perform. Coverage goes in the existing `cargo_workspace` integration test rather than a new one: its `printer` crate now reaches its sibling `rng` through the flag, and `printer:unit_test` calls into that sibling at runtime, while `num_printer` keeps declaring `//printer` by hand so both styles stay exercised. Its lockfile is repinned accordingly; most of that diff is the pending `extra_deps` build script migration rather than this change. Third-party output is unaffected. Rendering the test fixtures before and after this change produces a diff of pure additions: the new `first_party` parameter, its docstring, and six empty map literals for workspaces without intra-workspace dependencies.
abezukor
force-pushed
the
abe/all_crate_deps_intra_workspace_dependencies
branch
from
August 25, 2026 00:32
a932fab to
6c4cb45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #3308. Fixes #1923
crates_universedrops dependency edges between crates of the same Cargo workspace, leaving users to restate them by hand in BUILD files while Cargo.toml already describes them.Track those edges instead of discarding them, and render them into their own
_FIRST_PARTY_*maps thatall_crate_deps(first_party = True)opts into. The choice is per target at load time rather than per repository at generation time, so enabling it needs no repin and no configuration.The Bazel repository holding the workspace's crates is derived from the rule's existing
cargo_lockfilelabel, so there is no new user-facing attribute. That label stays out of the lockfile digest for the same reasonlabel_injection_mappingdoes: canonical repository names are consumer-specific, and hashing one would demand a producer-side repin that a read-only bzlmod cache cannot perform.Third-party output is unaffected. Rendering the test fixtures before and after this change produces a diff of pure additions: the new
first_partyparameter, its docstring, and six empty map literals for workspaces without intra-workspace dependencies.Almost all written with AI, starting with #3308 as a base. I have manually reviewed the code.