Skip to content

Commit cf312e0

Browse files
keitherenon
authored andcommitted
Expand make variables in copts
If you have something like `copts = ["-I$(GENDIR)"]` this requires pre-processing. There are other use cases like this that likely matter less than this.
1 parent 534a3e4 commit cf312e0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clang_tidy/clang_tidy.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ def _clang_tidy_aspect_impl(target, ctx):
174174
if hasattr(ctx.rule.attr, "implementation_deps"):
175175
compilation_contexts.extend([implementation_dep[CcInfo].compilation_context for implementation_dep in ctx.rule.attr.implementation_deps])
176176

177-
rule_flags = ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else []
177+
copts = ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else []
178+
rule_flags = []
179+
for copt in copts:
180+
rule_flags.append(ctx.expand_make_variables(
181+
"copts",
182+
copt,
183+
{},
184+
))
185+
178186
c_flags = _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.c_compile) + rule_flags) + ["-xc"]
179187
cxx_flags = _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.cpp_compile) + rule_flags) + ["-xc++"]
180188

0 commit comments

Comments
 (0)