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 | c868293 | 2016-07-26 14:27:03 -0700 | [diff] [blame] | 22 | -*,google*,performance*,misc-macro-parentheses \ |
| 23 | ,-google-readability*,-google-runtime-references |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 24 | |
Chih-Hung Hsieh | e1ea943 | 2016-05-11 13:39:48 -0700 | [diff] [blame] | 25 | # Disable style rules usually not followed by external projects. |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 26 | # 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 Hsieh | e1ea943 | 2016-05-11 13:39:48 -0700 | [diff] [blame] | 31 | # ,-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 Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 34 | DEFAULT_LOCAL_TIDY_CHECKS := \ |
| 35 | external/:,-google-build-using-namespace \ |
Chih-Hung Hsieh | 30f86e4 | 2016-04-29 15:16:59 -0700 | [diff] [blame] | 36 | external/:,-google-explicit-constructor,-google-runtime-int \ |
Chih-Hung Hsieh | e1ea943 | 2016-05-11 13:39:48 -0700 | [diff] [blame] | 37 | external/:,-misc-macro-parentheses \ |
| 38 | external/google:,google-runtime-int,misc-macro-parentheses \ |
Chih-Hung Hsieh | 460171a | 2016-04-21 15:37:24 -0700 | [diff] [blame] | 39 | external/webrtc/:,google-runtime-int \ |
Chih-Hung Hsieh | 30f86e4 | 2016-04-29 15:16:59 -0700 | [diff] [blame] | 40 | hardware/qcom:,-google-build-using-namespace \ |
| 41 | hardware/qcom:,-google-explicit-constructor,-google-runtime-int \ |
Chih-Hung Hsieh | c21ddbd | 2016-07-20 10:08:51 -0700 | [diff] [blame] | 42 | vendor/lge:,-google-build-using-namespace,-misc-macro-parentheses \ |
Chih-Hung Hsieh | 30f86e4 | 2016-04-29 15:16:59 -0700 | [diff] [blame] | 43 | vendor/lge:,-google-explicit-constructor,-google-runtime-int \ |
Chih-Hung Hsieh | c21ddbd | 2016-07-20 10:08:51 -0700 | [diff] [blame] | 44 | vendor/widevine:,-google-build-using-namespace,-misc-macro-parentheses \ |
Chih-Hung Hsieh | 30f86e4 | 2016-04-29 15:16:59 -0700 | [diff] [blame] | 45 | vendor/widevine:,-google-explicit-constructor,-google-runtime-int \ |
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 | |
| 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). |
| 60 | define 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 | ) |
| 67 | endef |