• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
20LOCAL_PATH := $(call my-dir)
21include $(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
28ifeq ($(BUILD_WITH_ASTL),true)
29libgtest_test_includes := \
30    bionic/libstdc++/include \
31    external/astl/include \
32	$(LOCAL_PATH)/../include \
33	$(LOCAL_PATH)/..
34libgtest_test_static_lib := libgtest_main libgtest libastl
35libgtest_test_shared_lib :=
36libgtest_test_host_static_lib := libgtest_main_host libgtest_host libastl_host
37libgtest_test_host_shared_lib :=
38else
39# BUILD_WITH_ASTL could be undefined, force it to false (for the guard
40# before the test-target call).
41BUILD_WITH_ASTL := false
42libgtest_test_includes := \
43    bionic \
44    external/stlport/stlport \
45	$(LOCAL_PATH)/../include \
46	$(LOCAL_PATH)/..
47libgtest_test_static_lib := libgtest_main libgtest
48libgtest_test_shared_lib := libstlport
49libgtest_test_host_static_lib :=
50libgtest_test_host_shared_lib :=
51endif
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
63define _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)
77endef
78
79ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
80define host-test
81$(call _define-test,$(1),HOST_,-O0,_host)
82endef
83endif
84
85
86# Cannot build simulator with STLport.
87ifneq ($(TARGET_SIMULATOR)-$(BUILD_WITH_ASTL),true-false)
88define target-test
89$(call _define-test,$(1))
90endef
91endif
92
93sources := \
94  gtest-death-test_test.cc \
95  gtest-filepath_test.cc \
96  gtest-linked_ptr_test.cc \
97  gtest-message_test.cc \
98  gtest-options_test.cc \
99  gtest-port_test.cc \
100  gtest_environment_test.cc \
101  gtest_no_test_unittest.cc \
102  gtest_pred_impl_unittest.cc \
103  gtest_repeat_test.cc \
104  gtest-test-part_test.cc \
105  gtest-typed-test_test.cc \
106  gtest-typed-test2_test.cc \
107  gtest_stress_test.cc \
108  gtest_unittest.cc \
109  gtest_prod_test.cc
110
111ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
112$(call host-test, $(sources))
113endif
114
115# Cannot build simulator with STLport.
116ifneq ($(TARGET_SIMULATOR)-$(BUILD_WITH_ASTL),true-false)
117$(call target-test, $(sources))
118endif
119
120
121