Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 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 | |
| 12 | my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name)) |
| 13 | my_built_modules := |
| 14 | my_copy_pairs := |
| 15 | my_pickup_files := |
| 16 | |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 17 | # Iterate over modules' built files and installed files; |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 18 | # Calculate the dest files in the output zip file. |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 19 | |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 20 | $(foreach m,$(my_modules),\ |
Ying Wang | c947b4a | 2014-06-16 15:14:45 -0700 | [diff] [blame] | 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),,\ |
Ying Wang | 571fee8 | 2014-05-07 16:39:21 -0700 | [diff] [blame] | 26 | $(warning Unknown installed file for module '$(m)'))\ |
Ying Wang | c947b4a | 2014-06-16 15:14:45 -0700 | [diff] [blame] | 27 | $(eval my_pickup_files += $(_pickup_files))\ |
| 28 | $(foreach i, $(_built_files),\ |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 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))\ |
Ying Wang | 571fee8 | 2014-05-07 16:39:21 -0700 | [diff] [blame] | 34 | $(eval my_copy_dest := $(patsubst data/%,DATA/%,\ |
Ying Wang | 92213a8 | 2014-05-15 20:45:39 -0700 | [diff] [blame] | 35 | $(patsubst system/%,DATA/%,\ |
Ying Wang | 3380d3a | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 36 | $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\ |
| 37 | $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\ |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 38 | )) |
| 39 | |
Ying Wang | a47420a | 2014-09-23 21:50:12 -0700 | [diff] [blame] | 40 | define 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));) |
| 45 | endef |
| 46 | |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 47 | my_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 $@) |
Ying Wang | a47420a | 2014-09-23 21:50:12 -0700 | [diff] [blame] | 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),\ |
Ying Wang | 069f1f8 | 2015-04-30 19:46:00 -0700 | [diff] [blame^] | 61 | cp -rfL $(f) $(dir $@);) |
Ying Wang | 3b81aab | 2014-05-05 16:46:52 -0700 | [diff] [blame] | 62 | $(hide) cd $(dir $@) && zip -rq $(notdir $@) * |