Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 1 | # |
| 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 Hsieh | c868293 | 2016-07-26 14:27:03 -0700 | [diff] [blame] | 18 | # Global tidy checks include only google*, performance*, |
| 19 | # and misc-macro-parentheses, but not google-readability* |
| 20 | # or google-runtime-references. |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 21 | DEFAULT_GLOBAL_TIDY_CHECKS := \ |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 22 | $(subst $(space),, \ |
Chih-Hung Hsieh | 97032cc | 2016-08-16 13:42:06 -0700 | [diff] [blame] | 23 | -*,google* \ |
| 24 | ,misc-macro-parentheses \ |
| 25 | ,performance* \ |
| 26 | ,-google-readability* \ |
| 27 | ,-google-runtime-references \ |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 28 | ) |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 29 | |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 30 | # There are too many clang-tidy warnings in external and vendor projects. |
| 31 | # Enable only some google checks for these projects. |
| 32 | DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \ |
| 33 | $(subst $(space),, \ |
Chih-Hung Hsieh | 97032cc | 2016-08-16 13:42:06 -0700 | [diff] [blame] | 34 | -*,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 Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 41 | ) |
| 42 | |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 43 | # Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format: |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 44 | # <local_path_prefix>:,<tidy-checks> |
| 45 | # The last matched local_path_prefix should be the most specific to be used. |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 46 | DEFAULT_LOCAL_TIDY_CHECKS := \ |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 47 | external/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ |
| 48 | external/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ |
| 49 | external/webrtc:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ |
Chih-Hung Hsieh | b9ea8d1 | 2016-08-23 11:07:19 -0700 | [diff] [blame] | 50 | frameworks/compile/mclinker/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 51 | hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ |
| 52 | vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \ |
| 53 | vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \ |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 54 | |
| 55 | # Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1). |
| 56 | define find_default_local_tidy_check2 |
| 57 | $(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1))) |
| 58 | endef |
| 59 | |
| 60 | # Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1). |
| 61 | define find_default_local_tidy_check |
| 62 | $(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2)) |
| 63 | endef |
| 64 | |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 65 | # 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 Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 68 | define default_global_tidy_checks |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame] | 69 | $(lastword \ |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 70 | $(DEFAULT_GLOBAL_TIDY_CHECKS) \ |
| 71 | $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \ |
| 72 | $(call find_default_local_tidy_check,$(pattern),$(1)) \ |
| 73 | ) \ |
| 74 | ) |
| 75 | endef |
Chih-Hung Hsieh | 0a33f65 | 2016-09-06 20:06:28 -0700 | [diff] [blame^] | 76 | |
| 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. |
| 80 | DEFAULT_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. |
| 95 | define default_tidy_header_filter |
| 96 | -header-filter="($(subst $(space),,$1|$(DEFAULT_TIDY_HEADER_DIRS)))" |
| 97 | endef |