-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Label instances as keys in select #14447
Conversation
b7f9574
to
3bc311e
Compare
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
What a nice PR! Thank you, Fabian! I'll import this shortly. |
@@ -330,8 +330,10 @@ public Depset depset( | |||
name = "x", | |||
positional = true, | |||
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 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I created #14458 as a follow-up, could you take a look?
Nice, thanks for your contribution! @fmeum |
@bazel-io flag |
@bazel-io fork 5.1 |
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)
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>
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, whichpreviously was not possible in select.
This commit also updates the docs for Label, select and macros.
Fixes #14259.