Carl Shapiro | 008e412 | 2011-06-23 17:27:46 -0700 | [diff] [blame] | 1 | # |
| 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 Carlstrom | 8ecd08c | 2011-07-27 17:50:51 -0700 | [diff] [blame] | 17 | ART_HOST_TEST_EXECUTABLES := |
| 18 | ART_TARGET_TEST_EXECUTABLES := |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 19 | ART_HOST_TEST_TARGETS := |
| 20 | ART_TARGET_TEST_TARGETS := |
Brian Carlstrom | 8ecd08c | 2011-07-27 17:50:51 -0700 | [diff] [blame] | 21 | |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 22 | ART_TEST_CFLAGS := |
| 23 | ifeq ($(ART_USE_LLVM_COMPILER),true) |
| 24 | ART_TEST_CFLAGS += -DART_USE_LLVM_COMPILER=1 |
| 25 | endif |
| 26 | |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 27 | ifeq ($(ART_USE_GREENLAND_COMPILER),true) |
| 28 | ART_TEST_CFLAGS += -DART_USE_GREENLAND_COMPILER=1 |
| 29 | endif |
| 30 | |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 31 | ifeq ($(ART_USE_QUICK_COMPILER),true) |
| 32 | ART_TEST_CFLAGS += -DART_USE_QUICK_COMPILER=1 |
| 33 | endif |
| 34 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 35 | # $(1): target or host |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 36 | # $(2): file name |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 37 | define build-art-test |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 38 | 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 Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 47 | art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename))) |
| 48 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 49 | include $(CLEAR_VARS) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 50 | ifeq ($$(art_target_or_host),target) |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 51 | include external/stlport/libstlport.mk |
| 52 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 53 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 54 | LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 55 | LOCAL_MODULE := $$(art_gtest_name) |
Brian Carlstrom | 871599a | 2012-09-06 13:27:49 -0700 | [diff] [blame^] | 56 | ifeq ($$(art_target_or_host),target) |
| 57 | LOCAL_MODULE_TAGS := tests |
| 58 | endif |
Elliott Hughes | eb02a12 | 2012-06-12 11:35:40 -0700 | [diff] [blame] | 59 | LOCAL_SRC_FILES := $$(art_gtest_filename) src/common_test.cc |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 60 | LOCAL_C_INCLUDES += $(ART_C_INCLUDES) |
Brian Carlstrom | b9cc1ca | 2012-01-27 00:57:42 -0800 | [diff] [blame] | 61 | LOCAL_SHARED_LIBRARIES := libartd |
Elliott Hughes | 06e3ad4 | 2012-02-07 14:51:57 -0800 | [diff] [blame] | 62 | ifeq ($$(art_target_or_host),target) |
| 63 | LOCAL_SHARED_LIBRARIES += libdynamic_annotations |
| 64 | else |
| 65 | LOCAL_SHARED_LIBRARIES += libdynamic_annotations-host |
| 66 | endif |
Brian Carlstrom | b9cc1ca | 2012-01-27 00:57:42 -0800 | [diff] [blame] | 67 | |
Elliott Hughes | 0f09676 | 2012-01-31 10:32:46 -0800 | [diff] [blame] | 68 | # Mac OS linker doesn't understand --export-dynamic. |
| 69 | ifneq ($(HOST_OS)-$$(art_target_or_host),darwin-host) |
Elliott Hughes | b264f08 | 2012-04-06 17:10:10 -0700 | [diff] [blame] | 70 | # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...). |
| 71 | LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar |
Brian Carlstrom | cfede66 | 2012-01-29 17:25:54 -0800 | [diff] [blame] | 72 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 73 | |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 74 | LOCAL_CFLAGS := $(ART_TEST_CFLAGS) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 75 | ifeq ($$(art_target_or_host),target) |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 76 | LOCAL_CFLAGS += $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS) |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 77 | LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz |
Elliott Hughes | eb02a12 | 2012-06-12 11:35:40 -0700 | [diff] [blame] | 78 | LOCAL_STATIC_LIBRARIES += libgtest |
Brian Carlstrom | 32b4b2a | 2012-01-31 16:21:40 -0800 | [diff] [blame] | 79 | LOCAL_MODULE_PATH := $(ART_NATIVETEST_OUT) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 80 | include $(BUILD_EXECUTABLE) |
Brian Carlstrom | b9cc1ca | 2012-01-27 00:57:42 -0800 | [diff] [blame] | 81 | art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 82 | ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 83 | else # host |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 84 | LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS) |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 85 | LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host |
Elliott Hughes | eb02a12 | 2012-06-12 11:35:40 -0700 | [diff] [blame] | 86 | ifeq ($(HOST_OS),darwin) |
| 87 | # Mac OS complains about unresolved symbols if you don't include this. |
| 88 | LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host |
Elliott Hughes | 34cf514 | 2012-01-20 16:39:13 -0800 | [diff] [blame] | 89 | endif |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 90 | include $(BUILD_HOST_EXECUTABLE) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 91 | art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE) |
| 92 | ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe) |
Brian Carlstrom | 8ecd08c | 2011-07-27 17:50:51 -0700 | [diff] [blame] | 93 | endif |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 94 | art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name) |
| 95 | ifeq ($$(art_target_or_host),target) |
| 96 | .PHONY: $$(art_gtest_target) |
| 97 | $$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync |
| 98 | adb shell touch $(ART_TEST_DIR)/$$@ |
| 99 | adb shell rm $(ART_TEST_DIR)/$$@ |
Brian Carlstrom | eaec3ae | 2012-06-17 23:30:57 -0700 | [diff] [blame] | 100 | adb shell chmod 755 $(ART_NATIVETEST_DIR)/$$(notdir $$<) |
Brian Carlstrom | 32b4b2a | 2012-01-31 16:21:40 -0800 | [diff] [blame] | 101 | adb shell sh -c "$(ART_NATIVETEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@" |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 102 | $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1) |
| 103 | $(hide) rm /tmp/$$@ |
| 104 | |
| 105 | ART_TARGET_TEST_TARGETS += $$(art_gtest_target) |
| 106 | else |
| 107 | .PHONY: $$(art_gtest_target) |
Brian Carlstrom | b0aa9d3 | 2012-04-07 23:12:22 -0700 | [diff] [blame] | 108 | $$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 109 | $$< |
| 110 | @echo $$@ PASSED |
| 111 | |
| 112 | ART_HOST_TEST_TARGETS += $$(art_gtest_target) |
| 113 | endif |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 114 | endef |
Carl Shapiro | 008e412 | 2011-06-23 17:27:46 -0700 | [diff] [blame] | 115 | |
Brian Carlstrom | 4b620ff | 2011-09-11 01:11:01 -0700 | [diff] [blame] | 116 | ifeq ($(ART_BUILD_TARGET),true) |
| 117 | $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file)))) |
| 118 | endif |
| 119 | ifeq ($(ART_BUILD_HOST),true) |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 120 | $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file)))) |
| 121 | endif |