Target "tests" now only builds the modules tagged as "tests"
But not install them.
This prevents "make tests" polluting system.img or userdata.img.
We have new mechanism to build and package up modules into zip file in
build/core/tasks/tools.
Change package-modules.mk to install DATA/ instead of data/ in the
zip file; Better handle of module name conflicting.
Bug: 13585955
Change-Id: I7586a8c7995b984c9ead0ba2fa84dd5d2dd20bd1
diff --git a/core/Makefile b/core/Makefile
index d223122..b6e0057 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -13,8 +13,6 @@
FILE_NAME_TAG := $(BUILD_NUMBER)
endif
-is_tests_build := $(filter tests,$(MAKECMDGOALS))
-
# -----------------------------------------------------------------
# Define rules to copy PRODUCT_COPY_FILES defined by the product.
# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
@@ -797,14 +795,6 @@
$(PDK_FUSION_SYSIMG_FILES) \
$(RECOVERY_RESOURCE_ZIP))
-ifdef is_tests_build
-# We don't want to install tests modules to the system partition
-# when building "tests", because now "tests" may be built in a user, userdebug
-# or eng build variant and we don't want to pollute the system partition.
-# INTERNAL_SYSTEMIMAGE_FILES += $(filter $(TARGET_OUT)/%, \
-# $(tests_MODULES))
-endif
-
FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
# -----------------------------------------------------------------
# installed file list
@@ -981,12 +971,6 @@
INTERNAL_USERDATAIMAGE_FILES := \
$(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
-# If we build "tests" at the same time, make sure $(tests_MODULES) get covered.
-ifdef is_tests_build
-INTERNAL_USERDATAIMAGE_FILES += \
- $(filter $(TARGET_OUT_DATA)/%,$(tests_MODULES))
-endif
-
# Don't build userdata.img if it's extfs but no partition size
skip_userdata.img :=
ifdef INTERNAL_USERIMAGES_EXT_VARIANT
@@ -1362,45 +1346,6 @@
endif # TARGET_DEVICE != generic*
endif # TARGET_PRODUCT != sdk
-ifdef is_tests_build
-# -----------------------------------------------------------------
-# A zip of the tests that are built when running "make tests".
-# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we
-# only grab DATA, and it's called "*-tests-*.zip".
-#
-name := $(TARGET_PRODUCT)
-ifeq ($(TARGET_BUILD_TYPE),debug)
- name := $(name)_debug
-endif
-name := $(name)-tests-$(FILE_NAME_TAG)
-
-intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip)
-BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip
-$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates)
-$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name)
-
-# Depending on the image dependency files, instead of the image files itself,
-# guarantees that the underlying directories are up-to-date,
-# but don't really build the image.
-$(BUILT_TESTS_ZIP_PACKAGE): \
- $(INTERNAL_USERDATAIMAGE_FILES) \
- | $(ACP)
- @echo "Package test files: $@"
- $(hide) rm -rf $@ $(zip_root)
- $(hide) mkdir -p $(dir $@) $(zip_root)
- @# Contents of the data image
- $(hide) $(call package_files-copy-root, \
- $(TARGET_OUT_DATA),$(zip_root)/DATA)
- $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
-
-.PHONY: tests
-tests: $(BUILT_TESTS_ZIP_PACKAGE)
-
-ifneq (,$(filter tests, $(MAKECMDGOALS)))
- $(call dist-for-goals, tests, $(BUILT_TESTS_ZIP_PACKAGE))
-endif
-endif # is_tests_build
-
# -----------------------------------------------------------------
# A zip of the symbols directory. Keep the full paths to make it
# more obvious where these files came from.
diff --git a/core/main.mk b/core/main.mk
index a6c946d..8f60da7 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1004,7 +1004,7 @@
# umbrella targets to assit engineers in verifying builds
.PHONY: java native target host java-host java-target native-host native-target \
java-host-tests java-target-tests native-host-tests native-target-tests \
- java-tests native-tests host-tests target-tests
+ java-tests native-tests host-tests target-tests tests
# some synonyms
.PHONY: host-java target-java host-native target-native \
target-java-tests target-native-tests
@@ -1014,6 +1014,7 @@
target-native : native-target
target-java-tests : java-target-tests
target-native-tests : native-target-tests
+tests : host-tests target-tests
.PHONY: lintall
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
index 25a4e3f..19e756a 100644
--- a/core/tasks/tools/package-modules.mk
+++ b/core/tasks/tools/package-modules.mk
@@ -16,15 +16,24 @@
# Search for modules' built files and installed files;
# Calculate the dest files in the output zip file.
+# If for 1 module name we found multiple installed files,
+# we use suffix matching to find the corresponding built file.
$(foreach m,$(my_modules),\
$(if $(ALL_MODULES.$(m).INSTALLED),,\
- $(warning Unknown installed file for module '$(m)'))\
+ $(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))))\
+ $(eval my_suffix := $(suffix $(i))) \
+ $(if $(my_suffix),\
+ $(eval my_patt := $(TARGET_OUT_ROOT)/%$(my_suffix)),\
+ $(eval my_patt := $(TARGET_OUT_ROOT)/%$(notdir $(i))))\
+ $(eval b := $(filter $(my_patt),$(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))),\
+ $(eval my_copy_dest := $(patsubst data/%,DATA/%,\
+ $(patsubst system/%,SYSTEM/%,\
+ $(patsubst $(PRODUCT_OUT)/%,%,$(i)))))\
+ $(eval my_copy_pairs += $(b):$(my_staging_dir)/$(my_copy_dest)),\
$(warning Unexpected module built file '$(b)' for module '$(m)'))\
))