1 # Copyright (C) 2009 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # 15 # 16 17 # Test for gtest. Run using 'runtest'. 18 # The linux build and tests are run under valgrind by 'runtest'. 19 20 LOCAL_PATH := $(call my-dir) 21 include $(CLEAR_VARS) 22 23 # TODO: Refactor these as 1st class build templates as suggested in 24 # review of the original import. 25 26 # Gtest depends on STLPort which does not build on host/simulator. 27 28 ifeq ($(BUILD_WITH_ASTL),true) 29 libgtest_test_includes := \ 30 bionic/libstdc++/include \ 31 external/astl/include \ 32 $(LOCAL_PATH)/../include \ 33 $(LOCAL_PATH)/.. 34 libgtest_test_static_lib := libgtest_main libgtest libastl 35 libgtest_test_shared_lib := 36 libgtest_test_host_static_lib := libgtest_main_host libgtest_host libastl_host 37 libgtest_test_host_shared_lib := 38 else 39 # BUILD_WITH_ASTL could be undefined, force it to false (for the guard 40 # before the test-target call). 41 BUILD_WITH_ASTL := false 42 libgtest_test_includes := \ 43 bionic \ 44 external/stlport/stlport \ 45 $(LOCAL_PATH)/../include \ 46 $(LOCAL_PATH)/.. 47 libgtest_test_static_lib := libgtest_main libgtest 48 libgtest_test_shared_lib := libstlport 49 libgtest_test_host_static_lib := 50 libgtest_test_host_shared_lib := 51 endif 52 53 # $(2) and $(4) must be set or cleared in sync. $(2) is used to 54 # generate the right make target (host vs device). $(4) is used in the 55 # module's name and to have different module names for the host vs 56 # device builds. Finally $(4) is used to pickup the right set of 57 # libraries, typically the host libs have a _host suffix in their 58 # names. 59 # $(1): source list 60 # $(2): "HOST_" or empty 61 # $(3): extra CFLAGS or empty 62 # $(4): "_host" or empty 63 define _define-test 64 $(foreach file,$(1), \ 65 $(eval include $(CLEAR_VARS)) \ 66 $(eval LOCAL_CPP_EXTENSION := .cc) \ 67 $(eval LOCAL_SRC_FILES := $(file)) \ 68 $(eval LOCAL_C_INCLUDES := $(libgtest_test_includes)) \ 69 $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))$(4)) \ 70 $(eval LOCAL_CFLAGS += $(3)) \ 71 $(eval LOCAL_STATIC_LIBRARIES := $(libgtest_test$(4)_static_lib)) \ 72 $(eval LOCAL_SHARED_LIBRARIES := $(libgtest_test$(4)_shared_lib)) \ 73 $(eval LOCAL_MODULE_TAGS := tests) \ 74 $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)) \ 75 $(eval include $(BUILD_$(2)EXECUTABLE)) \ 76 ) 77 endef 78 79 ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true) 80 define host-test 81 $(call _define-test,$(1),HOST_,-O0,_host) 82 endef 83 endif 84 85 define target-test 86 $(call _define-test,$(1)) 87 endef 88 89 sources := \ 90 gtest-death-test_test.cc \ 91 gtest-filepath_test.cc \ 92 gtest-linked_ptr_test.cc \ 93 gtest-message_test.cc \ 94 gtest-options_test.cc \ 95 gtest-port_test.cc \ 96 gtest_environment_test.cc \ 97 gtest_no_test_unittest.cc \ 98 gtest_pred_impl_unittest.cc \ 99 gtest_repeat_test.cc \ 100 gtest-test-part_test.cc \ 101 gtest-typed-test_test.cc \ 102 gtest-typed-test2_test.cc \ 103 gtest_stress_test.cc \ 104 gtest_unittest.cc \ 105 gtest_prod_test.cc 106 107 ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true) 108 $(call host-test, $(sources)) 109 endif 110 111 $(call target-test, $(sources)) 112