platform_build/core/tasks/tools/package-modules.mk
Nelson Li 6fe7f194b9 Revert "Build System: Solve dependency problem for test"
This reverts commit 224e103308.

Reason for revert: Build Breakage in git_pi-dev-plus-aosp/docs @5366136
make -j110 docs showcommands dist DIST_DIR=/buildbot/dist_dirs/git_pi-dev-plus-aosp-linux-docs/5366136 checkbuild
FAILED:
 Dependencies in out found with no rule to create them:
 out/target/product/generic/data/app/CtsVerifierTester/CtsVerifierTester.apk
 out/target/product/generic/data/app/TradeFedTestApp/TradeFedTestApp.apk
 out/target/product/generic/data/app/TradeFedUiTestApp/TradeFedUiTestApp.apk
 15:53:46 stopping
and
make -j50 showcommands dist TARGET_PRODUCT=cf_x86_phone DIST_DIR=/buildbot/dist_dirs/git_master-linux-ndk_translation_all/5366149 ndk_translation_all
FAILED: ninja: 'out/target/product/vsoc_x86/data/nativetest/arm/arm_insn_tests_arm_static/arm_insn_tests_arm_static', needed by 'out/target/product/vsoc_x86/obj/PACKAGING/ndk_translation_tests_intermediates/arm_insn_tests_arm_static_result.xml', missing and no known rule to make it
15:55:38 ninja failed with: exit status 1
make: *** [run_soong_ui] Error 1
Return Code: 2

Change-Id: Idf95ef2e06526a0a31690420c923207db627605f
2019-03-11 16:48:29 +00:00

79 lines
3.1 KiB
Makefile

# 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.
# my_copy_pairs: a list of extra files to install (in src:dest format)
# Output variables:
# my_package_zip: the path to the output zip file.
#
#
my_makefile := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name))
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)))
my_pickup_files :=
# 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))\
)
# 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
# Iterate over modules' built files and installed files;
# Calculate the dest files in the output zip file.
$(foreach m,$(my_modules_and_deps),\
$(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),,\
$(call my_missing_files,$(m)))\
$(eval my_pickup_files += $(_pickup_files))\
$(foreach i, $(_built_files),\
$(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))\
$(eval my_copy_dest := $(patsubst data/%,DATA/%,\
$(patsubst system/%,DATA/%,\
$(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
$(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
))
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 $@)
$(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
$(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\
cp -RfL $(f) $(dir $@) && ) true
$(hide) cd $(dir $@) && zip -rqX $(notdir $@) *
my_makefile :=
my_staging_dir :=
my_built_modules :=
my_copy_dest :=
my_copy_pairs :=
my_pickup_files :=
my_missing_files :=
my_modules_and_deps :=