From 99c3109654e062d867b4549c1b4912a883abbf5c 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 0a36c75..56e9d5e 100644 --- a/clang_tidy/clang_tidy.bzl +++ b/clang_tidy/clang_tidy.bzl @@ -155,7 +155,15 @@ def _clang_tidy_aspect_impl(target, ctx): config = ctx.attr._clang_tidy_config.files.to_list()[0] compilation_context = target[CcInfo].compilation_context - 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++"]