1# Package up modules to a zip file. 2# It preserves the install path of the modules' installed files. 3# 4# Input variables: 5# my_modules: a list of module names 6# my_package_name: the name of the output zip file. 7# Output variables: 8# my_package_zip: the path to the output zip file. 9# 10# 11 12my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name)) 13my_built_modules := 14my_copy_pairs := 15my_pickup_files := 16 17# Iterate over modules' built files and installed files; 18# Calculate the dest files in the output zip file. 19 20$(foreach m,$(my_modules),\ 21 $(eval _pickup_files := $(strip $(ALL_MODULES.$(m).PICKUP_FILES)\ 22 $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\ 23 $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\ 24 $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\ 25 $(if $(_pickup_files)$(_built_files),,\ 26 $(warning Unknown installed file for module '$(m)'))\ 27 $(eval my_pickup_files += $(_pickup_files))\ 28 $(foreach i, $(_built_files),\ 29 $(eval bui_ins := $(subst :,$(space),$(i)))\ 30 $(eval ins := $(word 2,$(bui_ins)))\ 31 $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\ 32 $(eval bui := $(word 1,$(bui_ins)))\ 33 $(eval my_built_modules += $(bui))\ 34 $(eval my_copy_dest := $(patsubst data/%,DATA/%,\ 35 $(patsubst system/%,DATA/%,\ 36 $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\ 37 $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\ 38 )) 39 40define copy-tests-in-batch 41$(hide) $(foreach p, $(1),\ 42 $(eval pair := $(subst :,$(space),$(p)))\ 43 mkdir -p $(dir $(word 2,$(pair)));\ 44 cp -Rf $(word 1,$(pair)) $(word 2,$(pair));) 45endef 46 47my_package_zip := $(my_staging_dir)/$(my_package_name).zip 48$(my_package_zip): PRIVATE_COPY_PAIRS := $(my_copy_pairs) 49$(my_package_zip): PRIVATE_PICKUP_FILES := $(my_pickup_files) 50$(my_package_zip) : $(my_built_modules) 51 @echo "Package $@" 52 @rm -rf $(dir $@) && mkdir -p $(dir $@) 53 $(call copy-tests-in-batch,$(wordlist 1,200,$(PRIVATE_COPY_PAIRS))) 54 $(call copy-tests-in-batch,$(wordlist 201,400,$(PRIVATE_COPY_PAIRS))) 55 $(call copy-tests-in-batch,$(wordlist 401,600,$(PRIVATE_COPY_PAIRS))) 56 $(call copy-tests-in-batch,$(wordlist 601,800,$(PRIVATE_COPY_PAIRS))) 57 $(call copy-tests-in-batch,$(wordlist 801,1000,$(PRIVATE_COPY_PAIRS))) 58 $(call copy-tests-in-batch,$(wordlist 1001,1200,$(PRIVATE_COPY_PAIRS))) 59 $(call copy-tests-in-batch,$(wordlist 1201,9999,$(PRIVATE_COPY_PAIRS))) 60 $(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\ 61 cp -RfL $(f) $(dir $@);) 62 $(hide) cd $(dir $@) && zip -rq $(notdir $@) * 63