pw_toolchains: clang-tidy path support
- Add support for passing clang_tidy_path variable from invoker to
static_analyis toolchain and clang-tidy python wrapper script.
Fixed: b/265675177
Change-Id: I375085003706eac17a60b138a1b361b908d3119f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126570
Commit-Queue: Shaun Carnegie <shauncarnegie@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_toolchain/static_analysis_toolchain.gni b/pw_toolchain/static_analysis_toolchain.gni
index 8f8f14e..e11f456 100644
--- a/pw_toolchain/static_analysis_toolchain.gni
+++ b/pw_toolchain/static_analysis_toolchain.gni
@@ -53,6 +53,7 @@
# Args:
# cc: (required) String indicating the C compiler to use.
# cxx: (required) String indicating the C++ compiler to use.
+# clang_tidy_path: (optional) String indicating clang-tidy bin to use.
template("pw_static_analysis_toolchain") {
invoker_toolchain_args = invoker.defaults
@@ -72,6 +73,11 @@
_skip_include_path =
_skip_include_path + " --skip-include-path '${pattern}'"
}
+ _clang_tidy_path = ""
+ if (defined(invoker.clang_tidy_path)) {
+ _clang_tidy_path =
+ "--clang-tidy " + rebase_path(invoker.clang_tidy_path, root_build_dir)
+ }
toolchain(target_name) {
# Uncomment this line to see which toolchains generate other toolchains.
@@ -98,6 +104,7 @@
_clang_tidy_py,
_source_exclude,
_skip_include_path,
+ _clang_tidy_path,
"--source-file {{source}}",
"--source-root '${_source_root}'",
"--export-fixes {{output}}.yaml",
@@ -126,6 +133,7 @@
_clang_tidy_py,
_source_exclude,
_skip_include_path,
+ _clang_tidy_path,
"--source-file {{source}}",
"--source-root '${_source_root}'",
"--export-fixes {{output}}.yaml",