Add LOCAL_EXPORT_CFLAGS for Soong

This lets Soong pass -isystem or -I as necessary (or potentially, even
other cflags in the future).

This is not available for Android.mk use, nor exposed directly to
Android.bp users.

Test: m -j
Change-Id: Id37d4692d5fbddce467bd777903b20169f44dd6e
This commit is contained in:
Dan Willemsen 2017-03-19 13:22:45 -07:00
parent efa8477fb4
commit 05909fae9f
3 changed files with 23 additions and 10 deletions

View File

@ -1738,7 +1738,14 @@ $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
# Export includes
###########################################################
export_includes := $(intermediates)/export_includes
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
export_cflags := $(foreach d,$(my_export_c_include_dirs),-I $(d))
# Soong exports cflags instead of include dirs, so that -isystem can be included.
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
export_cflags += $(LOCAL_EXPORT_CFLAGS)
else ifdef LOCAL_EXPORT_CFLAGS
$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead)
endif
$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
# Headers exported by whole static libraries are also exported by this library.
export_include_deps := $(strip \
$(foreach l,$(my_whole_static_libraries), \
@ -1761,10 +1768,8 @@ $(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps)
$(export_includes) : $(my_export_c_include_deps) $(my_generated_sources) $(export_include_deps) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
@echo Export includes file: $< -- $@
$(hide) mkdir -p $(dir $@) && rm -f $@.tmp && touch $@.tmp
ifdef my_export_c_include_dirs
$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
echo "-I $$d" >> $@.tmp; \
done
ifdef export_cflags
$(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >>$@.tmp
endif
ifdef export_include_deps
$(hide) for f in $(PRIVATE_REEXPORTED_INCLUDES); do \
@ -1776,6 +1781,7 @@ endif
else \
mv $@.tmp $@ ; \
fi
export_cflags :=
# Kati adds restat=1 to ninja. GNU make does nothing for this.
.KATI_RESTAT: $(export_includes)

View File

@ -69,6 +69,7 @@ LOCAL_DX_FLAGS:=
LOCAL_EMMA_COVERAGE_FILTER:=
LOCAL_EMMA_INSTRUMENT:=
LOCAL_ERROR_PRONE_FLAGS:=
LOCAL_EXPORT_CFLAGS:=
LOCAL_EXPORT_C_INCLUDE_DEPS:=
LOCAL_EXPORT_C_INCLUDE_DIRS:=
LOCAL_EXPORT_HEADER_LIBRARY_HEADERS:=

View File

@ -126,17 +126,23 @@ else # my_strip_module and my_pack_module_relocations not true
ifdef prebuilt_module_is_a_library
export_includes := $(intermediates)/export_includes
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
export_cflags := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d))
# Soong exports cflags instead of include dirs, so that -isystem can be included.
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
export_cflags += $(LOCAL_EXPORT_CFLAGS)
else ifdef LOCAL_EXPORT_CFLAGS
$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead)
endif
$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
$(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS)
@echo Export includes file: $< -- $@
$(hide) mkdir -p $(dir $@) && rm -f $@
ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
echo "-I $$d" >> $@; \
done
ifdef export_cflags
$(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >$@
else
$(hide) touch $@
endif
export_cflags :=
my_link_type := $(intermediates)/link_type
$(my_link_type): PRIVATE_LINK_TYPE := native:$(if $(LOCAL_SDK_VERSION),ndk,platform)