Skip to content

Commit ca1eeff

Browse files
committed
[feat] clang-tidy: add deps argument
This partially ports erenon/bazel_clang_tidy@b8c0567 to extend the support of hermetic toolchains. The `deps` argument lets users control the visibility of the hermetic gcc install during the clang-tidy run.
1 parent 4a31e39 commit ca1eeff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lint/clang_tidy.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def _gather_inputs(ctx, compilation_context, srcs):
5151
inputs = srcs + ctx.files._configs
5252
if (any(ctx.files._global_config)):
5353
inputs.append(ctx.files._global_config[0])
54+
for dep in ctx.files._deps:
55+
inputs.append(dep)
5456
return depset(inputs, transitive = [compilation_context.headers])
5557

5658
def _toolchain_env(ctx, user_flags, action_name = ACTION_NAMES.cpp_compile):
@@ -423,6 +425,7 @@ def lint_clang_tidy_aspect(
423425
configs = [],
424426
global_config = [],
425427
gcc_install_dir = [],
428+
deps = [],
426429
header_filter = "",
427430
lint_target_headers = False,
428431
angle_includes_are_system = True,
@@ -444,6 +447,7 @@ def lint_clang_tidy_aspect(
444447
files which may be used for formatting fixes.
445448
global_config: label of a single global .clang-tidy file to pass to clang-tidy on the command line. This
446449
will cause clang-tidy to ignore any other config files in the source directories.
450+
deps: labels of additional dependencies used during the clang-tidy run.
447451
gcc_install_dir: optional, label of a `Directory` from the skylib library pointing to the gcc install
448452
directory. The argument is passed to the underlying clang as `--gcc-install-dir`.
449453
header_filter: optional, set to a posix regex to supply to clang-tidy with the -header-filter option
@@ -474,6 +478,9 @@ def lint_clang_tidy_aspect(
474478
default = global_config,
475479
allow_files = True,
476480
),
481+
"_deps": attr.label_list(
482+
default = deps,
483+
),
477484
"_gcc_install_dir": attr.label_list(
478485
default = gcc_install_dir,
479486
providers = [DirectoryInfo],

0 commit comments

Comments
 (0)