Merge "Add default -Wall -Werror or -Wall."

am: 6ddc7843cb

Change-Id: Ib9b93dbd61bb9141b88fb7f1f7c4ead3fd28accc
This commit is contained in:
Chih-hung Hsieh 2017-11-21 21:24:12 +00:00 committed by android-build-merger
commit 39610026fb
3 changed files with 40 additions and 39 deletions

View File

@ -517,6 +517,20 @@ $(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
$(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@ $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT)) $(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
# -----------------------------------------------------------------
# Modules use -Wno-error, or added default -Wall -Werror
WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
$(WALL_WERROR):
@rm -f $@
echo "# Modules using -Wno-error" >> $@
for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
echo "# Modules added default -Wall -Werror" >> $@
for m in $(sort $(SOONG_MODULES_ADDED_WERROR) $(MODULES_ADDED_WERROR)); do echo $$m >> $@; done
echo "# Modules added default -Wall" >> $@
for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
$(call dist-for-goals,droidcore,$(WALL_WERROR))
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# The dev key is used to sign this package, and as the key required # The dev key is used to sign this package, and as the key required
# for future OTA packages installed by this system. Actual product # for future OTA packages installed by this system. Actual product

View File

@ -1664,13 +1664,31 @@ ifeq ($(my_strict),true)
my_cflags += -DANDROID_STRICT my_cflags += -DANDROID_STRICT
endif endif
# Add -Werror if LOCAL_PATH is in the WARNING_DISALLOWED project list, # Check if -Werror or -Wno-error is used in C compiler flags.
# or not in the WARNING_ALLOWED project list. # Modules defined in $(SOONG_ANDROID_MK) are checked in soong's cc.go.
ifneq (,$(strip $(call find_warning_disallowed_projects,$(LOCAL_PATH)))) ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
my_cflags_no_override += -Werror # Header libraries do not need cflags.
else ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS))
# Prebuilt modules do not need cflags.
ifeq (,$(LOCAL_PREBUILT_MODULE_FILE))
my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override)
# Issue warning if -Wno-error is used.
ifneq (,$(filter -Wno-error,$(my_all_cflags)))
$(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
else
# Issue warning if -Werror is not used. Add it.
ifeq (,$(filter -Werror,$(my_all_cflags)))
# Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list.
ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH)))) ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
my_cflags_no_override += -Werror $(eval MODULES_ADDED_WERROR := $(MODULES_ADDED_WERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
my_cflags := -Wall -Werror $(my_cflags)
else
$(eval MODULES_ADDED_WALL := $(MODULES_ADDED_WALL) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
my_cflags := -Wall $(my_cflags)
endif
endif
endif
endif
endif endif
endif endif

View File

@ -919,38 +919,7 @@ else
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION) APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
endif endif
# Projects clean of compiler warnings should be compiled with -Werror. # ANDROID_WARNING_ALLOWED_PROJECTS is generated by build/soong.
# If most modules in a directory such as external/ have warnings,
# the directory should be in ANDROID_WARNING_ALLOWED_PROJECTS list.
# When some of its subdirectories are cleaned up, the subdirectories
# can be added into ANDROID_WARNING_DISALLOWED_PROJECTS list, e.g.
# external/fio/.
ANDROID_WARNING_DISALLOWED_PROJECTS := \
art/% \
bionic/% \
external/fio/% \
hardware/interfaces/% \
define find_warning_disallowed_projects
$(filter $(ANDROID_WARNING_DISALLOWED_PROJECTS),$(1)/)
endef
# Projects with compiler warnings are compiled without -Werror.
ANDROID_WARNING_ALLOWED_PROJECTS := \
bootable/% \
cts/% \
dalvik/% \
development/% \
device/% \
external/% \
frameworks/% \
hardware/% \
packages/% \
system/% \
test/vts/% \
tools/adt/idea/android/ultimate/get_modification_time/jni/% \
vendor/% \
define find_warning_allowed_projects define find_warning_allowed_projects
$(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/) $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
endef endef