Allow Label instances as keys in select#14447
Closed
fmeum wants to merge 1 commit intobazelbuild:masterfrom
Closed
Allow Label instances as keys in select#14447fmeum wants to merge 1 commit intobazelbuild:masterfrom
fmeum wants to merge 1 commit intobazelbuild:masterfrom
Conversation
b7f9574 to
3bc311e
Compare
Collaborator
Author
3bc311e to
d009ef0
Compare
When a macro specifies a label string as a key in a select, this label is resolved relative to the site of use rather than the .bzl file the macro is defined in. The resolution will lead to incorrect results if the repository that uses the macro has a different repo mapping, e.g. because it is created by another Bazel module. This can be solved by allowing macros to specify label instances created with the `Label` constructor instead of label strings everywhere, which previously was not possible in select. This commit also updates the docs for Label, select and macros. Fixes bazelbuild#14259.
d009ef0 to
d299a87
Compare
Member
|
What a nice PR! Thank you, Fabian! I'll import this shortly. |
gregestren
reviewed
Dec 20, 2021
| doc = | ||
| "A dict that maps configuration conditions to values. Each key is a label string" | ||
| + " that identifies a config_setting instance."), | ||
| "A dict that maps configuration conditions to values. Each key is a " |
Contributor
There was a problem hiding this comment.
I agree this is a nice PR!
My one quibble is documentation that says "A may be X or Y" without differentiating details is fundamentally ambiguous.
You explain the differentiation particularly well in macros.md. I wonder if a cross-reference there would help this.
Collaborator
Author
There was a problem hiding this comment.
Thanks for the suggestion. I created #14458 as a follow-up, could you take a look?
Member
|
Nice, thanks for your contribution! @fmeum |
Collaborator
Author
Contributor
|
@bazel-io flag |
Member
|
@bazel-io fork 5.1 |
brentleyjones
pushed a commit
to brentleyjones/bazel
that referenced
this pull request
Feb 8, 2022
When a macro specifies a label string as a key in a select, this label is resolved relative to the site of use rather than the .bzl file the macro is defined in. The resolution will lead to incorrect results if the repository that uses the macro has a different repo mapping, e.g. because it is created by another Bazel module. This can be solved by allowing macros to specify label instances created with the `Label` constructor instead of label strings everywhere, which previously was not possible in select. This commit also updates the docs for Label, select and macros. Fixes bazelbuild#14259. Closes bazelbuild#14447. PiperOrigin-RevId: 417386977 (cherry picked from commit 69f8b17)
Wyverald
pushed a commit
that referenced
this pull request
Feb 9, 2022
When a macro specifies a label string as a key in a select, this label is resolved relative to the site of use rather than the .bzl file the macro is defined in. The resolution will lead to incorrect results if the repository that uses the macro has a different repo mapping, e.g. because it is created by another Bazel module. This can be solved by allowing macros to specify label instances created with the `Label` constructor instead of label strings everywhere, which previously was not possible in select. This commit also updates the docs for Label, select and macros. Fixes #14259. Closes #14447. PiperOrigin-RevId: 417386977 (cherry picked from commit 69f8b17) Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
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.
When a macro specifies a label string as a key in a select, this label
is resolved relative to the site of use rather than the .bzl file the
macro is defined in. The resolution will lead to incorrect results if
the repository that uses the macro has a different repo mapping, e.g.
because it is created by another Bazel module.
This can be solved by allowing macros to specify label instances created
with the
Labelconstructor instead of label strings everywhere, whichpreviously was not possible in select.
This commit also updates the docs for Label, select and macros.
Fixes #14259.