blob: d2eb7c388082d80abc487e2d56fec481d0c3bd60 [file] [log] [blame]
Dan Shiefb892d2017-12-06 15:57:31 -08001#
2# Copyright (C) 2017 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# This build rule allows TradeFed test config file to be created based on
18# following inputs:
19# is_native: If the test is a native test.
20# LOCAL_MANIFEST_FILE: Name of the AndroidManifest file for the test. If it's
21# not set, default value `AndroidManifest.xml` will be used.
22# Output:
23# autogen_test_config_file: Path to the test config file generated.
24
25autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
26ifeq (true,$(is_native))
Nelson Lieec95292018-04-18 17:51:58 +000027ifeq ($(LOCAL_NATIVE_BENCHMARK),true)
28autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE)
29else
30autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE)
31endif
Dan Shiefb892d2017-12-06 15:57:31 -080032# Auto generating test config file for native test
Nelson Lieec95292018-04-18 17:51:58 +000033$(autogen_test_config_file) : $(autogen_test_config_template)
Dan Shiefb892d2017-12-06 15:57:31 -080034 @echo "Auto generating test config $(notdir $@)"
35 $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@
36my_auto_generate_config := true
37else
38# Auto generating test config file for instrumentation test
39ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
40 LOCAL_MANIFEST_FILE := AndroidManifest.xml
41endif
42ifdef LOCAL_FULL_MANIFEST_FILE
43 my_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
44else
45 my_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
46endif
47ifneq (,$(wildcard $(my_android_manifest)))
Dan Shi2b334f52017-12-22 20:23:22 -080048$(autogen_test_config_file): PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT := $(AUTOGEN_TEST_CONFIG_SCRIPT)
49$(autogen_test_config_file): PRIVATE_TEST_CONFIG_ANDROID_MANIFEST := $(my_android_manifest)
50$(autogen_test_config_file): PRIVATE_EMPTY_TEST_CONFIG := $(EMPTY_TEST_CONFIG)
51$(autogen_test_config_file): PRIVATE_TEMPLATE := $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE)
52$(autogen_test_config_file) : $(my_android_manifest) $(EMPTY_TEST_CONFIG) $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE) $(AUTOGEN_TEST_CONFIG_SCRIPT)
Dan Shiefb892d2017-12-06 15:57:31 -080053 @echo "Auto generating test config $(notdir $@)"
54 @rm -f $@
Dan Shi2b334f52017-12-22 20:23:22 -080055 $(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE)
Dan Shiefb892d2017-12-06 15:57:31 -080056my_auto_generate_config := true
57endif # ifeq (,$(wildcard $(my_android_manifest)))
58endif # ifneq (true,$(is_native))
59
60ifeq (true,$(my_auto_generate_config))
61 LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file)
62 $(LOCAL_BUILT_MODULE): $(autogen_test_config_file)
63 ALL_MODULES.$(my_register_name).auto_test_config := true
64else
65 autogen_test_config_file :=
66endif
67
68my_android_manifest :=
69my_auto_generate_config :=