1# Copyright (C) 2024 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
16.PHONY: performance-tests
17
18performance_tests_zip := $(PRODUCT_OUT)/performance-tests.zip
19# Create an artifact to include a list of test config files in performance-tests.
20performance_tests_list_zip := $(PRODUCT_OUT)/performance-tests_list.zip
21# Create an artifact to include all test config files in performance-tests.
22performance_tests_configs_zip := $(PRODUCT_OUT)/performance-tests_configs.zip
23
24$(performance_tests_zip) : .KATI_IMPLICIT_OUTPUTS := $(performance_tests_list_zip) $(performance_tests_configs_zip)
25$(performance_tests_zip) : PRIVATE_performance_tests_list_zip := $(performance_tests_list_zip)
26$(performance_tests_zip) : PRIVATE_performance_tests_configs_zip := $(performance_tests_configs_zip)
27$(performance_tests_zip) : PRIVATE_performance_tests_list := $(PRODUCT_OUT)/performance-tests_list
28$(performance_tests_zip) : $(COMPATIBILITY.performance-tests.FILES) $(SOONG_ZIP)
29	echo $(sort $(COMPATIBILITY.performance-tests.FILES)) | tr " " "\n" > $@.list
30	grep $(HOST_OUT_TESTCASES) $@.list > $@-host.list || true
31	grep -e .*\\.config$$ $@-host.list > $@-host-test-configs.list || true
32	grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true
33	grep -e .*\\.config$$ $@-target.list > $@-target-test-configs.list || true
34	$(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list -P target -C $(PRODUCT_OUT) -l $@-target.list -sha256
35	$(hide) $(SOONG_ZIP) -d -o $(PRIVATE_performance_tests_configs_zip) \
36	  -P host -C $(HOST_OUT) -l $@-host-test-configs.list \
37	  -P target -C $(PRODUCT_OUT) -l $@-target-test-configs.list
38	rm -f $(PRIVATE_performance_tests_list)
39	$(hide) grep -e .*\\.config$$ $@-host.list | sed s%$(HOST_OUT)%host%g > $(PRIVATE_performance_tests_list)
40	$(hide) grep -e .*\\.config$$ $@-target.list | sed s%$(PRODUCT_OUT)%target%g >> $(PRIVATE_performance_tests_list)
41	$(hide) $(SOONG_ZIP) -d -o $(PRIVATE_performance_tests_list_zip) -C $(dir $@) -f $(PRIVATE_performance_tests_list)
42	rm -f $@.list $@-host.list $@-target.list $@-host-test-configs.list $@-target-test-configs.list \
43	  $(PRIVATE_performance_tests_list)
44
45performance-tests: $(performance_tests_zip)
46$(call dist-for-goals, performance-tests, $(performance_tests_zip) $(performance_tests_list_zip) $(performance_tests_configs_zip))
47
48$(call declare-1p-container,$(performance_tests_zip),)
49$(call declare-container-license-deps,$(performance_tests_zip),$(COMPATIBILITY.performance-tests.FILES),$(PRODUCT_OUT)/:/)
50
51tests: performance-tests
52
53# Reset temp vars
54performance_tests_zip :=
55performance_tests_list_zip :=
56performance_tests_configs_zip :=
57