blob: 7ec9378260d67cd6380bf76020723ec0f5250c97 [file] [log] [blame]
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -07001#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# Most Android source files are not clang-tidy clean yet.
Chih-Hung Hsiehc8682932016-07-26 14:27:03 -070018# Global tidy checks include only google*, performance*,
19# and misc-macro-parentheses, but not google-readability*
20# or google-runtime-references.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070021DEFAULT_GLOBAL_TIDY_CHECKS := \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070022 $(subst $(space),, \
Chih-Hung Hsieh97032cc2016-08-16 13:42:06 -070023 -*,google* \
24 ,misc-macro-parentheses \
25 ,performance* \
26 ,-google-readability* \
27 ,-google-runtime-references \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070028 )
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070029
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070030# There are too many clang-tidy warnings in external and vendor projects.
31# Enable only some google checks for these projects.
32DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \
33 $(subst $(space),, \
Chih-Hung Hsieh97032cc2016-08-16 13:42:06 -070034 -*,google* \
35 ,-google-build-using-namespace \
36 ,-google-default-arguments \
37 ,-google-explicit-constructor \
38 ,-google-readability* \
39 ,-google-runtime-int \
40 ,-google-runtime-references \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070041 )
42
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070043# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070044# <local_path_prefix>:,<tidy-checks>
45# The last matched local_path_prefix should be the most specific to be used.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070046DEFAULT_LOCAL_TIDY_CHECKS := \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070047 external/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
48 external/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
49 external/webrtc:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
Chih-Hung Hsiehb9ea8d12016-08-23 11:07:19 -070050 frameworks/compile/mclinker/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070051 hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
52 vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
53 vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070054
55# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
56define find_default_local_tidy_check2
57$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
58endef
59
60# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
61define find_default_local_tidy_check
62$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
63endef
64
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070065# Returns the default tidy check list for local project path $(1).
66# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
67# most specific pattern.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070068define default_global_tidy_checks
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070069$(lastword \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070070 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
71 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
72 $(call find_default_local_tidy_check,$(pattern),$(1)) \
73 ) \
74)
75endef
Chih-Hung Hsieh0a33f652016-09-06 20:06:28 -070076
77# Give warnings to header files only in selected directories.
78# Do not give warnings to external or vendor header files,
79# which contain too many warnings.
80DEFAULT_TIDY_HEADER_DIRS := \
81 art/ \
82 |bionic/ \
83 |bootable/ \
84 |build/ \
85 |cts/ \
86 |dalvik/ \
87 |developers/ \
88 |development/ \
89 |frameworks/ \
90 |libcore/ \
91 |libnativehelper/ \
92 |system/
93
94# Default filter contains current directory $1 and DEFAULT_TIDY_HEADER_DIRS.
95define default_tidy_header_filter
96 -header-filter="($(subst $(space),,$1|$(DEFAULT_TIDY_HEADER_DIRS)))"
97endef