1# Copyright (C) 2015 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# Package up a compatibility test suite in a zip file. 16# 17# Input variables: 18# test_suite_name: the name of this test suite eg. cts 19# test_suite_tradefed: the name of this test suite's tradefed wrapper 20# test_suite_dynamic_config: the path to this test suite's dynamic configuration file 21# test_suite_readme: the path to a README file for this test suite 22# test_suite_prebuilt_tools: the set of prebuilt tools to be included directly 23# in the 'tools' subdirectory of the test suite. 24# test_suite_tools: the set of tools for this test suite 25# 26# Output variables: 27# compatibility_zip: the path to the output zip file. 28 29special_mts_test_suites := 30special_mts_test_suites += mcts 31special_mts_test_suites += $(mts_modules) 32ifneq ($(filter $(special_mts_test_suites),$(patsubst mcts-%,%,$(test_suite_name))),) 33 test_suite_subdir := android-mts 34else ifneq ($(filter $(special_mts_test_suites),$(patsubst mts-%,%,$(test_suite_name))),) 35 test_suite_subdir := android-mts 36else 37 test_suite_subdir := android-$(test_suite_name) 38endif 39 40out_dir := $(HOST_OUT)/$(test_suite_name)/$(test_suite_subdir) 41test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES) 42test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \ 43 $(HOST_OUT_JAVA_LIBRARIES)/loganalysis.jar \ 44 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \ 45 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-tradefed.jar \ 46 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \ 47 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed)-tests.jar \ 48 $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \ 49 $(HOST_OUT_EXECUTABLES)/test-utils-script \ 50 $(test_suite_readme) 51 52$(foreach f,$(test_suite_readme),$(if $(strip $(ALL_TARGETS.$(f).META_LIC)),,$(eval ALL_TARGETS.$(f).META_LIC := $(module_license_metadata)))) 53 54test_tools += $(test_suite_tools) 55 56# The JDK to package into the test suite zip file. Always package the linux JDK. 57test_suite_jdk_dir := $(ANDROID_JAVA_HOME)/../linux-x86 58ifndef test_suite_jdk_files 59 # This file gets included many times, so make sure we only run the $(shell) once. 60 # Otherwise it will slow down every build due to all copies of it being rerun when kati 61 # checks the stamp file. 62 test_suite_jdk_files :=$= $(shell find $(test_suite_jdk_dir) -type f | sort) 63endif 64test_suite_jdk := $(call intermediates-dir-for,PACKAGING,$(test_suite_name)_jdk,HOST)/jdk.zip 65$(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir) 66$(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir) 67$(test_suite_jdk): $(test_suite_jdk_files) 68$(test_suite_jdk): $(SOONG_ZIP) 69 $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) -sha256 70 71$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,permissive,\ 72 $(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir))))) 73 74# Copy license metadata 75$(call declare-copy-target-license-metadata,$(out_dir)/$(notdir $(test_suite_jdk)),$(test_suite_jdk)) 76$(foreach t,$(test_tools) $(test_suite_prebuilt_tools),\ 77 $(eval _dst := $(out_dir)/tools/$(notdir $(t)))\ 78 $(if $(strip $(ALL_TARGETS.$(t).META_LIC)),\ 79 $(call declare-copy-target-license-metadata,$(_dst),$(t)),\ 80 $(warning $(t) has no license metadata)\ 81 )\ 82) 83test_copied_tools := $(foreach t,$(test_tools) $(test_suite_prebuilt_tools), $(out_dir)/tools/$(notdir $(t))) $(out_dir)/$(notdir $(test_suite_jdk)) 84 85 86# Include host shared libraries 87host_shared_libs := $(call copy-many-files, $(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES)) 88 89$(if $(strip $(host_shared_libs)),\ 90 $(foreach p,$(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES),\ 91 $(eval _src := $(call word-colon,1,$(p)))\ 92 $(eval _dst := $(call word-colon,2,$(p)))\ 93 $(if $(strip $(ALL_TARGETS.$(_src).META_LIC)),\ 94 $(call declare-copy-target-license-metadata,$(_dst),$(_src)),\ 95 $(warning $(_src) has no license metadata for $(_dst))\ 96 )\ 97 )\ 98) 99 100compatibility_zip_deps := \ 101 $(test_artifacts) \ 102 $(test_tools) \ 103 $(test_suite_prebuilt_tools) \ 104 $(test_suite_dynamic_config) \ 105 $(test_suite_jdk) \ 106 $(MERGE_ZIPS) \ 107 $(SOONG_ZIP) \ 108 $(host_shared_libs) \ 109 $(test_suite_extra_deps) \ 110 111compatibility_zip_resources := $(out_dir)/tools $(out_dir)/testcases $(out_dir)/lib $(out_dir)/lib64 112 113# Test Suite NOTICE files 114test_suite_notice_txt := $(out_dir)/NOTICE.txt 115test_suite_notice_html := $(out_dir)/NOTICE.html 116 117compatibility_zip_deps += $(test_suite_notice_txt) 118compatibility_zip_resources += $(test_suite_notice_txt) 119 120compatibility_tests_list_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name)-tests_list.zip 121 122compatibility_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name).zip 123$(compatibility_zip) : .KATI_IMPLICIT_OUTPUTS := $(compatibility_tests_list_zip) 124$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir) 125$(compatibility_zip): PRIVATE_TOOLS := $(test_tools) $(test_suite_prebuilt_tools) 126$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name) 127$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config) 128$(compatibility_zip): PRIVATE_RESOURCES := $(compatibility_zip_resources) 129$(compatibility_zip): PRIVATE_JDK := $(test_suite_jdk) 130$(compatibility_zip): PRIVATE_tests_list := $(out_dir)-tests_list 131$(compatibility_zip): PRIVATE_tests_list_zip := $(compatibility_tests_list_zip) 132ifeq ($(strip $(HAS_BUILD_NUMBER)),true) 133$(compatibility_zip): $(BUILD_NUMBER_FILE) 134endif 135$(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP) 136# Make dir structure 137 mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases 138 rm -f $@ $@.tmp $@.jdk 139 echo $(BUILD_NUMBER_FROM_FILE) > $(PRIVATE_OUT_DIR)/tools/version.txt 140# Copy tools 141 cp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools 142 $(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) cp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic) 143 find $(PRIVATE_RESOURCES) | sort >$@.list 144 $(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list -sha256 145 $(MERGE_ZIPS) $@ $@.tmp $(PRIVATE_JDK) 146 rm -f $@.tmp 147# Build a list of tests 148 rm -f $(PRIVATE_tests_list) 149 $(hide) grep -e .*\\.config$$ $@.list | sed s%$(PRIVATE_OUT_DIR)/testcases/%%g > $(PRIVATE_tests_list) 150 $(SOONG_ZIP) -d -o $(PRIVATE_tests_list_zip) -j -f $(PRIVATE_tests_list) 151 rm -f $(PRIVATE_tests_list) 152 153$(call declare-0p-target,$(compatibility_tests_list_zip),) 154 155$(call declare-1p-container,$(compatibility_zip),) 156$(call declare-container-license-deps,$(compatibility_zip),$(compatibility_zip_deps) $(test_copied_tools), $(out_dir)/:/) 157 158$(eval $(call html-notice-rule,$(test_suite_notice_html),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip))) 159$(eval $(call text-notice-rule,$(test_suite_notice_txt),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip))) 160 161$(call declare-0p-target,$(test_suite_notice_html)) 162$(call declare-0p-target,$(test_suite_notice_txt)) 163 164$(call declare-1p-copy-files,$(test_suite_dynamic_config),) 165$(call declare-1p-copy-files,$(test_suite_prebuilt_tools),) 166 167# Reset all input variables 168test_suite_name := 169test_suite_tradefed := 170test_suite_dynamic_config := 171test_suite_readme := 172test_suite_prebuilt_tools := 173test_suite_tools := 174test_suite_jdk := 175test_suite_jdk_dir := 176host_shared_libs := 177test_suite_extra_deps := 178