blob: 860257fac7a3fe072a55dc14d8c06309a4adc0a8 [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),, \
23 -*,google*,performance*,misc-macro-parentheses \
24 ,-google-readability*,-google-runtime-references \
25 )
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070026
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070027# There are too many clang-tidy warnings in external and vendor projects.
28# Enable only some google checks for these projects.
29DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \
30 $(subst $(space),, \
31 -*,google*,-google-build-using-namespace \
32 ,-google-readability*,-google-runtime-references \
33 ,-google-explicit-constructor,-google-runtime-int \
34 )
35
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070036# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070037# <local_path_prefix>:,<tidy-checks>
38# The last matched local_path_prefix should be the most specific to be used.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070039DEFAULT_LOCAL_TIDY_CHECKS := \
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070040 external/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
41 external/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
42 external/webrtc:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
43 hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
44 vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
45 vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070046
47# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
48define find_default_local_tidy_check2
49$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
50endef
51
52# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
53define find_default_local_tidy_check
54$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
55endef
56
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070057# Returns the default tidy check list for local project path $(1).
58# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
59# most specific pattern.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070060define default_global_tidy_checks
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070061$(lastword \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070062 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
63 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
64 $(call find_default_local_tidy_check,$(pattern),$(1)) \
65 ) \
66)
67endef