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),, \ |
| 23 | -*,google*,performance*,misc-macro-parentheses \ |
| 24 | ,-google-readability*,-google-runtime-references \ |
| 25 | ) |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 26 | |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame^] | 27 | # There are too many clang-tidy warnings in external and vendor projects. |
| 28 | # Enable only some google checks for these projects. |
| 29 | DEFAULT_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 Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 36 | # 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^] | 37 | # <local_path_prefix>:,<tidy-checks> |
| 38 | # 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] | 39 | DEFAULT_LOCAL_TIDY_CHECKS := \ |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame^] | 40 | 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 Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 46 | |
| 47 | # Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1). |
| 48 | define find_default_local_tidy_check2 |
| 49 | $(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1))) |
| 50 | endef |
| 51 | |
| 52 | # Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1). |
| 53 | define find_default_local_tidy_check |
| 54 | $(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2)) |
| 55 | endef |
| 56 | |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame^] | 57 | # 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 Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 60 | define default_global_tidy_checks |
Chih-Hung Hsieh | fac1926 | 2016-08-08 15:01:59 -0700 | [diff] [blame^] | 61 | $(lastword \ |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 62 | $(DEFAULT_GLOBAL_TIDY_CHECKS) \ |
| 63 | $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \ |
| 64 | $(call find_default_local_tidy_check,$(pattern),$(1)) \ |
| 65 | ) \ |
| 66 | ) |
| 67 | endef |