-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Starlark rules should allow selectable attribute defaults #287
Comments
This one is quite important for relaying features to a persistent worker. |
Hassan - can you elaborate? |
I need to convey certain feature flags to the kotlin builder. Some should invalid a target others shouldn't. Currently I am working on strict_deps and need to make it toggle-able as I want to release it as experimental. I can't use the In this instance I'd rather do the select in an implicit rule attribute using |
Laurent had a good suggestion (#1698 (comment))
|
Any chance of this being revisited? A drawback of the macro wrapper workaround is that you lose the rule signature docs if you're using Stardocs (higherkindness/rules_scala#258 (comment)) |
I think the best way forward is to get implementation guidance from whoever knows the code best so we have a shovel-ready recipe for anyone willing to make a patch. I poked into this a bit. Using:
I get the error
This comes from bazel/src/main/java/com/google/devtools/build/lib/syntax/CallUtils.java Lines 287 to 293 in 770606a
When I tried doing that Bazel crashed on an
I'm passing this onto the Starlark experts to evaluate how much more Starlark machinery we'd have to plumb through to successfully preserve a Starlark folks: How invasive is it for |
The type checking is enforced in |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post |
Given simple.bzl:
def simple_impl(ctx):
ctx.file_action(
output = ctx.outputs.out,
content = ctx.attr.foo)
simple = rule(
simple_impl,
attrs = {
'foo': select({ '//conditions:default': 'bard' }),
},
outputs = {'out': '%{name}.out' },
)
and BUILD:
simple(name = 'foo')
building ':foo' produces the error:
Illegal argument: expected <String, Builder> type for 'attrs' but got <string, SelectorList> instead.
This is an attempt at a "configurable attribute default", which should be able to work just fine. This failure may come from Skylark or it may come from Bazel's underlying rule machinery, which currently doesn't have any intelligent concept of selectable values not explicitly set in BUILD files.
Originally noticed in https://groups.google.com/d/msg/bazel-discuss/5VR2rVfak-8/dMxXDW1DnZ4J
The text was updated successfully, but these errors were encountered: