Repository navigation
crate_universe: resolve a non-root module's own labels to its repo - #4436
Open
TrapsterDK wants to merge 2 commits into
Open
TrapsterDK wants to merge 2 commits into
TrapsterDK wants to merge 2 commits into
Conversation
A module pinned as the root records labels to its own targets from `crate.annotation` (`override_target_lib`, `patches`, ...) as `@@//...` in its lockfile. The digest ignores the repo name so the lockfile stays valid when the module is a non-root dependency, but the files rendered from it kept `@@//...`, which then names the root module's repo. For non-root modules, `_generate_hub_and_spokes` now points `@@//` at the module's canonical repo (taken from its `lockfile` label) in the hub files, spoke BUILD files and lockfile JSON it reads back. Root modules, the lockfile format and the digest are unchanged. Test: new integration fixture `non_root_module_labels` uses `override_target` as a non-root module. `bazel test //... @cu_test_override_target//:all @cu_test_override_target//overrides:all` there covers the `lib`, `proc-macro` and `custom-build` overrides. It fails without the change (`no such target '//:foo'`, `no such package 'overrides'`) and passes with it. It runs from the `override_target` CI tasks. Assisted-by: Claude
… docstring buildifier-lint (v8.5.1, --warnings=all) flagged the `@@//` examples in the docstring. Suppress it the same way as the replace() call below it. Ran: buildifier-lint --lint=warn --warnings=all and buildifier --mode=check on the PR's .bzl/.bazel files; both clean. Assisted-by: Claude
Contributor
Author
|
The code-format-checks failure was real: buildifier-lint flagged Ran buildifier-lint v8.5.1 Assisted by Claude. |
This branch has not been deployed
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.
Fixes #4435.
A module pinned as the root records labels to its own targets from
crate.annotation(override_target_lib,patches, ...) as@@//...incargo-bazel-lock.json. The digest already ignores the repo name so that lockfile stays valid when the module is a non-root dependency. But the files rendered from it still said@@//..., which then means the root module's repo, so the build failed withno such target '//:foo'.How it works:
crate_universe/extensions.bzl: for a non-root module,_generate_hub_and_spokesreplaces@@//with@@<module repo>//in the hub files, the spoke BUILD files and the lockfile JSON it reads back (that last one coverspatchespassed tohttp_archive/git_repositoryand thePathcrates). The canonical repo name comes fromcfg.lockfile.repo_name; non-root modules must already setlockfile, and it lives in the module's own repo.@@//across the whole lockfile content and the rendered files. That matches what@@//meant when the lockfile was pinned: the pinning module was the root, so@@//was its own repo.//...and@//...strings in string-list annotation attributes (deps,build_script_data, ...) are not rewritten; how those resolve is a separate, existing behaviour.+vs~in canonical names.Test:
crate_universe/tests/integration/non_root_module_labels. It usesoverride_targetas a non-root module and has abuild_teston@cu_test_override_target//:override_targets_example, which goes throughoverride_target_lib = "//:foo".override_targets_exampleis now public for that.override_targetCI tasks also runbazel test //... @cu_test_override_target//:all @cu_test_override_target//overrides:allin the new fixture throughpost_shell_commands, since presubmit is at the 128 task limit. Runningoverride_target's own tests from there also covers theproc-macro(paste) andcustom-build(anyhow) overrides with the module as non-root.bazel test //... @cu_test_override_target//:all @cu_test_override_target//overrides:allinnon_root_module_labelsfails without the change (no such target '//:foo'forfoo,no such package 'overrides'forpasteand theanyhowgenquery) and passes with it.bazel test //...inoverride_target(root case) still passes.buildifier -mode=check -lint=warnis clean on the changed files.This is separate from #4386, which also changes how
_generate_hub_and_spokeshandles non-root modules. The two touch nearby lines but not the same ones, and both addpost_shell_commands, to different presubmit tasks.Assisted by Claude.