diff options
author | Ying Wang <wangying@google.com> | 2014-05-05 16:46:52 -0700 |
---|---|---|
committer | Ying Wang <wangying@google.com> | 2014-05-08 17:01:06 -0700 |
commit | 989ac38d93f706c30cb4ddb8f982df4d26ff71cf (patch) | |
tree | c529c536d3999b113a59054cba15c12e0c8b6fcc | |
parent | 41d8760d683f21d2868fbfb6872a3cf65b9edbcb (diff) | |
download | build-989ac38d93f706c30cb4ddb8f982df4d26ff71cf.tar.gz |
Add tool to package up built modules.
With this change, you can package up modules while avoiding installing
them to the system.img or userdata.img.
- build/core/tasks/tools/package-modules.mk
You can use this template to package up modules into a zip file and
preserve the installed file paths.
- LOCAL_PICKUP_FILES, you can use this variable to package up extra
files/directories.
Bug: 13585955
Change-Id: I103042b24ccf17cf5dc90c016d97ed1dd293e50b
-rw-r--r-- | core/base_rules.mk | 6 | ||||
-rw-r--r-- | core/clear_vars.mk | 1 | ||||
-rw-r--r-- | core/tasks/tools/package-modules.mk | 43 |
3 files changed, 50 insertions, 0 deletions
diff --git a/core/base_rules.mk b/core/base_rules.mk index 673fdd87b2..c68fba7076 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -598,6 +598,12 @@ ALL_MODULES.$(my_register_name).BUILT := \ $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE) ALL_MODULES.$(my_register_name).INSTALLED := \ $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE)) +ifdef LOCAL_PICKUP_FILES +# Files or directories ready to pick up by the build system +# when $(LOCAL_BUILT_MODULE) is done. +ALL_MODULES.$(my_register_name).PICKUP_FILES := \ + $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES) +endif ALL_MODULES.$(my_register_name).REQUIRED := \ $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(LOCAL_REQUIRED_MODULES) \ $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index ea47003662..5342fd2d24 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -13,6 +13,7 @@ LOCAL_BUILT_MODULE_STEM:= OVERRIDE_BUILT_MODULE_PATH:= LOCAL_INSTALLED_MODULE:= LOCAL_INSTALLED_MODULE_STEM:= +LOCAL_PICKUP_FILES:= LOCAL_UNINSTALLABLE_MODULE:= LOCAL_INTERMEDIATE_TARGETS:= LOCAL_UNSTRIPPED_PATH:= diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk new file mode 100644 index 0000000000..25a4e3fcbf --- /dev/null +++ b/core/tasks/tools/package-modules.mk @@ -0,0 +1,43 @@ +# 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. +# Output variables: +# my_package_zip: the path to the output zip file. +# +# + +my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name)) +my_built_modules := +my_copy_pairs := +my_pickup_files := + +# Search for modules' built files and installed files; +# Calculate the dest files in the output zip file. +$(foreach m,$(my_modules),\ + $(if $(ALL_MODULES.$(m).INSTALLED),,\ + $(warning Unknown installed file for module '$(m)'))\ + $(eval my_pickup_files += $(ALL_MODULES.$(m).PICKUP_FILES))\ + $(foreach i,$(filter $(TARGET_OUT_ROOT)/%,$(ALL_MODULES.$(m).INSTALLED)),\ + $(eval b := $(filter %$(suffix $(i)),$(filter $(TARGET_OUT_ROOT)/%,$(ALL_MODULES.$(m).BUILT))))\ + $(if $(filter 1,$(words $(b))),\ + $(eval my_built_modules += $(b))\ + $(eval my_copy_pairs += $(b):$(patsubst $(PRODUCT_OUT)/%,$(my_staging_dir)/%,$(i))),\ + $(warning Unexpected module built file '$(b)' for module '$(m)'))\ + )) + +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) +$(my_package_zip) : $(my_built_modules) + @echo "Package $@" + @rm -rf $(dir $@) && mkdir -p $(dir $@) + $(hide) $(foreach p, $(PRIVATE_COPY_PAIRS), \ + $(eval pair := $(subst :,$(space),$(p)))\ + mkdir -p $(dir $(word 2,$(pair))); \ + cp -rf $(word 1,$(pair)) $(word 2,$(pair));) + $(hide) $(foreach f, $(PRIVATE_PICKUP_FILES), \ + cp -rf $(f) $(dir $@);) + $(hide) cd $(dir $@) && zip -rq $(notdir $@) * |