From cf312e05da6bd803982435a2e67a7511b508ea1c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 4 Oct 2024 20:27:16 +0000 Subject: [PATCH] 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. --- clang_tidy/clang_tidy.bzl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clang_tidy/clang_tidy.bzl b/clang_tidy/clang_tidy.bzl index 272c75b..0b11752 100644 --- a/clang_tidy/clang_tidy.bzl +++ b/clang_tidy/clang_tidy.bzl @@ -174,7 +174,15 @@ def _clang_tidy_aspect_impl(target, ctx): if hasattr(ctx.rule.attr, "implementation_deps"): compilation_contexts.extend([implementation_dep[CcInfo].compilation_context for implementation_dep in ctx.rule.attr.implementation_deps]) - rule_flags = ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else [] + copts = ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else [] + rule_flags = [] + for copt in copts: + rule_flags.append(ctx.expand_make_variables( + "copts", + copt, + {}, + )) + c_flags = _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.c_compile) + rule_flags) + ["-xc"] cxx_flags = _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.cpp_compile) + rule_flags) + ["-xc++"]