blob: a6f6298650686beeb9bcd0e011f3ddce83265207 [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
Ian Rogersafd9acc2014-06-17 08:21:54 -070017# The path for which all the dex files are relative, not actually the current directory.
18LOCAL_PATH := art/test
19
20include art/build/Android.common_test.mk
21include art/build/Android.common_path.mk
22
23# Subdirectories in art/test which contain dex files used as inputs for gtests.
24GTEST_DEX_DIRECTORIES := \
25 AbstractMethod \
26 AllFields \
27 ExceptionHandle \
28 GetMethodSignature \
29 Interfaces \
30 Main \
31 MyClass \
32 MyClassNatives \
33 Nested \
34 NonStaticLeafMethods \
35 ProtoCompare \
36 ProtoCompare2 \
37 StaticLeafMethods \
38 Statics \
39 StaticsFromCode \
40 Transaction \
41 XandY
42
43# Create build rules for each dex file recording the dependency.
44$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gtest,$(dir), \
45 $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_GTEST_$(dir)_DEX)))
46
47# Dex file dependencies for each gtest.
48ART_GTEST_class_linker_test_DEPS := $(ART_GTEST_Interfaces_DEX) $(ART_GTEST_MyClass_DEX) \
49 $(ART_GTEST_Nested_DEX) $(ART_GTEST_Statics_DEX) $(ART_GTEST_StaticsFromCode_DEX)
Ian Rogers665de8a2014-06-24 21:34:09 -070050ART_GTEST_compiler_driver_test_DEPS := $(ART_GTEST_AbstractMethod_DEX)
Ian Rogersafd9acc2014-06-17 08:21:54 -070051ART_GTEST_dex_file_test_DEPS := $(ART_GTEST_GetMethodSignature_DEX)
52ART_GTEST_exception_test_DEPS := $(ART_GTEST_ExceptionHandle_DEX)
53ART_GTEST_jni_compiler_test_DEPS := $(ART_GTEST_MyClassNatives_DEX)
54ART_GTEST_jni_internal_test_DEPS := $(ART_GTEST_AllFields_DEX)
55ART_GTEST_object_test_DEPS := $(ART_GTEST_ProtoCompare_DEX) $(ART_GTEST_ProtoCompare2_DEX) \
56 $(ART_GTEST_StaticsFromCode_DEX) $(ART_GTEST_XandY_DEX)
57ART_GTEST_proxy_test_DEPS := $(ART_GTEST_Interfaces_DEX)
58ART_GTEST_reflection_test_DEPS := $(ART_GTEST_Main_DEX) $(ART_GTEST_NonStaticLeafMethods_DEX) \
59 $(ART_GTEST_StaticLeafMethods_DEX)
60ART_GTEST_stub_test_DEPS := $(ART_GTEST_AllFields_DEX)
61ART_GTEST_transaction_test_DEPS := $(ART_GTEST_Transaction_DEX)
62
63# The elf writer test has dependencies on core.oat.
64ART_GTEST_elf_writer_test_DEPS := $(HOST_CORE_OAT_OUT) $(2ND_HOST_CORE_OAT_OUT) \
65 $(TARGET_CORE_OAT_OUT) $(2ND_TARGET_CORE_OAT_OUT)
66
67# The path for which all the source files are relative, not actually the current directory.
Brian Carlstrom7940e442013-07-12 13:46:57 -070068LOCAL_PATH := art
69
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080070RUNTIME_GTEST_COMMON_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -070071 runtime/arch/arch_test.cc \
72 runtime/arch/stub_test.cc \
73 runtime/barrier_test.cc \
74 runtime/base/bit_field_test.cc \
75 runtime/base/bit_vector_test.cc \
76 runtime/base/hex_dump_test.cc \
77 runtime/base/histogram_test.cc \
78 runtime/base/mutex_test.cc \
79 runtime/base/scoped_flock_test.cc \
80 runtime/base/timing_logger_test.cc \
81 runtime/base/unix_file/fd_file_test.cc \
82 runtime/base/unix_file/mapped_file_test.cc \
83 runtime/base/unix_file/null_file_test.cc \
84 runtime/base/unix_file/random_access_file_utils_test.cc \
85 runtime/base/unix_file/string_file_test.cc \
86 runtime/class_linker_test.cc \
87 runtime/dex_file_test.cc \
88 runtime/dex_file_verifier_test.cc \
89 runtime/dex_instruction_visitor_test.cc \
90 runtime/dex_method_iterator_test.cc \
91 runtime/entrypoints/math_entrypoints_test.cc \
92 runtime/entrypoints/quick/quick_trampoline_entrypoints_test.cc \
93 runtime/entrypoints_order_test.cc \
94 runtime/exception_test.cc \
95 runtime/gc/accounting/space_bitmap_test.cc \
96 runtime/gc/heap_test.cc \
97 runtime/gc/space/dlmalloc_space_base_test.cc \
98 runtime/gc/space/dlmalloc_space_static_test.cc \
99 runtime/gc/space/dlmalloc_space_random_test.cc \
100 runtime/gc/space/rosalloc_space_base_test.cc \
101 runtime/gc/space/rosalloc_space_static_test.cc \
102 runtime/gc/space/rosalloc_space_random_test.cc \
103 runtime/gc/space/large_object_space_test.cc \
104 runtime/gtest_test.cc \
105 runtime/handle_scope_test.cc \
106 runtime/indenter_test.cc \
107 runtime/indirect_reference_table_test.cc \
108 runtime/instruction_set_test.cc \
109 runtime/intern_table_test.cc \
110 runtime/leb128_test.cc \
111 runtime/mem_map_test.cc \
112 runtime/mirror/dex_cache_test.cc \
113 runtime/mirror/object_test.cc \
114 runtime/parsed_options_test.cc \
115 runtime/reference_table_test.cc \
116 runtime/thread_pool_test.cc \
117 runtime/transaction_test.cc \
118 runtime/utils_test.cc \
119 runtime/verifier/method_verifier_test.cc \
120 runtime/verifier/reg_type_test.cc \
121 runtime/zip_archive_test.cc
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800122
123COMPILER_GTEST_COMMON_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700124 runtime/jni_internal_test.cc \
125 runtime/proxy_test.cc \
126 runtime/reflection_test.cc \
127 compiler/dex/local_value_numbering_test.cc \
128 compiler/dex/mir_optimization_test.cc \
129 compiler/driver/compiler_driver_test.cc \
130 compiler/elf_writer_test.cc \
131 compiler/image_test.cc \
132 compiler/jni/jni_compiler_test.cc \
133 compiler/oat_test.cc \
134 compiler/optimizing/codegen_test.cc \
135 compiler/optimizing/dominator_test.cc \
136 compiler/optimizing/find_loops_test.cc \
137 compiler/optimizing/graph_test.cc \
138 compiler/optimizing/linearize_test.cc \
139 compiler/optimizing/liveness_test.cc \
140 compiler/optimizing/live_interval_test.cc \
141 compiler/optimizing/live_ranges_test.cc \
142 compiler/optimizing/parallel_move_test.cc \
143 compiler/optimizing/pretty_printer_test.cc \
144 compiler/optimizing/register_allocator_test.cc \
145 compiler/optimizing/ssa_test.cc \
146 compiler/output_stream_test.cc \
147 compiler/utils/arena_allocator_test.cc \
148 compiler/utils/dedupe_set_test.cc \
149 compiler/utils/arm/managed_register_arm_test.cc \
150 compiler/utils/arm64/managed_register_arm64_test.cc \
151 compiler/utils/x86/managed_register_x86_test.cc \
Brian Carlstrom51c24672013-07-11 16:00:56 -0700152
Dragos Sbirlea8cc51622013-06-21 09:20:34 -0700153ifeq ($(ART_SEA_IR_MODE),true)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800154COMPILER_GTEST_COMMON_SRC_FILES += \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700155 compiler/utils/scoped_hashtable_test.cc \
156 compiler/sea_ir/types/type_data_test.cc \
157 compiler/sea_ir/types/type_inference_visitor_test.cc \
158 compiler/sea_ir/ir/regions_test.cc
Dragos Sbirlea8cc51622013-06-21 09:20:34 -0700159endif
160
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800161RUNTIME_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700162 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstrom51c24672013-07-11 16:00:56 -0700163
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800164RUNTIME_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700165 $(RUNTIME_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800166
167COMPILER_GTEST_TARGET_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700168 $(COMPILER_GTEST_COMMON_SRC_FILES)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800169
170COMPILER_GTEST_HOST_SRC_FILES := \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700171 $(COMPILER_GTEST_COMMON_SRC_FILES) \
172 compiler/utils/x86/assembler_x86_test.cc \
173 compiler/utils/x86_64/assembler_x86_64_test.cc
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -0700174
Shih-wei Liaoc4c98812012-03-10 21:55:51 -0800175ART_TEST_CFLAGS :=
buzbeec531cef2012-10-18 07:09:20 -0700176ifeq ($(ART_USE_PORTABLE_COMPILER),true)
177 ART_TEST_CFLAGS += -DART_USE_PORTABLE_COMPILER=1
buzbee2cfc6392012-05-07 14:51:40 -0700178endif
179
Ian Rogersafd9acc2014-06-17 08:21:54 -0700180# Variables holding collections of gtest pre-requisits used to run a number of gtests.
181ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
182ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
183ART_TEST_HOST_GTEST_RULES :=
184ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
185ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
186ART_TEST_HOST_VALGRIND_GTEST_RULES :=
187ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
188ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
189ART_TEST_TARGET_GTEST_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700190
Ian Rogersafd9acc2014-06-17 08:21:54 -0700191# Define a make rule for a target device gtest.
192# $(1): gtest name - the name of the test we're building such as leb128_test.
193# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
194define define-art-gtest-rule-target
195 gtest_rule := test-art-target-gtest-$(1)$$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700196
Ian Rogersafd9acc2014-06-17 08:21:54 -0700197 # Add the test dependencies to test-art-target-sync, which will be a prerequisit for the test
198 # to ensure files are pushed to the device.
199 TEST_ART_TARGET_SYNC_DEPS += \
200 $$(ART_GTEST_$(1)_DEPS) \
201 $$(ART_TARGET_NATIVETEST_OUT)/$$(TARGET_$(2)ARCH)/$(1) \
Ian Rogers665de8a2014-06-24 21:34:09 -0700202 $$(TARGET_CORE_DEX_LOCATIONS) \
203 $$($(2)TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700204
Ian Rogersafd9acc2014-06-17 08:21:54 -0700205.PHONY: $$(gtest_rule)
206$$(gtest_rule): test-art-target-sync
207 $(hide) adb shell touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
208 $(hide) adb shell rm $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID
209 $(hide) adb shell chmod 755 $(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1)
210 $(hide) $$(call ART_TEST_SKIP,$$@) && \
211 (adb shell sh -c "$(ART_TARGET_NATIVETEST_DIR)/$(TARGET_$(2)ARCH)/$(1) && touch $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID" \
212 && (adb pull $(ART_TARGET_TEST_DIR)/$(TARGET_$(2)ARCH)/$$@-$$$$PPID /tmp/ \
213 && $$(call ART_TEST_PASSED,$$@)) \
214 || $$(call ART_TEST_FAILED,$$@))
215 $(hide) rm /tmp/$$@-$$$$PPID
216
217 ART_TEST_TARGET_GTEST$($(2)ART_PHONY_TEST_TARGET_SUFFIX)_RULES += $$(gtest_rule)
218 ART_TEST_TARGET_GTEST_RULES += $$(gtest_rule)
219 ART_TEST_TARGET_GTEST_$(1)_RULES += $$(gtest_rule)
220
221 # Clear locally defined variables.
222 gtest_rule :=
223endef # define-art-gtest-rule-target
224
225# Define make rules for a host gtests.
226# $(1): gtest name - the name of the test we're building such as leb128_test.
227# $(2): 2ND_ or undefined - used to differentiate between the primary and secondary architecture.
228define define-art-gtest-rule-host
229 gtest_rule := test-art-host-gtest-$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
230 gtest_exe := $$(HOST_OUT_EXECUTABLES)/$(1)$$($(2)ART_PHONY_TEST_HOST_SUFFIX)
Ian Rogers665de8a2014-06-24 21:34:09 -0700231 # Dependencies for all host gtests.
232 gtest_deps := $$(HOST_CORE_DEX_LOCATIONS) \
233 $$($(2)ART_HOST_LIBRARY_PATH)/libjavacore$$(ART_HOST_SHLIB_EXTENSION)
234
Ian Rogersafd9acc2014-06-17 08:21:54 -0700235
236.PHONY: $$(gtest_rule)
Ian Rogers665de8a2014-06-24 21:34:09 -0700237$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_DEPS) $$(gtest_deps)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700238 $(hide) ($$(call ART_TEST_SKIP,$$@) && $$< && $$(call ART_TEST_PASSED,$$@)) \
239 || $$(call ART_TEST_FAILED,$$@)
240
241 ART_TEST_HOST_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += $$(gtest_rule)
242 ART_TEST_HOST_GTEST_RULES += $$(gtest_rule)
243 ART_TEST_HOST_GTEST_$(1)_RULES += $$(gtest_rule)
244
245.PHONY: valgrind-$$(gtest_rule)
Ian Rogers665de8a2014-06-24 21:34:09 -0700246valgrind-$$(gtest_rule): $$(gtest_exe) $$(ART_GTEST_$(1)_DEPS) $$(gtest_deps)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700247 $(hide) $$(call ART_TEST_SKIP,$$@) && \
248 valgrind --leak-check=full --error-exitcode=1 $$< && $$(call ART_TEST_PASSED,$$@) \
249 || $$(call ART_TEST_FAILED,$$@)
250
251 ART_TEST_HOST_VALGRIND_GTEST$$($(2)ART_PHONY_TEST_HOST_SUFFIX)_RULES += valgrind-$$(gtest_rule)
252 ART_TEST_HOST_VALGRIND_GTEST_RULES += valgrind-$$(gtest_rule)
253 ART_TEST_HOST_VALGRIND_GTEST_$(1)_RULES += valgrind-$$(gtest_rule)
254
255 # Clear locally defined variables.
256 valgrind_gtest_rule :=
257 gtest_rule :=
258 gtest_exe :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700259 gtest_deps :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700260endef # define-art-gtest-rule-host
261
262# Define the rules to build and run host and target gtests.
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700263# $(1): target or host
Brian Carlstrom0796af02011-10-12 14:31:45 -0700264# $(2): file name
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800265# $(3): extra C includes
266# $(4): extra shared libraries
Ian Rogersafd9acc2014-06-17 08:21:54 -0700267define define-art-gtest
Brian Carlstrom0796af02011-10-12 14:31:45 -0700268 ifneq ($(1),target)
269 ifneq ($(1),host)
270 $$(error expected target or host for argument 1, received $(1))
271 endif
272 endif
273
274 art_target_or_host := $(1)
275 art_gtest_filename := $(2)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800276 art_gtest_extra_c_includes := $(3)
277 art_gtest_extra_shared_libraries := $(4)
Brian Carlstrom0796af02011-10-12 14:31:45 -0700278
Ian Rogersafd9acc2014-06-17 08:21:54 -0700279 include $$(CLEAR_VARS)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700280 art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700281 LOCAL_MODULE := $$(art_gtest_name)
Brian Carlstrom871599a2012-09-06 13:27:49 -0700282 ifeq ($$(art_target_or_host),target)
283 LOCAL_MODULE_TAGS := tests
284 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700285 LOCAL_CPP_EXTENSION := $$(ART_CPP_EXTENSION)
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800286 LOCAL_SRC_FILES := $$(art_gtest_filename) runtime/common_runtime_test.cc
Ian Rogersafd9acc2014-06-17 08:21:54 -0700287 LOCAL_C_INCLUDES += $$(ART_C_INCLUDES) art/runtime $$(art_gtest_extra_c_includes)
288 LOCAL_SHARED_LIBRARIES += libartd $$(art_gtest_extra_shared_libraries)
Brian Carlstrom4478eb02013-07-14 21:05:57 -0700289
Ian Rogersafd9acc2014-06-17 08:21:54 -0700290 # LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
291 # LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.gtest.mk
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800292
Elliott Hughes0f096762012-01-31 10:32:46 -0800293 # Mac OS linker doesn't understand --export-dynamic.
Ian Rogersafd9acc2014-06-17 08:21:54 -0700294 ifneq ($$(HOST_OS)-$$(art_target_or_host),darwin-host)
Elliott Hughesb264f082012-04-06 17:10:10 -0700295 # Allow jni_compiler_test to find Java_MyClassNatives_bar within itself using dlopen(NULL, ...).
296 LOCAL_LDFLAGS := -Wl,--export-dynamic -Wl,-u,Java_MyClassNatives_bar -Wl,-u,Java_MyClassNatives_sbar
Brian Carlstromcfede662012-01-29 17:25:54 -0800297 endif
Brian Carlstrom0796af02011-10-12 14:31:45 -0700298
Ian Rogersafd9acc2014-06-17 08:21:54 -0700299 LOCAL_CFLAGS := $$(ART_TEST_CFLAGS)
Dan Albert2a0e9542014-05-21 14:55:02 -0700300 include external/libcxx/libcxx.mk
Brian Carlstrom0796af02011-10-12 14:31:45 -0700301 ifeq ($$(art_target_or_host),target)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700302 $$(eval $$(call set-target-local-clang-vars))
303 $$(eval $$(call set-target-local-cflags-vars,debug))
Serban Constantinescu15523732014-04-02 13:18:05 +0100304 LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libz libcutils libvixl
Ian Rogersba0c51f2014-05-16 12:26:00 -0700305 LOCAL_STATIC_LIBRARIES += libgtest_libc++
Ian Rogersafd9acc2014-06-17 08:21:54 -0700306 LOCAL_MODULE_PATH_32 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_32)
307 LOCAL_MODULE_PATH_64 := $$(ART_TARGET_NATIVETEST_OUT)/$$(ART_TARGET_ARCH_64)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700308 LOCAL_MULTILIB := both
Ian Rogersafd9acc2014-06-17 08:21:54 -0700309 include $$(BUILD_EXECUTABLE)
Andreas Gampe5ca4eaa2014-05-29 02:09:33 -0700310
Ian Rogersafd9acc2014-06-17 08:21:54 -0700311 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700312 ifdef TARGET_2ND_ARCH
Ian Rogersafd9acc2014-06-17 08:21:54 -0700313 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),2ND_))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700314 endif
Ian Rogersafd9acc2014-06-17 08:21:54 -0700315 $$(eval $$(call define-art-gtest-rule-target,$$(art_gtest_name),))
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700316
Ian Rogersafd9acc2014-06-17 08:21:54 -0700317 # A rule to run the different architecture versions of the gtest.
318.PHONY: test-art-target-gtest-$$(art_gtest_name)
319test-art-target-gtest-$$(art_gtest_name): $$(ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES)
320 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
321
322 # Clear locally defined variables.
323 ART_TEST_TARGET_GTEST_$$(art_gtest_name)_RULES :=
Brian Carlstrom0796af02011-10-12 14:31:45 -0700324 else # host
Ian Rogersafd9acc2014-06-17 08:21:54 -0700325 LOCAL_CLANG := $$(ART_HOST_CLANG)
326 LOCAL_CFLAGS += $$(ART_HOST_CFLAGS) $$(ART_HOST_DEBUG_CFLAGS)
Elliott Hughes18c07532011-08-18 15:50:51 -0700327 LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
Serban Constantinescu15523732014-04-02 13:18:05 +0100328 LOCAL_STATIC_LIBRARIES += libcutils libvixl
Ian Rogersafd9acc2014-06-17 08:21:54 -0700329 ifneq ($$(WITHOUT_HOST_CLANG),true)
330 # GCC host compiled tests fail with this linked, presumably due to destructors that run.
331 LOCAL_STATIC_LIBRARIES += libgtest_libc++_host
Brian Carlstrom7f2e3da2014-03-25 16:23:56 -0700332 endif
Andrew Hsiehcae10f72014-04-01 11:52:01 +0800333 LOCAL_LDLIBS += -lpthread -ldl
Ian Rogersbd5ea6a2014-04-16 16:34:44 -0700334 LOCAL_IS_HOST_MODULE := true
Ian Rogersafd9acc2014-06-17 08:21:54 -0700335 LOCAL_MULTILIB := both
336 LOCAL_MODULE_STEM_32 := $$(art_gtest_name)32
337 LOCAL_MODULE_STEM_64 := $$(art_gtest_name)64
338 include $$(BUILD_HOST_EXECUTABLE)
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700339
Ian Rogersafd9acc2014-06-17 08:21:54 -0700340 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
341 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
342 ifneq ($$(HOST_PREFER_32_BIT),true)
343 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),2ND_))
344 endif
345 $$(eval $$(call define-art-gtest-rule-host,$$(art_gtest_name),))
Ian Rogersd912e5c2013-11-13 12:40:11 -0800346
Ian Rogersafd9acc2014-06-17 08:21:54 -0700347 # Rules to run the different architecture versions of the gtest.
348.PHONY: test-art-host-gtest-$$(art_gtest_name)
349test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES)
350 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
Ian Rogersd912e5c2013-11-13 12:40:11 -0800351
Ian Rogersafd9acc2014-06-17 08:21:54 -0700352.PHONY: valgrind-test-art-host-gtest-$$(art_gtest_name)
353valgrind-test-art-host-gtest-$$(art_gtest_name): $$(ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES)
354 $$(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
355
356 # Clear locally defined variables.
357 ART_TEST_HOST_GTEST_$$(art_gtest_name)_RULES :=
358 ART_TEST_HOST_VALGRIND_GTEST_$$(art_gtest_name)_RULES :=
359 endif # host_or_target
360
361 # Clear locally defined variables.
362 art_target_or_host :=
363 art_gtest_filename :=
364 art_gtest_extra_c_includes :=
365 art_gtest_extra_shared_libraries :=
366 art_gtest_name :=
367endef # define-art-gtest
Carl Shapiro008e4122011-06-23 17:27:46 -0700368
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700369ifeq ($(ART_BUILD_TARGET),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700370 $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),,)))
371 $(foreach file,$(COMPILER_GTEST_TARGET_SRC_FILES), $(eval $(call define-art-gtest,target,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom4b620ff2011-09-11 01:11:01 -0700372endif
Ian Rogersc5f17732014-06-05 20:48:42 -0700373ifeq ($(ART_BUILD_HOST),true)
Ian Rogersafd9acc2014-06-17 08:21:54 -0700374 $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),,)))
375 $(foreach file,$(COMPILER_GTEST_HOST_SRC_FILES), $(eval $(call define-art-gtest,host,$(file),art/compiler,libartd-compiler)))
Brian Carlstrom07d579f2011-07-27 13:31:51 -0700376endif
Tsu Chiang Chuangec245a42014-05-15 21:16:21 -0700377
378# Used outside the art project to get a list of the current tests
379RUNTIME_TARGET_GTEST_MAKE_TARGETS :=
380$(foreach file, $(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval RUNTIME_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
381COMPILER_TARGET_GTEST_MAKE_TARGETS :=
382$(foreach file, $(COMPILER_GTEST_TARGET_SRC_FILES), $(eval COMPILER_TARGET_GTEST_MAKE_TARGETS += $$(notdir $$(basename $$(file)))))
Ian Rogersafd9acc2014-06-17 08:21:54 -0700383
384# Define all the combinations of host/target, valgrind and suffix such as:
385# test-art-host-gtest or valgrind-test-art-host-gtest64
386# $(1): host or target
387# $(2): HOST or TARGET
388# $(3): valgrind- or undefined
389# $(4): undefined, 32 or 64
390define define-test-art-gtest-combination
391 ifeq ($(1),host)
392 ifneq ($(2),HOST)
393 $$(error argument mismatch $(1) and ($2))
394 endif
395 else
396 ifneq ($(1),target)
397 $$(error found $(1) expected host or target)
398 endif
399 ifneq ($(2),TARGET)
400 $$(error argument mismatch $(1) and ($2))
401 endif
402 endif
403
404 rule_name := $(3)test-art-$(1)-gtest$(4)
405 dependencies := $$(ART_TEST_$(2)_GTEST$(4)_RULES)
406
407.PHONY: $$(rule_name)
408$$(rule_name): $$(dependencies)
409 $(hide) $$(call ART_TEST_PREREQ_FINISHED,$$@)
410
411 # Clear locally defined variables.
412 rule_name :=
413 dependencies :=
414endef # define-test-art-gtest-combination
415
416$(eval $(call define-test-art-gtest-combination,target,TARGET,,))
417$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(ART_PHONY_TEST_TARGET_SUFFIX)))
418ifdef TARGET_2ND_ARCH
419$(eval $(call define-test-art-gtest-combination,target,TARGET,,$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)))
420endif
421$(eval $(call define-test-art-gtest-combination,host,HOST,,))
422$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,))
423$(eval $(call define-test-art-gtest-combination,host,HOST,,$(ART_PHONY_TEST_HOST_SUFFIX)))
424$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(ART_PHONY_TEST_HOST_SUFFIX)))
425ifneq ($(HOST_PREFER_32_BIT),true)
426$(eval $(call define-test-art-gtest-combination,host,HOST,,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
427$(eval $(call define-test-art-gtest-combination,host,HOST,valgrind-,$(2ND_ART_PHONY_TEST_HOST_SUFFIX)))
428endif
429
430# Clear locally defined variables.
431define-art-gtest-rule-target :=
432define-art-gtest-rule-host :=
433define-art-gtest :=
434define-test-art-gtest-combination :=
435RUNTIME_GTEST_COMMON_SRC_FILES :=
436COMPILER_GTEST_COMMON_SRC_FILES :=
437RUNTIME_GTEST_TARGET_SRC_FILES :=
438RUNTIME_GTEST_HOST_SRC_FILES :=
439COMPILER_GTEST_TARGET_SRC_FILES :=
440COMPILER_GTEST_HOST_SRC_FILES :=
441ART_TEST_CFLAGS :=
442ART_TEST_HOST_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
443ART_TEST_HOST_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
444ART_TEST_HOST_GTEST_RULES :=
445ART_TEST_HOST_VALGRIND_GTEST$(ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
446ART_TEST_HOST_VALGRIND_GTEST$(2ND_ART_PHONY_TEST_HOST_SUFFIX)_RULES :=
447ART_TEST_HOST_VALGRIND_GTEST_RULES :=
448ART_TEST_TARGET_GTEST$(ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
449ART_TEST_TARGET_GTEST$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)_RULES :=
450ART_TEST_TARGET_GTEST_RULES :=
451ART_GTEST_class_linker_test_DEPS :=
Ian Rogers665de8a2014-06-24 21:34:09 -0700452ART_GTEST_compiler_driver_test_DEPS :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700453ART_GTEST_dex_file_test_DEPS :=
454ART_GTEST_exception_test_DEPS :=
455ART_GTEST_jni_compiler_test_DEPS :=
456ART_GTEST_jni_internal_test_DEPS :=
457ART_GTEST_object_test_DEPS :=
458ART_GTEST_proxy_test_DEPS :=
459ART_GTEST_reflection_test_DEPS :=
460ART_GTEST_stub_test_DEPS :=
461ART_GTEST_transaction_test_DEPS :=
462$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval ART_GTEST_TEST_$(dir)_DEX :=))
463GTEST_DEX_DIRECTORIES :=
464LOCAL_PATH :=