From bbe4e11a7681c52d2197ce35ae47d4939ca246b6 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 12 Jun 2019 17:13:28 +0000 Subject: [PATCH] Call clean-path in more places When an Android.mk specifies a local path that is outside the current directory, it uses '..', since we prepend $(LOCAL_PATH)/ to the given path. This path ('a/b/../c') gets inserted into command lines and dependencies. For dependencies, when it gets to Ninja, Ninja calls CanonicalizePath and removes those references ('a/c'), but the command line is preserved. So we've got a command line that references 'a/b', but no dependency on it. Usually that's not a big problem, but it's an issue if we're trying to only expose dependencies to the rule, like with RBE only sending the dependencies to the remote workers. So use our 'clean-path' macro to collapse the '..' references in Kati so that they don't show up in the command line either. Test: treehugger Test: build a system image with RBE Change-Id: I0706faa2ac15e9c12c720f43c7bb8171c5efd97c --- core/base_rules.mk | 2 +- core/definitions.mk | 6 +++--- core/prebuilt_internal.mk | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 6c7e8831d2..b0e0577a2e 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -396,7 +396,7 @@ endif logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES) ifneq ($(strip $(logtags_sources)),) -event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources)) +event_log_tags := $(foreach f,$(addprefix $(LOCAL_PATH)/,$(logtags_sources)),$(call clean-path,$(f))) else event_log_tags := endif diff --git a/core/definitions.mk b/core/definitions.mk index e1977ba9b2..717e10ba35 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1012,7 +1012,7 @@ endef # 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) +$$(define-aidl-java-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL) $$(transform-aidl-to-java) $(3) += $$(define-aidl-java-rule-src) endef @@ -1025,7 +1025,7 @@ endef # You must call this with $(eval). define define-aidl-cpp-rule define-aidl-cpp-rule-src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1)))) -$$(define-aidl-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL_CPP) +$$(define-aidl-cpp-rule-src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL_CPP) $$(transform-aidl-to-cpp) $(3) += $$(define-aidl-cpp-rule-src) endef @@ -1925,7 +1925,7 @@ $(hide) $(AAPT2) link -o $@ \ $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \ $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \ $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \ - $(addprefix -A ,$(PRIVATE_ASSET_DIR)) \ + $(addprefix -A ,$(foreach d,$(PRIVATE_ASSET_DIR),$(call clean-path,$(d)))) \ $(addprefix --java ,$(PRIVATE_JAVA_GEN_DIR)) \ $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \ $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index ad62e1a82f..7006667b00 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -23,13 +23,13 @@ my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT) ifdef LOCAL_PREBUILT_MODULE_FILE my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE) else ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) - my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) + my_prebuilt_src_file := $(call clean-path,$(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := else ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix) - my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) + my_prebuilt_src_file := $(call clean-path,$(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))) LOCAL_SRC_FILES_$(my_32_64_bit_suffix) := else ifdef LOCAL_SRC_FILES - my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES) + my_prebuilt_src_file := $(call clean-path,$(LOCAL_PATH)/$(LOCAL_SRC_FILES)) LOCAL_SRC_FILES := else ifdef LOCAL_REPLACE_PREBUILT_APK_INSTALLED # This is handled specially in app_prebuilt_internal.mk