blob: c359bacdfe8f00a9674207bb585244ab09165c3d [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))
27# Auto generating test config file for native test
28$(autogen_test_config_file) : $(NATIVE_TEST_CONFIG_TEMPLATE)
29 @echo "Auto generating test config $(notdir $@)"
30 $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@
31my_auto_generate_config := true
32else
33# Auto generating test config file for instrumentation test
34ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
35 LOCAL_MANIFEST_FILE := AndroidManifest.xml
36endif
37ifdef LOCAL_FULL_MANIFEST_FILE
38 my_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
39else
40 my_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
41endif
42ifneq (,$(wildcard $(my_android_manifest)))
Dan Shi2b334f52017-12-22 20:23:22 -080043$(autogen_test_config_file): PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT := $(AUTOGEN_TEST_CONFIG_SCRIPT)
44$(autogen_test_config_file): PRIVATE_TEST_CONFIG_ANDROID_MANIFEST := $(my_android_manifest)
45$(autogen_test_config_file): PRIVATE_EMPTY_TEST_CONFIG := $(EMPTY_TEST_CONFIG)
46$(autogen_test_config_file): PRIVATE_TEMPLATE := $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE)
47$(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 -080048 @echo "Auto generating test config $(notdir $@)"
49 @rm -f $@
Dan Shi2b334f52017-12-22 20:23:22 -080050 $(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE)
Dan Shiefb892d2017-12-06 15:57:31 -080051my_auto_generate_config := true
52endif # ifeq (,$(wildcard $(my_android_manifest)))
53endif # ifneq (true,$(is_native))
54
55ifeq (true,$(my_auto_generate_config))
56 LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file)
57 $(LOCAL_BUILT_MODULE): $(autogen_test_config_file)
58 ALL_MODULES.$(my_register_name).auto_test_config := true
59else
60 autogen_test_config_file :=
61endif
62
63my_android_manifest :=
64my_auto_generate_config :=