rules_cc
rules_cc copied to clipboard
Rule based toolchains should expand `args` with `data`
I wrote a args rule like this:
cc_args(
name = "asan_compile_args",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = [
"-fno-sanitize-recover=all",
"-fsanitize=address",
"-fsanitize-ignorelist=$(location //bazel/internal:asan-suppressions.txt)",
],
data = [
"//bazel/internal:asan-suppressions.txt",
],
)
Which I think we should be able to support
The cc_args.format attribute can do this today, and can handle expansion of directory rules from bazel_skylib as well as files and cc_variables. I don't think there's a significant reason to not support this though.
Putting a file in cc_args.format doesn't work because the format argument is missing allow_files = True. As a workaround, the file can be wrapped in a filegroup:
filegroup(
name = "example",
srcs = ["example.txt"],
)
cc_args(
name = "default_flags",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = [
"--example={example}",
],
format = {"example": ":example"},
data = [":example"],
)