diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2013-08-27 17:33:06 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2013-09-04 09:26:25 +0800 |
commit | 6cea59a4b9b62442a5e17f6954e308a35ba12b5e (patch) | |
tree | e3244d720e8972e32e7217f91d2be149f89387be | |
parent | d58df2de78b798f8fc301afcfeb61f574629b8ce (diff) | |
download | build-6cea59a4b9b62442a5e17f6954e308a35ba12b5e.tar.gz |
Add "WITH_SYNTAX_CHECK=1 make ..."
The new option WITH_SYNTAX_CHECK=1 instructs build system to invoke
"clang -fsyntax-only" to utilize clang's better diagnostics before calling
LOCAL_CC/LOCAL_CXX for code generation. The compilation time is slightly
longer, and the generated object file should be the same as w/o WITH_SYNTAX_CHECK
Project use lots of GCC extensions (eg. nested function) not supported
by clang may opt out by adding LOCAL_NO_SYNTAX_CHECK:=true
Change-Id: I5689586788ef049bd967364f71f31f1e359bd121
-rw-r--r-- | core/binary.mk | 16 | ||||
-rw-r--r-- | core/clear_vars.mk | 1 | ||||
-rw-r--r-- | core/config.mk | 9 |
3 files changed, 26 insertions, 0 deletions
diff --git a/core/binary.mk b/core/binary.mk index 3893d03539..3785af1f95 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -170,6 +170,16 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(TARGET_GLOBAL $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) +ifeq ($(strip $(WITH_SYNTAX_CHECK)),) + LOCAL_NO_SYNTAX_CHECK := true +endif + +ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) + my_syntax_arch := host +else + my_syntax_arch := $(TARGET_ARCH) +endif + ifeq ($(strip $(LOCAL_CC)),) ifeq ($(strip $(LOCAL_CLANG)),true) LOCAL_CC := $(CLANG) @@ -177,6 +187,9 @@ ifeq ($(strip $(LOCAL_CC)),) LOCAL_CC := $($(my_prefix)CC) endif endif +ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) + LOCAL_CC := $(SYNTAX_TOOLS_PREFIX)/ccc-syntax $(my_syntax_arch) "$(LOCAL_CC)" +endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(LOCAL_CC) ifeq ($(strip $(LOCAL_CXX)),) @@ -186,6 +199,9 @@ ifeq ($(strip $(LOCAL_CXX)),) LOCAL_CXX := $($(my_prefix)CXX) endif endif +ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) + LOCAL_CXX := $(SYNTAX_TOOLS_PREFIX)/cxx-syntax $(my_syntax_arch) "$(LOCAL_CXX)" +endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(LOCAL_CXX) # TODO: support a mix of standard extensions so that this isn't necessary diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 7ad58b2e9b..140cfa2f07 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -137,6 +137,7 @@ LOCAL_ADDITIONAL_CERTIFICATES:= LOCAL_PREBUILT_MODULE_FILE:= LOCAL_POST_INSTALL_CMD:= LOCAL_DIST_BUNDLED_BINARIES:= +LOCAL_NO_SYNTAX_CHECK:= # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to # iterate over thousands of entries every time. diff --git a/core/config.mk b/core/config.mk index 21e187d67a..0153109733 100644 --- a/core/config.mk +++ b/core/config.mk @@ -247,6 +247,15 @@ TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT))) TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT)) endif +# Disable WITH_SYNTAX_CHECK if tool can't be found +SYNTAX_TOOLS_PREFIX := prebuilts/clang/$(HOST_PREBUILT_TAG)/host/3.3/bin +ifneq ($(strip $(WITH_SYNTAX_CHECK)),) + ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-syntax),) + $(warning *** Disable WITH_SYNTAX_CHECK because $(SYNTAX_TOOLS_PREFIX)/ccc-syntax does not exist) + WITH_SYNTAX_CHECK := + endif +endif + # Pick a Java compiler. include $(BUILD_SYSTEM)/combo/javac.mk |