From 2a8a39398b6c6107e0b36f2e1af914727d742ad0 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sun, 19 Mar 2017 13:22:45 -0700 Subject: [PATCH] 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 Merged-In: Id37d4692d5fbddce467bd777903b20169f44dd6e Change-Id: Id37d4692d5fbddce467bd777903b20169f44dd6e --- core/binary.mk | 16 +++++++++++----- core/clear_vars.mk | 1 + core/prebuilt_internal.mk | 16 +++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 2538a932e..e2f6e00b7 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -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) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 257f3f91c..85431f565 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -68,6 +68,7 @@ LOCAL_DROIDDOC_USE_STANDARD_DOCLET:= LOCAL_DX_FLAGS:= LOCAL_EMMA_COVERAGE_FILTER:= LOCAL_EMMA_INSTRUMENT:= +LOCAL_EXPORT_CFLAGS:= LOCAL_EXPORT_C_INCLUDE_DEPS:= LOCAL_EXPORT_C_INCLUDE_DIRS:= LOCAL_EXPORT_HEADER_LIBRARY_HEADERS:= diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 997f97161..03f7cc7a5 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -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)