blob: 019e6f0292191af0a3a0230abf910affc71c0673 [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 Hsiehe1ea9432016-05-11 13:39:48 -070018# Global tidy checks include only google* and misc-macro-parentheses,
19# but not google-readability*.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070020DEFAULT_GLOBAL_TIDY_CHECKS := \
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070021 -*,google*,-google-readability*,misc-macro-parentheses
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070022
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070023# Disable style rules usually not followed by external projects.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070024# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
25# <local_path_prefix>:,<tidy-check-pattern>
26# The tidy-check-patterns of all matching local_path_prefixes will be used.
27# For example, external/google* projects will have:
28# ,-google-build-using-namespace,-google-explicit-constructor
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070029# ,-google-runtime-int,-misc-macro-parentheses,
30# ,google-runtime-int,misc-macro-parentheses
31# where google-runtime-int and misc-macro-parentheses are enabled at the end.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070032DEFAULT_LOCAL_TIDY_CHECKS := \
33 external/:,-google-build-using-namespace \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070034 external/:,-google-explicit-constructor,-google-runtime-int \
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070035 external/:,-misc-macro-parentheses \
36 external/google:,google-runtime-int,misc-macro-parentheses \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070037 external/webrtc/:,google-runtime-int \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070038 hardware/qcom:,-google-build-using-namespace \
39 hardware/qcom:,-google-explicit-constructor,-google-runtime-int \
40 vendor/lge:,-google-build-using-namespace \
41 vendor/lge:,-google-explicit-constructor,-google-runtime-int \
42 vendor/widevine:,-google-build-using-namespace \
43 vendor/widevine:,-google-explicit-constructor,-google-runtime-int \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070044
45# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
46define find_default_local_tidy_check2
47$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
48endef
49
50# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
51define find_default_local_tidy_check
52$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
53endef
54
55# Returns concatenated tidy check patterns from the
56# DEFAULT_GLOBAL_TIDY_CHECKS and all matched patterns
57# in DEFAULT_LOCAL_TIDY_CHECKS based on given directory path $(1).
58define default_global_tidy_checks
59$(subst $(space),, \
60 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
61 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
62 $(call find_default_local_tidy_check,$(pattern),$(1)) \
63 ) \
64)
65endef