blob: f13c47e271fabbb95aaa0c16d7ab785885b25532 [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 :=
buzbeec531cef2012-10-18 07:09:20 -070023ifeq ($(ART_USE_PORTABLE_COMPILER),true)
24 ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
buzbee2cfc6392012-05-07 14:51:40 -070025endif
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 Carlstrom871599a2012-09-06 13:27:49 -070048 ifeq ($$(art_target_or_host),target)
49 LOCAL_MODULE_TAGS := tests
50 endif
Elliott Hugheseb02a122012-06-12 11:35:40 -070051 LOCAL_SRC_FILES := $$(art_gtest_filename) src/common_test.cc
Brian Carlstromb0460ea2011-07-29 10:08:05 -070052 LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080053 LOCAL_SHARED_LIBRARIES := libartd
54
Elliott Hughes0f096762012-01-31 10:32:46 -080055 # Mac OS linker doesn't understand --export-dynamic.
56 ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -070057 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
58 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -080059 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070060
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080061 LOCAL_CFLAGS := $(ART_TEST_CFLAGS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070062 ifeq ($$(art_target_or_host),target)
Ian Rogerscd5d0422013-05-17 15:54:01 -070063 LOCAL_CLANG := $(ART_TARGET_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080064 LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Mathieu Chartier0e4627e2012-10-23 16:13:36 -070065 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz libcutils
Elliott Hugheseb02a122012-06-12 11:35:40 -070066 LOCAL_STATIC_LIBRARIES += libgtest
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080067 LOCAL_MODULE_PATH := $(ART_NATIVETEST_OUT)
Brian Carlstrom700c8d32012-11-05 10:42:02 -080068 include $(LLVM_DEVICE_BUILD_MK)
Brian Carlstrom0796af02011-10-12 14:31:45 -070069 include $(BUILD_EXECUTABLE)
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -080070 art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070071 ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom0796af02011-10-12 14:31:45 -070072 else # host
Ian Rogerscd5d0422013-05-17 15:54:01 -070073 LOCAL_CLANG := $(ART_HOST_CLANG)
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080074 LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070075 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Mathieu Chartier0e4627e2012-10-23 16:13:36 -070076 LOCAL_STATIC_LIBRARIES += libcutils
Elliott Hugheseb02a122012-06-12 11:35:40 -070077 ifeq ($(HOST_OS),darwin)
78 # Mac OS complains about unresolved symbols if you don't include this.
79 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host
Elliott Hughes34cf5142012-01-20 16:39:13 -080080 endif
Brian Carlstrom700c8d32012-11-05 10:42:02 -080081 include $(LLVM_HOST_BUILD_MK)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070082 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070083 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
84 ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070085 endif
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070086art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
87ifeq ($$(art_target_or_host),target)
88.PHONY: $$(art_gtest_target)
89$$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync
90 adb shell touch $(ART_TEST_DIR)/$$@
91 adb shell rm $(ART_TEST_DIR)/$$@
Brian Carlstromeaec3ae2012-06-17 23:30:57 -070092 adb shell chmod 755 $(ART_NATIVETEST_DIR)/$$(notdir $$<)
Brian Carlstrom32b4b2a2012-01-31 16:21:40 -080093 adb shell sh -c "$(ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@"
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070094 $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
95 $(hide) rm /tmp/$$@
96
97ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
98else
99.PHONY: $$(art_gtest_target)
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700100$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700101 $$<
102 @echo $$@ PASSED
103
104ART_HOST_TEST_TARGETS += $$(art_gtest_target)
105endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700106endef
Carl Shapiro008e4122011-06-23 17:27:46 -0700107
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700108ifeq ($(ART_BUILD_TARGET),true)
109 $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
110endif
111ifeq ($(ART_BUILD_HOST),true)
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700112 $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
113endif