Starlark rules should allow selectable attribute defaults
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
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 type for 'attrs' but got 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
Contributor guide
Assessment
This issue has not been assessed yet.