2014-05-06 01:46:52 +02:00
|
|
|
# Package up modules to a zip file.
|
|
|
|
# It preserves the install path of the modules' installed files.
|
|
|
|
#
|
|
|
|
# Input variables:
|
|
|
|
# my_modules: a list of module names
|
|
|
|
# my_package_name: the name of the output zip file.
|
2017-06-21 00:57:32 +02:00
|
|
|
# my_copy_pairs: a list of extra files to install (in src:dest format)
|
2014-05-06 01:46:52 +02:00
|
|
|
# Output variables:
|
|
|
|
# my_package_zip: the path to the output zip file.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2017-02-24 22:14:23 +01:00
|
|
|
my_makefile := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
|
2014-05-06 01:46:52 +02:00
|
|
|
my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name))
|
2017-06-21 00:57:32 +02:00
|
|
|
my_built_modules := $(foreach p,$(my_copy_pairs),$(call word-colon,1,$(p)))
|
|
|
|
my_copy_pairs := $(foreach p,$(my_copy_pairs),$(call word-colon,1,$(p)):$(my_staging_dir)/$(call word-colon,2,$(p)))
|
2014-05-06 01:46:52 +02:00
|
|
|
my_pickup_files :=
|
|
|
|
|
2017-01-05 17:54:46 +01:00
|
|
|
# Iterate over the modules and include their direct dependencies stated in the
|
|
|
|
# LOCAL_REQUIRED_MODULES.
|
|
|
|
my_modules_and_deps := $(my_modules)
|
|
|
|
$(foreach m,$(my_modules),\
|
|
|
|
$(eval _explicitly_required := \
|
|
|
|
$(strip $(ALL_MODULES.$(m).EXPLICITLY_REQUIRED)\
|
|
|
|
$(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).EXPLICITLY_REQUIRED)))\
|
|
|
|
$(eval my_modules_and_deps += $(_explicitly_required))\
|
|
|
|
)
|
|
|
|
|
2017-04-08 09:31:31 +02:00
|
|
|
# Ignore unknown installed files on partial builds
|
|
|
|
my_missing_files :=
|
|
|
|
ifneq ($(ALLOW_MISSING_DEPENDENCIES),true)
|
|
|
|
my_missing_files = $(shell $(call echo-warning,$(my_makefile),$(my_package_name): Unknown installed file for module '$(1)'))
|
|
|
|
endif
|
|
|
|
|
2014-05-19 22:03:36 +02:00
|
|
|
# Iterate over modules' built files and installed files;
|
2014-05-06 01:46:52 +02:00
|
|
|
# Calculate the dest files in the output zip file.
|
2014-05-19 22:03:36 +02:00
|
|
|
|
2017-01-05 17:54:46 +01:00
|
|
|
$(foreach m,$(my_modules_and_deps),\
|
2014-06-17 00:14:45 +02:00
|
|
|
$(eval _pickup_files := $(strip $(ALL_MODULES.$(m).PICKUP_FILES)\
|
|
|
|
$(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\
|
|
|
|
$(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
|
|
|
|
$(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
|
|
|
|
$(if $(_pickup_files)$(_built_files),,\
|
2017-04-08 09:31:31 +02:00
|
|
|
$(call my_missing_files,$(m)))\
|
2014-06-17 00:14:45 +02:00
|
|
|
$(eval my_pickup_files += $(_pickup_files))\
|
|
|
|
$(foreach i, $(_built_files),\
|
2014-05-19 22:03:36 +02:00
|
|
|
$(eval bui_ins := $(subst :,$(space),$(i)))\
|
|
|
|
$(eval ins := $(word 2,$(bui_ins)))\
|
|
|
|
$(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
|
|
|
|
$(eval bui := $(word 1,$(bui_ins)))\
|
|
|
|
$(eval my_built_modules += $(bui))\
|
2014-05-08 01:39:21 +02:00
|
|
|
$(eval my_copy_dest := $(patsubst data/%,DATA/%,\
|
2019-03-11 17:36:53 +01:00
|
|
|
$(patsubst system/%,DATA/%,\
|
|
|
|
$(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
|
2014-05-19 22:03:36 +02:00
|
|
|
$(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
|
2014-05-06 01:46:52 +02:00
|
|
|
))
|
|
|
|
|
|
|
|
my_package_zip := $(my_staging_dir)/$(my_package_name).zip
|
|
|
|
$(my_package_zip): PRIVATE_COPY_PAIRS := $(my_copy_pairs)
|
|
|
|
$(my_package_zip): PRIVATE_PICKUP_FILES := $(my_pickup_files)
|
2015-11-04 19:06:25 +01:00
|
|
|
$(my_package_zip) : $(my_built_modules)
|
2014-05-06 01:46:52 +02:00
|
|
|
@echo "Package $@"
|
|
|
|
@rm -rf $(dir $@) && mkdir -p $(dir $@)
|
2017-03-15 00:58:34 +01:00
|
|
|
$(foreach p, $(PRIVATE_COPY_PAIRS),\
|
|
|
|
$(eval pair := $(subst :,$(space),$(p)))\
|
|
|
|
mkdir -p $(dir $(word 2,$(pair))) && \
|
|
|
|
cp -Rf $(word 1,$(pair)) $(word 2,$(pair)) && ) true
|
2014-09-24 06:50:12 +02:00
|
|
|
$(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\
|
2017-03-15 00:58:34 +01:00
|
|
|
cp -RfL $(f) $(dir $@) && ) true
|
2015-10-30 00:33:05 +01:00
|
|
|
$(hide) cd $(dir $@) && zip -rqX $(notdir $@) *
|
2017-06-21 00:57:32 +02:00
|
|
|
|
|
|
|
my_makefile :=
|
|
|
|
my_staging_dir :=
|
|
|
|
my_built_modules :=
|
|
|
|
my_copy_dest :=
|
|
|
|
my_copy_pairs :=
|
|
|
|
my_pickup_files :=
|
|
|
|
my_missing_files :=
|
|
|
|
my_modules_and_deps :=
|