Filter out unknown arguments with clang-tidy.sh.
* Call clang-tidy.sh defined in PATH_TO_CLANG_TIDY_SHELL.
* Add dependency to clang-tidy and clang-tidy.sh.
Bug: 110538415
Test: build with WITH_TIDY=1
Change-Id: I90175ea1489272d8d4fc0f9ba4e5bbfdc7399d82
diff --git a/core/binary.mk b/core/binary.mk
index a28561c..5b73e52 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1737,7 +1737,7 @@
# Disable clang-tidy if clang is disabled.
my_tidy_enabled := false
else
- tidy_only: $(cpp_objects) $(c_objects)
+ tidy_only: $(cpp_objects) $(c_objects) $(gen_c_objects) $(gen_cpp_objects)
# Set up global default checks
my_tidy_checks := $(WITH_TIDY_CHECKS)
ifeq ($(my_tidy_checks),)
@@ -1776,6 +1776,15 @@
my_tidy_checks := $(subst $(space),,$(my_tidy_checks))
+# Add dependency of clang-tidy and clang-tidy.sh
+ifneq ($(my_tidy_checks),)
+ my_clang_tidy_programs := $(PATH_TO_CLANG_TIDY) $(PATH_TO_CLANG_TIDY_SHELL)
+ $(cpp_objects): $(intermediates)/%.o: $(my_clang_tidy_programs)
+ $(c_objects): $(intermediates)/%.o: $(my_clang_tidy_programs)
+ $(gen_cpp_objects): $(intermediates)/%.o: $(my_clang_tidy_programs)
+ $(gen_c_objects): $(intermediates)/%.o: $(my_clang_tidy_programs)
+endif
+
# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
my_ldlibs := $(filter -l%,$(my_ldlib_flags))