Skip to content

Commit

Permalink
Allow LOCAL_C*FLAGS to override Application.mk.
Browse files Browse the repository at this point in the history
`APP_CFLAGS` is the best place to put things like `-Wall -Werror`,
but with Clang the order of warning flags matters. If the
Application.mk settings come after the module level settings, modules
can't override global settings.

Test: ./run_tests.py --filter LOCAL_CFLAGS-beats-APP_CFLAGS
Bug: android/ndk#307
Change-Id: I3b7f1488fb2795a3fbbac53226e67b21a85b5b95
  • Loading branch information
DanAlbert committed Mar 24, 2017
1 parent 9102004 commit 601456b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
20 changes: 10 additions & 10 deletions build/core/definitions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1612,10 +1612,10 @@ _OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2)
_FLAGS := $$($$(my)CFLAGS) \
$$(call get-src-file-target-cflags,$(1)) \
$$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CONLYFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(NDK_APP_CONLYFLAGS) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CONLYFLAGS) \
--sysroot $$(call host-path,$$(SYSROOT_INC)) \
$(SYSROOT_ARCH_INC_ARG) \
-c \
Expand All @@ -1640,10 +1640,10 @@ _OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2)
_FLAGS := $$($$(my)CFLAGS) \
$$(call get-src-file-target-cflags,$(1)) \
$$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_ASFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(NDK_APP_ASFLAGS) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_ASFLAGS) \
-isystem $$(call host-path,$$(SYSROOT_INC)/usr/include) \
-c \

Expand Down Expand Up @@ -1741,12 +1741,12 @@ _OBJ:=$$(LOCAL_OBJS_DIR:%/=%)/$(2)
_FLAGS := $$($$(my)CXXFLAGS) \
$$(call get-src-file-target-cflags,$(1)) \
$$(call host-c-includes, $$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CPPFLAGS) \
$$(LOCAL_CXXFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(NDK_APP_CPPFLAGS) \
$$(NDK_APP_CXXFLAGS) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CPPFLAGS) \
$$(LOCAL_CXXFLAGS) \
--sysroot $$(call host-path,$$(SYSROOT_INC)) \
$(SYSROOT_ARCH_INC_ARG) \
-c \
Expand Down Expand Up @@ -1790,12 +1790,12 @@ _COMPAT := $(6)
_CPP_FLAGS := $$($$(my)CXXFLAGS) \
$$(call get-src-file-target-cflags,$(1)) \
$$(call host-c-includes, $$(LOCAL_C_INCLUDES) $$(LOCAL_PATH)) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CPPFLAGS) \
$$(LOCAL_CXXFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(NDK_APP_CPPFLAGS) \
$$(NDK_APP_CXXFLAGS) \
$$(LOCAL_CFLAGS) \
$$(LOCAL_CPPFLAGS) \
$$(LOCAL_CXXFLAGS) \
--sysroot $$(call host-path,$$(SYSROOT_INC)) \
$(SYSROOT_ARCH_INC_ARG) \
-fno-rtti \
Expand Down
7 changes: 7 additions & 0 deletions tests/build/LOCAL_CFLAGS-beats-APP_CFLAGS/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo.c
LOCAL_CFLAGS := -Wno-error=return-type
include $(BUILD_STATIC_LIBRARY)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_CFLAGS := -Wall -Werror
2 changes: 2 additions & 0 deletions tests/build/LOCAL_CFLAGS-beats-APP_CFLAGS/jni/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int foo() {
}

0 comments on commit 601456b

Please sign in to comment.