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 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 22 | # $(1): target or host |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 23 | # $(2): file name |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 24 | define build-art-test |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 25 | ifneq ($(1),target) |
| 26 | ifneq ($(1),host) |
| 27 | $$(error expected target or host for argument 1, received $(1)) |
| 28 | endif |
| 29 | endif |
| 30 | |
| 31 | art_target_or_host := $(1) |
| 32 | art_gtest_filename := $(2) |
| 33 | |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 34 | art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename))) |
| 35 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 36 | include $(CLEAR_VARS) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 37 | ifeq ($$(art_target_or_host),target) |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 38 | include external/stlport/libstlport.mk |
| 39 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 40 | |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 41 | LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 42 | LOCAL_MODULE := $$(art_gtest_name) |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 43 | LOCAL_MODULE_TAGS := tests |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 44 | LOCAL_SRC_FILES := $$(art_gtest_filename) |
Brian Carlstrom | b0460ea | 2011-07-29 10:08:05 -0700 | [diff] [blame] | 45 | LOCAL_C_INCLUDES += $(ART_C_INCLUDES) |
Brian Carlstrom | 8ecd08c | 2011-07-27 17:50:51 -0700 | [diff] [blame] | 46 | LOCAL_SHARED_LIBRARIES := libarttest libartd |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 47 | |
| 48 | ifeq ($$(art_target_or_host),target) |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 49 | LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS) |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 50 | LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 51 | LOCAL_STATIC_LIBRARIES := libgtest libgtest_main |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 52 | LOCAL_MODULE_PATH := $(ART_TEST_OUT) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 53 | include $(BUILD_EXECUTABLE) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 54 | art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE) |
| 55 | ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe) |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 56 | else # host |
Brian Carlstrom | 8692721 | 2011-09-15 11:31:11 -0700 | [diff] [blame] | 57 | LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS) |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 58 | LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host |
Elliott Hughes | 659526d | 2012-01-20 17:46:53 -0800 | [diff] [blame^] | 59 | # glibc complains about double frees if you include both libraries, but Mac OS |
| 60 | # complains about unresolved symbols if you don't! |
Elliott Hughes | 34cf514 | 2012-01-20 16:39:13 -0800 | [diff] [blame] | 61 | ifeq ($(HOST_OS),linux) |
Elliott Hughes | 659526d | 2012-01-20 17:46:53 -0800 | [diff] [blame^] | 62 | LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_main_host |
| 63 | else |
| 64 | LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_host libgtest_main_host |
Elliott Hughes | 34cf514 | 2012-01-20 16:39:13 -0800 | [diff] [blame] | 65 | endif |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 66 | include $(BUILD_HOST_EXECUTABLE) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 67 | art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE) |
| 68 | ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe) |
Brian Carlstrom | 8ecd08c | 2011-07-27 17:50:51 -0700 | [diff] [blame] | 69 | endif |
Brian Carlstrom | 0796af0 | 2011-10-12 14:31:45 -0700 | [diff] [blame] | 70 | |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 71 | art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name) |
| 72 | ifeq ($$(art_target_or_host),target) |
| 73 | .PHONY: $$(art_gtest_target) |
| 74 | $$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync |
| 75 | adb shell touch $(ART_TEST_DIR)/$$@ |
| 76 | adb shell rm $(ART_TEST_DIR)/$$@ |
| 77 | adb shell sh -c "$(ART_TEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@" |
| 78 | $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1) |
| 79 | $(hide) rm /tmp/$$@ |
| 80 | |
| 81 | ART_TARGET_TEST_TARGETS += $$(art_gtest_target) |
| 82 | else |
| 83 | .PHONY: $$(art_gtest_target) |
Brian Carlstrom | 29e7ac7 | 2011-12-05 23:42:57 -0800 | [diff] [blame] | 84 | $$(art_gtest_target): $$(art_gtest_exe) $(ART_HOST_TEST_DEPENDENCIES) |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 85 | $$< |
| 86 | @echo $$@ PASSED |
| 87 | |
| 88 | ART_HOST_TEST_TARGETS += $$(art_gtest_target) |
| 89 | endif |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 90 | endef |
Carl Shapiro | 008e412 | 2011-06-23 17:27:46 -0700 | [diff] [blame] | 91 | |
Brian Carlstrom | 4b620ff | 2011-09-11 01:11:01 -0700 | [diff] [blame] | 92 | ifeq ($(ART_BUILD_TARGET),true) |
| 93 | $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file)))) |
| 94 | endif |
| 95 | ifeq ($(ART_BUILD_HOST),true) |
Brian Carlstrom | 07d579f | 2011-07-27 13:31:51 -0700 | [diff] [blame] | 96 | $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file)))) |
| 97 | endif |