blob: ee6b6edf8f213f40dfbefd13ae131c92f377f45a [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) \
50 hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
51 vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
52 vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070053
54# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
55define find_default_local_tidy_check2
56$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
57endef
58
59# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
60define find_default_local_tidy_check
61$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
62endef
63
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070064# Returns the default tidy check list for local project path $(1).
65# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
66# most specific pattern.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070067define default_global_tidy_checks
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070068$(lastword \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070069 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
70 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
71 $(call find_default_local_tidy_check,$(pattern),$(1)) \
72 ) \
73)
74endef