OSDN Git Service

Target "tests" now only builds the modules tagged as "tests"
authorYing Wang <wangying@google.com>
Wed, 7 May 2014 23:39:21 +0000 (16:39 -0700)
committerYing Wang <wangying@google.com>
Fri, 9 May 2014 00:01:25 +0000 (17:01 -0700)
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

core/Makefile
core/main.mk
core/tasks/tools/package-modules.mk

index d223122..b6e0057 100644 (file)
@@ -13,8 +13,6 @@ else
   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 @@ INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
     $(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 @@ boottarball-nodeps btnod: $(FS_GET_STATS) \
 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_NO_KERNEL != true
 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.
index a6c946d..8f60da7 100644 (file)
@@ -1004,7 +1004,7 @@ $(call dist-for-goals,sdk win_sdk, \
 # 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 @@ host-native : native-host
 target-native : native-target
 target-java-tests : java-target-tests
 target-native-tests : native-target-tests
+tests : host-tests target-tests
 
 
 .PHONY: lintall
index 25a4e3f..19e756a 100644 (file)
@@ -16,15 +16,24 @@ my_pickup_files :=
 
 # 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)'))\
   ))