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