• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-test-framework.jar \
34  $(HOST_OUT_JAVA_LIBRARIES)/loganalysis.jar \
35  $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \
36  $(HOST_OUT_JAVA_LIBRARIES)/compatibility-tradefed.jar \
37  $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \
38  $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed)-tests.jar \
39  $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \
40  $(test_suite_readme)
41
42$(foreach f,$(test_suite_readme),$(if $(strip $(ALL_TARGETS.$(f).META_LIC)),,$(eval ALL_TARGETS.$(f).META_LIC := $(module_license_metadata))))
43
44test_tools += $(test_suite_tools)
45
46# The JDK to package into the test suite zip file.  Always package the linux JDK.
47test_suite_jdk_dir := $(ANDROID_JAVA_HOME)/../linux-x86
48test_suite_jdk := $(call intermediates-dir-for,PACKAGING,$(test_suite_name)_jdk,HOST)/jdk.zip
49$(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir)
50$(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir)
51$(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort)
52$(test_suite_jdk): $(SOONG_ZIP)
53	$(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) -sha256
54
55$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,permissive,\
56  $(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir)))))
57
58# Copy license metadata
59$(call declare-copy-target-license-metadata,$(out_dir)/$(notdir $(test_suite_jdk)),$(test_suite_jdk))
60$(foreach t,$(test_tools) $(test_suite_prebuilt_tools),\
61  $(eval _dst := $(out_dir)/tools/$(notdir $(t)))\
62  $(if $(strip $(ALL_TARGETS.$(t).META_LIC)),\
63    $(call declare-copy-target-license-metadata,$(_dst),$(t)),\
64    $(warning $(t) has no license metadata)\
65  )\
66)
67test_copied_tools := $(foreach t,$(test_tools) $(test_suite_prebuilt_tools), $(out_dir)/tools/$(notdir $(t))) $(out_dir)/$(notdir $(test_suite_jdk))
68
69
70# Include host shared libraries
71host_shared_libs := $(call copy-many-files, $(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES))
72
73$(if $(strip $(host_shared_libs)),\
74  $(foreach p,$(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES),\
75    $(eval _src := $(call word-colon,1,$(p)))\
76    $(eval _dst := $(call word-colon,2,$(p)))\
77    $(if $(strip $(ALL_TARGETS.$(_src).META_LIC)),\
78      $(call declare-copy-target-license-metadata,$(_dst),$(_src)),\
79      $(warning $(_src) has no license metadata for $(_dst))\
80    )\
81  )\
82)
83
84compatibility_zip_deps := \
85  $(test_artifacts) \
86  $(test_tools) \
87  $(test_suite_prebuilt_tools) \
88  $(test_suite_dynamic_config) \
89  $(test_suite_jdk) \
90  $(MERGE_ZIPS) \
91  $(SOONG_ZIP) \
92  $(host_shared_libs) \
93  $(test_suite_extra_deps) \
94
95compatibility_zip_resources := $(out_dir)/tools $(out_dir)/testcases $(out_dir)/lib $(out_dir)/lib64
96
97# Test Suite NOTICE files
98test_suite_notice_txt := $(out_dir)/NOTICE.txt
99test_suite_notice_html := $(out_dir)/NOTICE.html
100
101compatibility_zip_deps += $(test_suite_notice_txt)
102compatibility_zip_resources += $(test_suite_notice_txt)
103
104compatibility_tests_list_zip := $(out_dir)-tests_list.zip
105
106compatibility_zip := $(out_dir).zip
107$(compatibility_zip) : .KATI_IMPLICIT_OUTPUTS := $(compatibility_tests_list_zip)
108$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir)
109$(compatibility_zip): PRIVATE_TOOLS := $(test_tools) $(test_suite_prebuilt_tools)
110$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name)
111$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config)
112$(compatibility_zip): PRIVATE_RESOURCES := $(compatibility_zip_resources)
113$(compatibility_zip): PRIVATE_JDK := $(test_suite_jdk)
114$(compatibility_zip): PRIVATE_tests_list := $(out_dir)-tests_list
115$(compatibility_zip): PRIVATE_tests_list_zip := $(compatibility_tests_list_zip)
116$(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP)
117# Make dir structure
118	mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases
119	rm -f $@ $@.tmp $@.jdk
120	echo $(BUILD_NUMBER_FROM_FILE) > $(PRIVATE_OUT_DIR)/tools/version.txt
121# Copy tools
122	cp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools
123	$(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) cp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic)
124	find $(PRIVATE_RESOURCES) | sort >$@.list
125	$(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list -sha256
126	$(MERGE_ZIPS) $@ $@.tmp $(PRIVATE_JDK)
127	rm -f $@.tmp
128# Build a list of tests
129	rm -f $(PRIVATE_tests_list)
130	$(hide) grep -e .*\\.config$$ $@.list | sed s%$(PRIVATE_OUT_DIR)/testcases/%%g > $(PRIVATE_tests_list)
131	$(SOONG_ZIP) -d -o $(PRIVATE_tests_list_zip) -j -f $(PRIVATE_tests_list)
132	rm -f $(PRIVATE_tests_list)
133
134$(call declare-0p-target,$(compatibility_tests_list_zip),)
135
136$(call declare-1p-container,$(compatibility_zip),)
137$(call declare-container-license-deps,$(compatibility_zip),$(compatibility_zip_deps) $(test_copied_tools), $(out_dir)/:/)
138
139$(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)))
140$(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)))
141
142$(call declare-0p-target,$(test_suite_notice_html))
143$(call declare-0p-target,$(test_suite_notice_txt))
144
145$(call declare-1p-copy-files,$(test_suite_dynamic_config),)
146$(call declare-1p-copy-files,$(test_suite_prebuilt_tools),)
147
148# Reset all input variables
149test_suite_name :=
150test_suite_tradefed :=
151test_suite_dynamic_config :=
152test_suite_readme :=
153test_suite_prebuilt_tools :=
154test_suite_tools :=
155test_suite_jdk :=
156test_suite_jdk_dir :=
157host_shared_libs :=
158test_suite_extra_deps :=
159