blob: 868f7bc885a641a86cda60bded5a31ede378345a [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
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070017# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
18define find_default_local_tidy_check2
19$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
20endef
21
22# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
23define find_default_local_tidy_check
24$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
25endef
26
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070027# Returns the default tidy check list for local project path $(1).
28# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
29# most specific pattern.
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070030define default_global_tidy_checks
Chih-Hung Hsiehfac19262016-08-08 15:01:59 -070031$(lastword \
Chih-Hung Hsieh460171a2016-04-21 15:37:24 -070032 $(DEFAULT_GLOBAL_TIDY_CHECKS) \
33 $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
34 $(call find_default_local_tidy_check,$(pattern),$(1)) \
35 ) \
36)
37endef
Chih-Hung Hsieh0a33f652016-09-06 20:06:28 -070038
Chih-Hung Hsieh0a33f652016-09-06 20:06:28 -070039# Default filter contains current directory $1 and DEFAULT_TIDY_HEADER_DIRS.
40define default_tidy_header_filter
41 -header-filter="($(subst $(space),,$1|$(DEFAULT_TIDY_HEADER_DIRS)))"
42endef