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 29test_suite_subdir := android-$(test_suite_name) 30out_dir := $(HOST_OUT)/$(test_suite_name)/$(test_suite_subdir) 31test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES) 32test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \ 33 $(HOST_OUT_JAVA_LIBRARIES)/tradefed-no-fwk.jar \ 34 $(HOST_OUT_JAVA_LIBRARIES)/tradefed-test-framework.jar \ 35 $(HOST_OUT_JAVA_LIBRARIES)/loganalysis.jar \ 36 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \ 37 $(HOST_OUT_JAVA_LIBRARIES)/compatibility-tradefed.jar \ 38 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \ 39 $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed)-tests.jar \ 40 $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \ 41 $(test_suite_readme) 42 43test_tools += $(test_suite_tools) 44 45# The JDK to package into the test suite zip file. Always package the linux JDK. 46test_suite_jdk_dir := $(ANDROID_JAVA_HOME)/../linux-x86 47test_suite_jdk := $(call intermediates-dir-for,PACKAGING,$(test_suite_name)_jdk,HOST)/jdk.zip 48$(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir) 49$(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir) 50$(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort) 51$(test_suite_jdk): $(SOONG_ZIP) 52 $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) 53 54# Include host shared libraries 55host_shared_libs := $(call copy-many-files, $(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES)) 56 57compatibility_zip_deps := \ 58 $(test_artifacts) \ 59 $(test_tools) \ 60 $(test_suite_prebuilt_tools) \ 61 $(test_suite_dynamic_config) \ 62 $(test_suite_jdk) \ 63 $(MERGE_ZIPS) \ 64 $(SOONG_ZIP) \ 65 $(host_shared_libs) \ 66 67compatibility_zip_resources := $(out_dir)/tools $(out_dir)/testcases $(out_dir)/lib $(out_dir)/lib64 68 69# Test Suite NOTICE files 70test_suite_notice_txt := $(out_dir)/NOTICE.txt 71test_suite_notice_html := $(out_dir)/NOTICE.html 72 73$(eval $(call combine-notice-files, html, \ 74 $(test_suite_notice_txt), \ 75 $(test_suite_notice_html), \ 76 "Notices for files contained in the test suites filesystem image in this directory:", \ 77 $(HOST_OUT_NOTICE_FILES) $(TARGET_OUT_NOTICE_FILES), \ 78 $(compatibility_zip_deps))) 79 80compatibility_zip_deps += $(test_suite_notice_txt) 81compatibility_zip_resources += $(test_suite_notice_txt) 82 83compatibility_tests_list_zip := $(out_dir)-tests_list.zip 84 85compatibility_zip := $(out_dir).zip 86$(compatibility_zip) : .KATI_IMPLICIT_OUTPUTS := $(compatibility_tests_list_zip) 87$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir) 88$(compatibility_zip): PRIVATE_TOOLS := $(test_tools) $(test_suite_prebuilt_tools) 89$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name) 90$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config) 91$(compatibility_zip): PRIVATE_RESOURCES := $(compatibility_zip_resources) 92$(compatibility_zip): PRIVATE_JDK := $(test_suite_jdk) 93$(compatibility_zip): PRIVATE_tests_list := $(out_dir)-tests_list 94$(compatibility_zip): PRIVATE_tests_list_zip := $(compatibility_tests_list_zip) 95$(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP) 96# Make dir structure 97 mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases 98 rm -f $@ $@.tmp $@.jdk 99 echo $(BUILD_NUMBER_FROM_FILE) > $(PRIVATE_OUT_DIR)/tools/version.txt 100# Copy tools 101 cp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools 102 $(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) cp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic) 103 find $(PRIVATE_RESOURCES) | sort >$@.list 104 $(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list 105 $(MERGE_ZIPS) $@ $@.tmp $(PRIVATE_JDK) 106 rm -f $@.tmp 107# Build a list of tests 108 rm -f $(PRIVATE_tests_list) 109 $(hide) grep -e .*\\.config$$ $@.list | sed s%$(PRIVATE_OUT_DIR)/testcases/%%g > $(PRIVATE_tests_list) 110 $(SOONG_ZIP) -d -o $(PRIVATE_tests_list_zip) -j -f $(PRIVATE_tests_list) 111 rm -f $(PRIVATE_tests_list) 112 113# Reset all input variables 114test_suite_name := 115test_suite_tradefed := 116test_suite_dynamic_config := 117test_suite_readme := 118test_suite_prebuilt_tools := 119test_suite_tools := 120test_suite_jdk := 121test_suite_jdk_dir := 122host_shared_libs := 123