blob: 4ea6f9abd31ccfbdf11dc98ea99dd84c108ccf9a [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
Brian Carlstrom07d579f2011-07-27 13:31:51 -070022# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -070023# $(2): file name
Brian Carlstrom07d579f2011-07-27 13:31:51 -070024define build-art-test
Brian Carlstrom0796af02011-10-12 14:31:45 -070025 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 Carlstrom47a0d5a2011-10-12 21:20:05 -070034 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
35
Brian Carlstrom07d579f2011-07-27 13:31:51 -070036 include $(CLEAR_VARS)
Brian Carlstrom0796af02011-10-12 14:31:45 -070037 ifeq ($$(art_target_or_host),target)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070038 include external/stlport/libstlport.mk
39 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070040
Brian Carlstrom07d579f2011-07-27 13:31:51 -070041 LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070042 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070043 LOCAL_MODULE_TAGS := tests
Brian Carlstrom0796af02011-10-12 14:31:45 -070044 LOCAL_SRC_FILES := $$(art_gtest_filename)
Brian Carlstromb0460ea2011-07-29 10:08:05 -070045 LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070046 LOCAL_SHARED_LIBRARIES := libarttest libartd
Brian Carlstrom0796af02011-10-12 14:31:45 -070047
48 ifeq ($$(art_target_or_host),target)
Brian Carlstrom86927212011-09-15 11:31:11 -070049 LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070050 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz
Brian Carlstrom07d579f2011-07-27 13:31:51 -070051 LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070052 LOCAL_MODULE_PATH := $(ART_TEST_OUT)
Brian Carlstrom0796af02011-10-12 14:31:45 -070053 include $(BUILD_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070054 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
55 ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom0796af02011-10-12 14:31:45 -070056 else # host
Brian Carlstrom86927212011-09-15 11:31:11 -070057 LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -070058 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Brian Carlstrombc512352011-09-16 15:57:22 -070059 LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_main_host
Brian Carlstrom07d579f2011-07-27 13:31:51 -070060 include $(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070061 art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
62 ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070063 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -070064
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070065art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
66ifeq ($$(art_target_or_host),target)
67.PHONY: $$(art_gtest_target)
68$$(art_gtest_target): $$(art_gtest_exe) test-art-target-sync
69 adb shell touch $(ART_TEST_DIR)/$$@
70 adb shell rm $(ART_TEST_DIR)/$$@
71 adb shell sh -c "$(ART_TEST_DIR)/$$(notdir $$<) && touch $(ART_TEST_DIR)/$$@"
72 $(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
73 $(hide) rm /tmp/$$@
74
75ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
76else
77.PHONY: $$(art_gtest_target)
78$$(art_gtest_target): $$(art_gtest_exe)
79 $$<
80 @echo $$@ PASSED
81
82ART_HOST_TEST_TARGETS += $$(art_gtest_target)
83endif
Brian Carlstrom07d579f2011-07-27 13:31:51 -070084endef
Carl Shapiro008e4122011-06-23 17:27:46 -070085
Brian Carlstrom4b620ff2011-09-11 01:11:01 -070086ifeq ($(ART_BUILD_TARGET),true)
87 $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
88endif
89ifeq ($(ART_BUILD_HOST),true)
Brian Carlstrom07d579f2011-07-27 13:31:51 -070090 $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
91endif