blob: 790765bdf128ec49e73bd18479794349ff4a39df [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
Brian Carlstrom07d579f2011-07-27 13:31:51 -070027# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -070028# $(2): file name
Brian Carlstrom07d579f2011-07-27 13:31:51 -070029define build-art-test
Brian Carlstrom0796af02011-10-12 14:31:45 -070030 ifneq ($(1),target)
31 ifneq ($(1),host)
32 $$(error expected target or host for argument 1, received $(1))
33 endif
34 endif
35
36 art_target_or_host := $(1)
37 art_gtest_filename := $(2)
38
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070039 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
40
Brian Carlstrom07d579f2011-07-27 13:31:51 -070041 include $(CLEAR_VARS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070042 ifeq ($$(art_target_or_host),target)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070043 include external/stlport/libstlport.mk
44 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070045
Brian Carlstrom07d579f2011-07-27 13:31:51 -070046 LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070047 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070048 LOCAL_MODULE_TAGS := tests
Brian Carlstrom0796af02011-10-12 14:31:45 -070049 LOCAL_SRC_FILES := $$(art_gtest_filename)
Brian Carlstromb0460ea2011-07-29 10:08:05 -070050 LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080051 LOCAL_SHARED_LIBRARIES := libartd
Elliott Hughes06e3ad42012-02-07 14:51:57 -080052 ifeq ($$(art_target_or_host),target)
53 LOCAL_SHARED_LIBRARIES += libdynamic_annotations
54 else
55 LOCAL_SHARED_LIBRARIES += libdynamic_annotations-host
56 endif
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080057
Shih-wei Liao5b8b1ed2012-02-23 23:48:21 -080058 ifeq ($(ART_USE_LLVM_COMPILER),true)
59 LOCAL_C_INCLUDES += frameworks/compile/linkloader
TDYa127b4669202012-03-24 20:21:51 -070060 LOCAL_STATIC_LIBRARIES += librsloader
Shih-wei Liao5b8b1ed2012-02-23 23:48:21 -080061 endif
62
Elliott Hughes0f096762012-01-31 10:32:46 -080063 # Mac OS linker doesn't understand --export-dynamic.
64 ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host)
65 # Allow jni_compiler_test to find Java_MyClass_bar within itself using dlopen(NULL, ...).
Brian Carlstrom282dab02012-02-29 10:15:34 -080066 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClass_bar -Wl,-u,Java_MyClass_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -080067 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070068
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080069 LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070070 ifeq ($$(art_target_or_host),target)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080071 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070072 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz
Shih-wei Liao5b8b1ed2012-02-23 23:48:21 -080073 LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080074 LOCAL_MODULE_PATH := $(ART_NATIVETEST_OUT)
Brian Carlstrom0796af02011-10-12 14:31:45 -070075 include $(BUILD_EXECUTABLE)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080076 art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070077 ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom0796af02011-10-12 14:31:45 -070078 else # host
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080079 LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070080 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Elliott Hughes659526d2012-01-20 17:46:53 -080081 # glibc complains about double frees if you include both libraries, but Mac OS
82 # complains about unresolved symbols if you don't!
Elliott Hughes34cf5142012-01-20 16:39:13 -080083 ifeq ($(HOST_OS),linux)
Elliott Hughes659526d2012-01-20 17:46:53 -080084 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_main_host
85 else
86 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host libgtest_main_host
Elliott Hughes34cf5142012-01-20 16:39:13 -080087 endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -070088 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070089 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
90 ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070091 endif
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070092art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
93ifeq ($$(art_target_or_host),target)
94.PHONY: $$(art_gtest_target)
95$$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync
96 adb shell touch $(ART_TEST_DIR)/$$@
97 adb shell rm $(ART_TEST_DIR)/$$@
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080098 adb shell sh -c "$(ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070099 $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
100 $(hide) rm /tmp/$$@
101
102ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
103else
104.PHONY: $$(art_gtest_target)
Brian Carlstrom29e7ac72011-12-05 23:42:57 -0800105$$(art_gtest_target): $$(art_gtest_exe) $(ART_HOST_TEST_DEPENDENCIES)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700106 $$<
107 @echo $$@ PASSED
108
109ART_HOST_TEST_TARGETS += $$(art_gtest_target)
110endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700111endef
Carl Shapiro008e4122011-06-23 17:27:46 -0700112
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700113ifeq ($(ART_BUILD_TARGET),true)
114 $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
115endif
116ifeq ($(ART_BUILD_HOST),true)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700117 $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
118endif