From d9cd1fafb5db622cb4277f961dd81975a0c0d330 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Tue, 2 Aug 2016 14:22:06 -0700 Subject: [PATCH] Issue warning on projects with LOCAL_CLANG set to false. * LOCAL_CLANG_EXCEPTION_PROJECTS is the list of project prefixes. * New warning message is detected by warn.py as high severity. Bug: 30575506 Change-Id: I87a38b2ba6bab1d2e5e7a9d5ec9557f0e609727c Test: build and find new warning in build.log --- core/binary.mk | 7 +++++++ core/clang/config.mk | 17 +++++++++++++++++ tools/warn.py | 3 +++ 3 files changed, 27 insertions(+) diff --git a/core/binary.mk b/core/binary.mk index 4554d4db0..10d447b72 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -265,6 +265,13 @@ endif ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) endif +# Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found +# in the exception project list. +ifeq ($(my_clang),false) + ifeq ($(call find_in_local_clang_exception_projects,$(LOCAL_MODULE_MAKEFILE)),) + $(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): warning: LOCAL_CLANG is set to false) + endif +endif # clang is enabled by default for host builds # enable it unless we've specifically disabled clang above diff --git a/core/clang/config.mk b/core/clang/config.mk index 468551475..e47c36a52 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -143,4 +143,21 @@ ifeq ($(HOST_PREFER_32_BIT),true) FORCE_BUILD_LLVM_COMPONENTS := true endif +# A list of projects that are allowed to set LOCAL_CLANG to false. +LOCAL_CLANG_EXCEPTION_PROJECTS := \ + device/huawei/angler/ \ + device/lge/bullhead/ \ + external/valgrind/ \ + hardware/qcom/ \ + $(INTERNAL_LOCAL_CLANG_EXCEPTION_PROJECTS) + +# Find $1 in the exception project list. +define find_in_local_clang_exception_projects +$(subst $(space),, \ + $(foreach project,$(LOCAL_CLANG_EXCEPTION_PROJECTS), \ + $(if $(filter $(project)%,$(1)),$(project)) \ + ) \ +) +endef + include $(BUILD_SYSTEM)/clang/tidy.mk diff --git a/tools/warn.py b/tools/warn.py index f17e8ac0b..f118263be 100755 --- a/tools/warn.py +++ b/tools/warn.py @@ -74,6 +74,9 @@ warnpatterns = [ 'description':'make: overriding commands/ignoring old commands', 'patterns':[r".*: warning: overriding commands for target .+", r".*: warning: ignoring old commands for target .+"] }, + { 'category':'make', 'severity':severity.HIGH, 'members':[], 'option':'', + 'description':'make: LOCAL_CLANG is false', + 'patterns':[r".*: warning: LOCAL_CLANG is set to false"] }, { 'category':'C/C++', 'severity':severity.HIGH, 'members':[], 'option':'-Wimplicit-function-declaration', 'description':'Implicit function declaration', 'patterns':[r".*: warning: implicit declaration of function .+",