1# Copyright (C) 2011 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
15LOCAL_PATH := $(call my-dir)
16
17# test dex library
18# ============================================================
19include $(CLEAR_VARS)
20
21# custom variables used to generate test description. do not touch!
22LOCAL_SRC_FILES := $(call all-java-files-under, src)
23
24LOCAL_MODULE := cts-tf-dalvik-lib
25LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
26LOCAL_LICENSE_CONDITIONS := notice
27LOCAL_MODULE_CLASS := JAVA_LIBRARIES
28LOCAL_MODULE_TAGS := optional
29LOCAL_JAVA_LIBRARIES := junit
30include $(BUILD_JAVA_LIBRARY)
31
32cts-tf-dalvik-lib.jar := $(full_classes_jar)
33
34# buildutil java library
35# ============================================================
36include $(CLEAR_VARS)
37
38# custom variables used by cts/tools/utils/CollectAllTests.java to generate test description. do not touch!
39LOCAL_TEST_TYPE := vmHostTest
40LOCAL_JAR_PATH := android.core.vm-tests-tf.jar
41
42LOCAL_SRC_FILES := $(call all-java-files-under, src build/src)
43
44LOCAL_MODULE := cts-tf-dalvik-buildutil
45LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
46LOCAL_LICENSE_CONDITIONS := notice
47LOCAL_MODULE_CLASS := JAVA_LIBRARIES
48LOCAL_MODULE_TAGS := optional
49
50LOCAL_JAVA_LIBRARIES := junit jsr305 d8 smali
51
52LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
53
54include $(BUILD_HOST_JAVA_LIBRARY)
55
56# Buid android.core.vm-tests-tf.jar
57# ============================================================
58#
59include $(CLEAR_VARS)
60
61LOCAL_MODULE := vm-tests-tf
62LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
63LOCAL_LICENSE_CONDITIONS := notice
64LOCAL_MODULE_CLASS := JAVA_LIBRARIES
65LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
66LOCAL_IS_HOST_MODULE := true
67LOCAL_BUILT_MODULE_STEM := javalib.jar
68intermediates := $(call local-intermediates-dir)
69# Install the module as $(intermediates)/android.core.vm-tests-tf.jar.
70LOCAL_INSTALLED_MODULE_STEM := android.core.vm-tests-tf.jar
71LOCAL_MODULE_PATH := $(intermediates)
72
73# Tag this module as a cts test artifact
74LOCAL_COMPATIBILITY_SUITE := cts general-tests
75
76include $(BUILD_SYSTEM)/base_rules.mk
77
78vmteststf_dep_jars := \
79    $(HOST_JDK_TOOLS_JAR) \
80    $(cts-tf-dalvik-lib.jar) \
81    $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar junit.jar d8.jar smali.jar) \
82    $(call intermediates-dir-for,JAVA_LIBRARIES,cts-vmtests-dot,HOST,COMMON)/classes.jar
83
84vmtests_generated_resources_jar := \
85    $(call intermediates-dir-for,JAVA_LIBRARIES,vmtests-generated-resources,HOST)/javalib.jar
86vmtests_mains_generated_jar := \
87    $(call intermediates-dir-for,JAVA_LIBRARIES,vmtests-mains,,COMMON)/javalib.jar
88
89$(LOCAL_BUILT_MODULE): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
90$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
91$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES := $(intermediates)/tests
92$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
93$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(call normalize-path-list, $(vmteststf_dep_jars))
94$(LOCAL_BUILT_MODULE): PRIVATE_VMTESTS_GENERATED_RESOURCES := $(vmtests_generated_resources_jar)
95$(LOCAL_BUILT_MODULE): PRIVATE_VMTESTS_MAINS_GENERATED := $(vmtests_mains_generated_jar)
96$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar $(DX) $(vmtests_generated_resources_jar) $(vmtests_mains_generated_jar)
97	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
98	$(hide) mkdir -p $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
99	# generated and compile the host side junit tests
100	@echo "Write generated Main_*.java"
101	$(hide) $(JAVA) \
102	    -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
103		$(PRIVATE_INTERMEDIATES_CLASSES)
104	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
105	$(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
106		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class dot/junit/AssertionFailedException.class)
107	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
108	$(hide) $(DX_COMMAND) --output $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
109		$(if $(NO_OPTIMIZE_DX), --debug) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
110	$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
111	$(hide) cp $(PRIVATE_VMTESTS_GENERATED_RESOURCES) $@
112	$(hide) cp $(PRIVATE_VMTESTS_MAINS_GENERATED) $(dir $@)/tests/mains.jar
113	$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
114
115# Clean up temp vars
116intermediates :=
117vmteststf_dep_jars :=
118vmtests_generated_resources_jar :=
119vmtests_mains_generated_jar :=
120
121include $(call all-makefiles-under,$(LOCAL_PATH))
122