From 435360a79095a4f3b84cea4df3aa44dd7144400a Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 27 Jul 2016 22:52:42 -0700 Subject: [PATCH] Refactor LOCAL_INIT_RC We supported de-duplicating LOCAL_INIT_RC across multiple architecture variants in a single module definition, but that didn't work if the module was defined with two different BUILD_PREBUILT definitions. That's how we're exporting modules from Soong to Make. Change-Id: Ifc93b15ef78ea3d8e78005d428a3ec57d7e414e8 --- core/base_rules.mk | 25 +++++++++++++------------ core/definitions.mk | 3 +++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 39ba8224f..1daf2294c 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -336,21 +336,22 @@ $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) $(copy-file-to-new-target) $(PRIVATE_POST_INSTALL_CMD) +ifndef LOCAL_IS_HOST_MODULE # Rule to install the module's companion init.rc. -my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) -ifneq ($(my_init_rc),) -my_init_rc_pairs += $(LOCAL_PATH)/$(my_init_rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc)) -endif -ifneq ($(LOCAL_INIT_RC),) -my_init_rc_pairs += $(LOCAL_PATH)/$(LOCAL_INIT_RC):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(LOCAL_INIT_RC)) -# Make sure we don't define the rule twice in multilib module. -LOCAL_INIT_RC := -endif -ifneq ($(my_init_rc_pairs),) -my_init_rc_installed := $(call copy-many-files,$(my_init_rc_pairs)) +my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC) +ifneq ($(strip $(my_init_rc)),) +my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(rc))) +my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc))) + +# Make sure we only set up the copy rules once, even if another arch variant +# shares a common LOCAL_INIT_RC. +my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs)) +my_init_rc_new_installed := $(call copy-many-files,$(my_init_rc_new_pairs)) +ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs) $(my_register_name) : $(my_init_rc_installed) -endif # my_init_rc_pairs +endif # my_init_rc +endif # !LOCAL_IS_HOST_MODULE # Rule to install the module's companion symlinks my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix))) diff --git a/core/definitions.mk b/core/definitions.mk index 53a6fcd5c..8ef67f19d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -95,6 +95,9 @@ TARGET_DISPLAY := target HOST_DISPLAY := host HOST_CROSS_DISPLAY := host cross +# All installed initrc files +ALL_INIT_RC_INSTALLED_PAIRS := + ########################################################### ## Debugging; prints a variable list to stdout ###########################################################