Simplify DEFAULT_LOCAL_TIDY_CHECKS.
* Now each local directory path is matched against multiple
patterns and only the last matched one will be used,
or the DEFAULT_GLOBAL_TIDY_CHECKS is used.
Bug: http://b/27779618
Change-Id: I786e6cacd8a680a034b4bc09f561f658177d9b17
Test: build with WITH_TIDY=1.
diff --git a/core/clang/tidy.mk b/core/clang/tidy.mk
index d50b43d..860257f 100644
--- a/core/clang/tidy.mk
+++ b/core/clang/tidy.mk
@@ -19,30 +19,30 @@
# and misc-macro-parentheses, but not google-readability*
# or google-runtime-references.
DEFAULT_GLOBAL_TIDY_CHECKS := \
- -*,google*,performance*,misc-macro-parentheses \
- ,-google-readability*,-google-runtime-references
+ $(subst $(space),, \
+ -*,google*,performance*,misc-macro-parentheses \
+ ,-google-readability*,-google-runtime-references \
+ )
-# Disable style rules usually not followed by external projects.
+# There are too many clang-tidy warnings in external and vendor projects.
+# Enable only some google checks for these projects.
+DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \
+ $(subst $(space),, \
+ -*,google*,-google-build-using-namespace \
+ ,-google-readability*,-google-runtime-references \
+ ,-google-explicit-constructor,-google-runtime-int \
+ )
+
# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
-# <local_path_prefix>:,<tidy-check-pattern>
-# The tidy-check-patterns of all matching local_path_prefixes will be used.
-# For example, external/google* projects will have:
-# ,-google-build-using-namespace,-google-explicit-constructor
-# ,-google-runtime-int,-misc-macro-parentheses,
-# ,google-runtime-int,misc-macro-parentheses
-# where google-runtime-int and misc-macro-parentheses are enabled at the end.
+# <local_path_prefix>:,<tidy-checks>
+# The last matched local_path_prefix should be the most specific to be used.
DEFAULT_LOCAL_TIDY_CHECKS := \
- external/:,-google-build-using-namespace \
- external/:,-google-explicit-constructor,-google-runtime-int \
- external/:,-misc-macro-parentheses \
- external/google:,google-runtime-int,misc-macro-parentheses \
- external/webrtc/:,google-runtime-int \
- hardware/qcom:,-google-build-using-namespace \
- hardware/qcom:,-google-explicit-constructor,-google-runtime-int \
- vendor/lge:,-google-build-using-namespace,-misc-macro-parentheses \
- vendor/lge:,-google-explicit-constructor,-google-runtime-int \
- vendor/widevine:,-google-build-using-namespace,-misc-macro-parentheses \
- vendor/widevine:,-google-explicit-constructor,-google-runtime-int \
+ external/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
+ external/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
+ external/webrtc:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
+ hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
+ vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
+ vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
define find_default_local_tidy_check2
@@ -54,11 +54,11 @@
$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
endef
-# Returns concatenated tidy check patterns from the
-# DEFAULT_GLOBAL_TIDY_CHECKS and all matched patterns
-# in DEFAULT_LOCAL_TIDY_CHECKS based on given directory path $(1).
+# Returns the default tidy check list for local project path $(1).
+# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
+# most specific pattern.
define default_global_tidy_checks
-$(subst $(space),, \
+$(lastword \
$(DEFAULT_GLOBAL_TIDY_CHECKS) \
$(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
$(call find_default_local_tidy_check,$(pattern),$(1)) \