blob: d50b43d49e2a186b5ec72a54e9bd23874b036171 [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 Hsiehc8682932016-07-26 14:27:03 -070022 -*,google*,performance*,misc-macro-parentheses \
23 ,-google-readability*,-google-runtime-references
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070024
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070025# Disable style rules usually not followed by external projects.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070026# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
27# <local_path_prefix>:,<tidy-check-pattern>
28# The tidy-check-patterns of all matching local_path_prefixes will be used.
29# For example, external/google* projects will have:
30# ,-google-build-using-namespace,-google-explicit-constructor
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070031# ,-google-runtime-int,-misc-macro-parentheses,
32# ,google-runtime-int,misc-macro-parentheses
33# where google-runtime-int and misc-macro-parentheses are enabled at the end.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070034DEFAULT_LOCAL_TIDY_CHECKS := \
35 external/:,-google-build-using-namespace \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070036 external/:,-google-explicit-constructor,-google-runtime-int \
Chih-Hung Hsiehe1ea9432016-05-11 13:39:48 -070037 external/:,-misc-macro-parentheses \
38 external/google:,google-runtime-int,misc-macro-parentheses \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070039 external/webrtc/:,google-runtime-int \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070040 hardware/qcom:,-google-build-using-namespace \
41 hardware/qcom:,-google-explicit-constructor,-google-runtime-int \
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -070042 vendor/lge:,-google-build-using-namespace,-misc-macro-parentheses \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070043 vendor/lge:,-google-explicit-constructor,-google-runtime-int \
Chih-Hung Hsiehc21ddbd2016-07-20 10:08:51 -070044 vendor/widevine:,-google-build-using-namespace,-misc-macro-parentheses \
Chih-Hung Hsieh30f86e42016-04-29 15:16:59 -070045 vendor/widevine:,-google-explicit-constructor,-google-runtime-int \
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
57# Returns concatenated tidy check patterns from the
58# DEFAULT_GLOBAL_TIDY_CHECKS and all matched patterns
59# in DEFAULT_LOCAL_TIDY_CHECKS based on given directory path $(1).
60define default_global_tidy_checks
61$(subst $(space),, \
62 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
63 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
64 $(call find_default_local_tidy_check,$(pattern),$(1)) \
65 ) \
66)
67endef