Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 1 | # |
| 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 | |
| 25 | autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config |
| 26 | ifeq (true,$(is_native)) |
Nelson Li | eec9529 | 2018-04-18 17:51:58 +0000 | [diff] [blame] | 27 | ifeq ($(LOCAL_NATIVE_BENCHMARK),true) |
| 28 | autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE) |
| 29 | else |
| 30 | autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE) |
| 31 | endif |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 32 | # Auto generating test config file for native test |
Nelson Li | eec9529 | 2018-04-18 17:51:58 +0000 | [diff] [blame] | 33 | $(autogen_test_config_file) : $(autogen_test_config_template) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 34 | @echo "Auto generating test config $(notdir $@)" |
| 35 | $(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@ |
| 36 | my_auto_generate_config := true |
| 37 | else |
| 38 | # Auto generating test config file for instrumentation test |
| 39 | ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) |
| 40 | LOCAL_MANIFEST_FILE := AndroidManifest.xml |
| 41 | endif |
| 42 | ifdef LOCAL_FULL_MANIFEST_FILE |
| 43 | my_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) |
| 44 | else |
| 45 | my_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) |
| 46 | endif |
| 47 | ifneq (,$(wildcard $(my_android_manifest))) |
Dan Shi | 2b334f5 | 2017-12-22 20:23:22 -0800 | [diff] [blame] | 48 | $(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 Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 53 | @echo "Auto generating test config $(notdir $@)" |
| 54 | @rm -f $@ |
Dan Shi | 2b334f5 | 2017-12-22 20:23:22 -0800 | [diff] [blame] | 55 | $(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE) |
Dan Shi | efb892d | 2017-12-06 15:57:31 -0800 | [diff] [blame] | 56 | my_auto_generate_config := true |
| 57 | endif # ifeq (,$(wildcard $(my_android_manifest))) |
| 58 | endif # ifneq (true,$(is_native)) |
| 59 | |
| 60 | ifeq (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 |
| 64 | else |
| 65 | autogen_test_config_file := |
| 66 | endif |
| 67 | |
| 68 | my_android_manifest := |
| 69 | my_auto_generate_config := |