From d9205ba17e24d1b8eca2773a7b40c50e541eb456 Mon Sep 17 00:00:00 2001 From: Christopher Wiley Date: Thu, 23 Jun 2016 16:44:47 -0700 Subject: [PATCH] Fix path escaping for aidl generated java Bug: 29619260 Change-Id: I806044573661c61e691adf36a47092188db87ab6 Test: Generated java with ../ in paths appears in the right place. --- core/definitions.mk | 13 +++++++++++++ core/java.mk | 19 ++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index de1948ff6..237319e00 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1084,6 +1084,19 @@ $(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \ $< $(PRIVATE_HEADER_OUTPUT_DIR) $@ endef +## Given a .aidl file path, generate the rule to compile it a .java file +# $(1): a .aidl source file +# $(2): a directory to place the generated .java files in +# $(3): name of a variable to add the path to the generated source file to +# +# You must call this with $(eval). +define define-aidl-java-rule +define-aidl-java-rule-src := $(patsubst %.aidl,%.java,$(subst ../,dotdot/,$(addprefix $(2)/,$(1)))) +$$(define-aidl-java-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL) + $$(transform-aidl-to-java) +$(3) += $$(define-aidl-java-rule-src) +endef + ## Given a .aidl file path generate the rule to compile it a .cpp file. # $(1): a .aidl source file # $(2): a directory to place the generated .cpp files in diff --git a/core/java.mk b/core/java.mk index 912ce0a19..159de5a49 100644 --- a/core/java.mk +++ b/core/java.mk @@ -277,10 +277,9 @@ endif ## AIDL: Compile .aidl files to .java ########################################################### aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES)) +aidl_java_sources := ifneq ($(strip $(aidl_sources)),) -aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources))) -aidl_sources := $(addprefix $(LOCAL_PATH)/, $(aidl_sources)) aidl_preprocess_import := ifdef LOCAL_SDK_VERSION @@ -294,19 +293,17 @@ else # build against the platform. LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) endif # LOCAL_SDK_VERSION -$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) -$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \ - $(LOCAL_PATH)/%.aidl \ - $(LOCAL_ADDITIONAL_DEPENDENCIES) \ - $(AIDL) \ - $(aidl_preprocess_import) - $(transform-aidl-to-java) +$(foreach s,$(aidl_sources),\ + $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON),aidl_java_sources))) $(foreach java,$(aidl_java_sources), \ $(call include-depfile,$(java:%.java=%.P),$(java))) -else -aidl_java_sources := +$(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import) + +$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) +$(aidl_java_sources : PRIVATE_MODULE := $(LOCAL_MODULE) + endif ##########################################