From de048d847fb53cae433c092a8c59ff8a2e6f8190 Mon Sep 17 00:00:00 2001 From: Shaun Carnegie Date: Thu, 19 Jan 2023 13:13:09 +0000 Subject: [PATCH] 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 Reviewed-by: Wyatt Hepler --- pw_toolchain/static_analysis_toolchain.gni | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pw_toolchain/static_analysis_toolchain.gni b/pw_toolchain/static_analysis_toolchain.gni index 8f8f14ebf9..e11f45635b 100644 --- a/pw_toolchain/static_analysis_toolchain.gni +++ b/pw_toolchain/static_analysis_toolchain.gni @@ -53,6 +53,7 @@ declare_args() { # 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 @@ template("pw_static_analysis_toolchain") { _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 @@ template("pw_static_analysis_toolchain") { _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 @@ template("pw_static_analysis_toolchain") { _clang_tidy_py, _source_exclude, _skip_include_path, + _clang_tidy_path, "--source-file {{source}}", "--source-root '${_source_root}'", "--export-fixes {{output}}.yaml",