-
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 combining select[Label]
s
#24674
Comments
I just realized that the "Introspecting selects" proposal could solve this by mapping each value with |
Allowing the
Yes, that would be preferrable. In fact, I was looking forward to that as a possible solution for the pattern where a symbolic macro calls Unfortunately, that proposal ran into issues around 1) how much information does the callback see about the structure of a concatenation of selects; and 2) what is the behavior of the callback w.r.t. a None select value. So that proposal isn't being pursued right now, and a modified or alternative design would be needed. In the meantime, when select()s get in the way of a symbolic macro, you can set the attr to be |
def _my_macro_impl(name, visibility, my_flag):
print(my_flag)
if my_flag:
...
my_macro = macro(
implementation = _my_macro_impl,
attrs = {
"my_flag" = attr.bool(default = False),
}
) This will log I'm finding this default behavior of receiving unresolved |
Yes, basically anytime you need to consume the value in the macro's logic you need to remember to opt out of configurability. This was deemed better than defaulting to nonconfigurable because it's more consistent with rules (whose attributes are almost always configurable) and errs on the side that you're more likely to notice right away if you get it wrong (as opposed to forgetting to declare
This is a known pitfall that would be fixed by #14506. The only problem is it's weird to have a Starlark value that fails when you implicitly attempt to convert it to a bool, but I suspect that's not enough of a blocker to justify not doing it.
The latter. By design macros operate during the loading phase before it is possible to resolve |
Description of the feature request:
With the new symbolic macros, it's difficult to manipulate
attr.label
inputs, as they're wrapped inselect[Label]
objects. Allowing the following operation would regain a lot of functionality:select[Label] + select[Label] -> select[list[Label]]
.Which category does this issue belong to?
Configurability, Starlark Interpreter
What underlying problem are you trying to solve with this feature?
To retain flexibility in making labels a list of labels within a macro.
Which operating system are you running Bazel on?
Ubuntu 24.04
What is the output of
bazel info release
?release 8.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?Have you found anything relevant by searching the web?
Relevant docs: https://bazel.build/docs/configurable-attributes#faq-select-macro
Relevant proposal: https://docs.google.com/document/d/1c-8GNkz57pDgBGPdJoXJ42aCFHr-gN-Ebon9Zx1COsk/edit?tab=t.0#heading=h.5mcn15i0e1ch
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: