bazelbuild / bazelbuild/rules_cc
cc_binary can't be passed to inherit_attrs
- Dominant language
- Starlark
- Stars
- 247
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
I want to wrap cc_binary in macros to select a different compiler for multiple binaries. I came up with this which works perfectly with native cc_binary.
```starlark
def _wrap_impl(name, **kwargs):
cc_binary(
name = name,
**kwargs,
)
_transition_to_clang(
name = name + "_transition",
binary = name,
)
cc_wrap = macro(
inherit_attrs = native.cc_binary,
implementation = _wrap_impl,
)
```
When I change native.cc_binary to cc_binary from rules_cc, I get an error since the latter is exported as a function instead of a rule, contrary to what the cc_binary docstring in `rules_cc/cc/cc_binary.bzl` states.
Contributor guide
Research direction
Start by reading the cc_binary docstring and export in rules_cc/cc/cc_binary.bzl, then reproduce the shown macro with native.cc_binary and rules_cc's cc_binary. Investigate why inherit_attrs rejects the rules_cc export. Done means the documented rule/function behavior and the macro example agree, with the discrepancy addressed or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100