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/dot)
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)
41
42LOCAL_MODULE := cts-tf-dalvik-buildutil
43LOCAL_MODULE_CLASS := JAVA_LIBRARIES
44LOCAL_MODULE_TAGS := optional
45
46LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit-host jsr305lib d8
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 vts 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 dasm.jar dx.jar cfassembler.jar junit-host.jar d8.jar)
76
77$(LOCAL_BUILT_MODULE): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
78$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
79$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES := $(intermediates)/tests
80$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DEXCORE_JAR := $(intermediates)/tests/dot/junit/dexcore.jar
81$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
82$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
83$(LOCAL_BUILT_MODULE): PRIVATE_CLASS_PATH := $(call normalize-path-list, $(vmteststf_dep_jars))
84oj_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)/classes.jar
85libart_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)/classes.jar
86$(LOCAL_BUILT_MODULE): PRIVATE_DALVIK_SUITE_CLASSPATH := $(oj_jar):$(libart_jar):$(cts-tf-dalvik-lib.jar):$(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar:
87$(LOCAL_BUILT_MODULE) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar $(DX)
88	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
89	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
90	# generated and compile the host side junit tests
91	@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
92	$(hide) $(JAVA) \
93	    -cp $(PRIVATE_CLASS_PATH) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
94		$(PRIVATE_DALVIK_SUITE_CLASSPATH) \
95		$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
96	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
97	$(hide) $(JAR) -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
98		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class dot/junit/AssertionFailedException.class)
99	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
100ifneq ($(USE_D8_DESUGAR),true)
101	$(hide) $(DX_COMMAND) --dex --output=$(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
102		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
103else
104	$(hide) $(DX_COMMAND) --output $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
105		$(if $(NO_OPTIMIZE_DX), --debug) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
106endif
107	$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
108	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../$(notdir $@) .
109	$(hide) cd $(dir $@) && zip -q -r $(notdir $@) tests
110oj_jar :=
111libart_jar :=
112
113# Clean up temp vars
114intermediates :=
115vmteststf_dep_jars :=
116
117include $(call all-makefiles-under,$(LOCAL_PATH))
118