blob: 5a9f6137b70ac77db7040b698223f80a8f5084e3 [file] [log] [blame]
Carl Shapiro008e4122011-06-23 17:27:46 -07001#
2# Copyright (C) 2011 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
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070017ART_HOST_TEST_EXECUTABLES :=
18ART_TARGET_TEST_EXECUTABLES :=
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070019ART_HOST_TEST_TARGETS :=
20ART_TARGET_TEST_TARGETS :=
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070021
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080022ART_TEST_CFLAGS :=
23ifeq ($(ART_USE_LLVM_COMPILER),true)
24 ART_TEST_CFLAGS += -DART_USE_LLVM_COMPILER=1
25endif
26
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070027ifeq ($(ART_USE_GREENLAND_COMPILER),true)
28 ART_TEST_CFLAGS += -DART_USE_GREENLAND_COMPILER=1
29endif
30
buzbee2cfc6392012-05-07 14:51:40 -070031ifeq ($(ART_USE_QUICK_COMPILER),true)
32 ART_TEST_CFLAGS += -DART_USE_QUICK_COMPILER=1
33endif
34
Brian Carlstrom07d579f2011-07-27 13:31:51 -070035# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -070036# $(2): file name
Brian Carlstrom07d579f2011-07-27 13:31:51 -070037define build-art-test
Brian Carlstrom0796af02011-10-12 14:31:45 -070038 ifneq ($(1),target)
39 ifneq ($(1),host)
40 $$(error expected target or host for argument 1, received $(1))
41 endif
42 endif
43
44 art_target_or_host := $(1)
45 art_gtest_filename := $(2)
46
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070047 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
48
Brian Carlstrom07d579f2011-07-27 13:31:51 -070049 include $(CLEAR_VARS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070050 ifeq ($$(art_target_or_host),target)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070051 include external/stlport/libstlport.mk
52 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070053
Brian Carlstrom07d579f2011-07-27 13:31:51 -070054 LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070055 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070056 LOCAL_MODULE_TAGS := tests
Elliott Hugheseb02a122012-06-12 11:35:40 -070057 LOCAL_SRC_FILES := $$(art_gtest_filename) src/common_test.cc
Brian Carlstromb0460ea2011-07-29 10:08:05 -070058 LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080059 LOCAL_SHARED_LIBRARIES := libartd
Elliott Hughes06e3ad42012-02-07 14:51:57 -080060 ifeq ($$(art_target_or_host),target)
61 LOCAL_SHARED_LIBRARIES += libdynamic_annotations
62 else
63 LOCAL_SHARED_LIBRARIES += libdynamic_annotations-host
64 endif
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080065
Shih-wei Liao5b8b1ed2012-02-23 23:48:21 -080066 ifeq ($(ART_USE_LLVM_COMPILER),true)
67 LOCAL_C_INCLUDES += frameworks/compile/linkloader
TDYa127b4669202012-03-24 20:21:51 -070068 LOCAL_STATIC_LIBRARIES += librsloader
Shih-wei Liao5b8b1ed2012-02-23 23:48:21 -080069 endif
70
Elliott Hughes0f096762012-01-31 10:32:46 -080071 # Mac OS linker doesn't understand --export-dynamic.
72 ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -070073 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
74 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -080075 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070076
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080077 LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070078 ifeq ($$(art_target_or_host),target)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080079 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070080 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz
Elliott Hugheseb02a122012-06-12 11:35:40 -070081 LOCAL_STATIC_LIBRARIES += libgtest
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080082 LOCAL_MODULE_PATH := $(ART_NATIVETEST_OUT)
Brian Carlstrom0796af02011-10-12 14:31:45 -070083 include $(BUILD_EXECUTABLE)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080084 art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070085 ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom0796af02011-10-12 14:31:45 -070086 else # host
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080087 LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070088 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Elliott Hugheseb02a122012-06-12 11:35:40 -070089 ifeq ($(HOST_OS),darwin)
90 # Mac OS complains about unresolved symbols if you don't include this.
91 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host
Elliott Hughes34cf5142012-01-20 16:39:13 -080092 endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -070093 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070094 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
95 ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070096 endif
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070097art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
98ifeq ($$(art_target_or_host),target)
99.PHONY: $$(art_gtest_target)
100$$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync
101 adb shell touch $(ART_TEST_DIR)/$$@
102 adb shell rm $(ART_TEST_DIR)/$$@
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -0800103 adb shell sh -c "$(ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700104 $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
105 $(hide) rm /tmp/$$@
106
107ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
108else
109.PHONY: $$(art_gtest_target)
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700110$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700111 $$<
112 @echo $$@ PASSED
113
114ART_HOST_TEST_TARGETS += $$(art_gtest_target)
115endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700116endef
Carl Shapiro008e4122011-06-23 17:27:46 -0700117
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700118ifeq ($(ART_BUILD_TARGET),true)
119 $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
120endif
121ifeq ($(ART_BUILD_HOST),true)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700122 $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
123endif