Skip to content

Commit

Permalink
Merge pull request #4 from mongodb-forks/DEVPROD-9367
Browse files Browse the repository at this point in the history
DEVPROD-9367 Expand Bazel variables in flags passed to bazel_clang_tidy
  • Loading branch information
zackwintermdb authored Jul 31, 2024
2 parents 47e5cc0 + b2e7bdf commit 0660540
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clang_tidy/clang_tidy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def _safe_flags(flags):

return [flag for flag in flags if flag not in unsupported_flags]

def _expand_flags(ctx, flags):
return [ctx.expand_make_variables("clang_tidy_expand_flags", flag, ctx.var) for flag in flags]

def _clang_tidy_aspect_impl(target, ctx):
# if not a C/C++ target, we are not interested
if not CcInfo in target:
Expand Down Expand Up @@ -168,8 +171,8 @@ def _clang_tidy_aspect_impl(target, ctx):
compilation_context = target[CcInfo].compilation_context

rule_flags = ctx.rule.attr.copts if hasattr(ctx.rule.attr, "copts") else []
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++"]
c_flags = _expand_flags(ctx, _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.c_compile) + rule_flags) + ["-xc"])
cxx_flags = _expand_flags(ctx, _safe_flags(_toolchain_flags(ctx, ACTION_NAMES.cpp_compile) + rule_flags) + ["-xc++"])

srcs = _rule_sources(ctx)

Expand Down

0 comments on commit 0660540

Please sign in to comment.