Skip to content

Commit

Permalink
Fix pch handling for tagged sources.
Browse files Browse the repository at this point in the history
Still generate the one precompiled header for the default
configuration, but don't use it for sources that have additional tags
(.arm or .neon, shouldn't affect non-ARM32).

Patch contributed by @DoDoENT.

Bug: #14
Change-Id: I1fff1599b3f30e69134aed4972117745bc9c053a
  • Loading branch information
DanAlbert committed Mar 14, 2016
1 parent da081ef commit 412b3f0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
19 changes: 14 additions & 5 deletions build/core/build-binary.mk
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,22 @@ ifneq (,$(LOCAL_PCH))
# Build PCH
$(call compile-cpp-source,$(LOCAL_PCH),$(LOCAL_BUILT_PCH).gch)

# All obj files are dependent on the PCH
$(foreach src,$(filter $(all_cpp_patterns),$(LOCAL_SRC_FILES)),\
# Filter obj files that are dependent on the PCH (only those without tags)
ifeq (true,$(LOCAL_ARM_NEON))
TAGS_TO_FILTER=arm
else
TAGS_TO_FILTER=arm neon
endif

allowed_src := $(foreach src,$(filter $(all_cpp_patterns),$(LOCAL_SRC_FILES)),\
$(if $(filter $(TAGS_TO_FILTER),$(LOCAL_SRC_FILES_TAGS.$(src))),,$(src))\
)
# All files without tags depend on PCH
$(foreach src,$(allowed_src),\
$(eval $(LOCAL_OBJS_DIR)/$(call get-object-name,$(src)) : $(LOCAL_OBJS_DIR)/$(LOCAL_BUILT_PCH).gch)\
)

# Files from now on build with PCH
LOCAL_CPPFLAGS += -Winvalid-pch -include $(LOCAL_OBJS_DIR)/$(LOCAL_BUILT_PCH)
# Make sure those files are built with PCH
$(call add-src-files-target-cflags,$(allowed_src),-Winvalid-pch -include $(LOCAL_OBJS_DIR)/$(LOCAL_BUILT_PCH))

# Insert PCH dir at beginning of include search path
LOCAL_C_INCLUDES := \
Expand Down
22 changes: 22 additions & 0 deletions tests/build/pch-tags/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := pch
LOCAL_PCH := stdafx.h
LOCAL_SRC_FILES := foo.cpp bar.cpp
LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := pch-arm
LOCAL_PCH := stdafx.h
LOCAL_SRC_FILES := foo.cpp bar.cpp.arm
LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := pch-neon
LOCAL_PCH := stdafx.h
LOCAL_SRC_FILES := foo.cpp bar.cpp.neon
LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/build/pch-tags/jni/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 412b3f0

Please sign in to comment.