Merge "Add tidy.mk to set up global default checks."
This commit is contained in:
commit
214c7fadf1
3 changed files with 60 additions and 2 deletions
|
@ -1412,8 +1412,7 @@ ifneq (,$(filter 1 true,$(my_tidy_enabled)))
|
|||
# Set up global default checks
|
||||
my_tidy_checks := $(WITH_TIDY_CHECKS)
|
||||
ifeq ($(my_tidy_checks),)
|
||||
# AOSP source did not follow Google readability rules.
|
||||
my_tidy_checks := -*,google*,-google-readability*
|
||||
my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH))
|
||||
endif
|
||||
# Append local clang-tidy checks.
|
||||
ifneq ($(LOCAL_TIDY_CHECKS),)
|
||||
|
|
|
@ -177,3 +177,5 @@ ifeq ($(HOST_PREFER_32_BIT),true)
|
|||
# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
|
||||
FORCE_BUILD_LLVM_COMPONENTS := true
|
||||
endif
|
||||
|
||||
include $(BUILD_SYSTEM)/clang/tidy.mk
|
||||
|
|
57
core/clang/tidy.mk
Normal file
57
core/clang/tidy.mk
Normal file
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Copyright (C) 2016 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Most Android source files are not clang-tidy clean yet.
|
||||
# Global tidy checks include only google* minus google-readability*.
|
||||
DEFAULT_GLOBAL_TIDY_CHECKS := \
|
||||
-*,google*,-google-readability*
|
||||
|
||||
# Disable google style rules usually not followed by external projects.
|
||||
# Every word in DEFAULT_LOCAL_TIDY_CHECKS list has the following format:
|
||||
# <local_path_prefix>:,<tidy-check-pattern>
|
||||
# The tidy-check-patterns of all matching local_path_prefixes will be used.
|
||||
# For example, external/google* projects will have:
|
||||
# ,-google-build-using-namespace,-google-explicit-constructor
|
||||
# ,-google-runtime-int,google-runtime-int
|
||||
# where google-runtime-int is enabled at the end.
|
||||
DEFAULT_LOCAL_TIDY_CHECKS := \
|
||||
external/:,-google-build-using-namespace \
|
||||
external/:,-google-explicit-constructor \
|
||||
external/:,-google-runtime-int \
|
||||
external/google:,google-runtime-int \
|
||||
external/webrtc/:,google-runtime-int \
|
||||
|
||||
# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
|
||||
define find_default_local_tidy_check2
|
||||
$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
|
||||
endef
|
||||
|
||||
# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
|
||||
define find_default_local_tidy_check
|
||||
$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
|
||||
endef
|
||||
|
||||
# Returns concatenated tidy check patterns from the
|
||||
# DEFAULT_GLOBAL_TIDY_CHECKS and all matched patterns
|
||||
# in DEFAULT_LOCAL_TIDY_CHECKS based on given directory path $(1).
|
||||
define default_global_tidy_checks
|
||||
$(subst $(space),, \
|
||||
$(DEFAULT_GLOBAL_TIDY_CHECKS) \
|
||||
$(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
|
||||
$(call find_default_local_tidy_check,$(pattern),$(1)) \
|
||||
) \
|
||||
)
|
||||
endef
|
Loading…
Reference in a new issue