From c16dbcd8c8518fe19a87c5ec71866e0336a2cf5d Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 21 Dec 2011 11:30:59 -0800 Subject: [PATCH] Fix multiple modules with the same name in FACTORY_RAMDISK_MODULES With this change, if a module name is associated with multiple modules, you can specify multiple install paths in PRODUCT_FACTORY_RAMDISK_MODULES. For example, if we have 2 modules named "foo", one is Java library and the other is executable, then you can write: PRODUCT_FACTORY_RAMDISK_MODULES += \ foo:system/bin/foo:system/framework/foo.jar Or: PRODUCT_FACTORY_RAMDISK_MODULES += \ foo:system/bin/foo \ foo:system/framework/foo.jar The build system will choose the correct built files based on the install paths. Change-Id: I6efc72e8abd1e81710ada16731b6792989aefd85 --- core/tasks/factory_ramdisk.mk | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/core/tasks/factory_ramdisk.mk b/core/tasks/factory_ramdisk.mk index 7b78657f6..a8cc7ebb6 100644 --- a/core/tasks/factory_ramdisk.mk +++ b/core/tasks/factory_ramdisk.mk @@ -14,26 +14,42 @@ # limitations under the License. # -# PRODUCT_FACTORY_RAMDISK_MODULES consists of ":" pairs. +# PRODUCT_FACTORY_RAMDISK_MODULES consists of ":[:...]" tuples. # is relative to TARGET_FACTORY_RAMDISK_OUT. +# We can have multiple s because multiple modules may have the same name. # For example: # PRODUCT_FACTORY_RAMDISK_MODULES := \ -# toolbox:bin/toolbox adbd:sbin/adbd adb:bin/adb +# toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES)) ifneq (,$(factory_ramdisk_modules)) + +# A module name may end up in multiple modules (so multiple built files) +# with the same name. +# This function selects the module built file based on the install path. +# $(1): the dest install path +# $(2): the module built files +define install-one-factory-ramdisk-module +$(eval _iofrm_suffix := $(suffix $(1))) \ +$(if $(_iofrm_suffix), \ + $(eval _iofrm_pattern := %$(_iofrm_suffix)), \ + $(eval _iofrm_pattern := %$(notdir $(1)))) \ +$(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \ +$(if $(filter 1,$(words $(_iofrm_src))), \ + $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \ + $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \ + $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \ + $(error Error: Can not find match in "$(2)" for "$(1)") \ + ) +endef + INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES := $(foreach m, $(factory_ramdisk_modules), \ - $(eval _fr_m_name := $(call word-colon,1,$(m))) \ - $(eval _fr_dest := $(call word-colon,2,$(m))) \ - $(eval _fr_m_built := $(filter-out %.a, $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT)))) \ - $(if $(_fr_m_built), \ - $(if $(filter-out 1, $(words $(_fr_m_built))), \ - $(error Error: module "$(m)" has multiple built files: "$(_fr_m_built)")) \ - $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(_fr_dest)) \ - $(eval $(call copy-one-file,$(_fr_m_built),$(_fulldest))) \ - $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \ - $(error Error: module "$(m)" in PRODUCT_FACTORY_RAMDISK_MODULES is not a target module!) \ - )) + $(eval _fr_m_tuple := $(subst :, ,$(m))) \ + $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \ + $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \ + $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \ + $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \ + ) endif # Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc. -- 2.11.0