Android.mk revision cda9ca55683d97e2d215e4a786a865e2b41bc26f
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# Gtest builds 2 libraries: libgtest and libgtest_main. libgtest
18# contains most of the code (assertions...) and libgtest_main just
19# provide a common main to run the test (ie if you link against
20# libgtest_main you won't/should not provide a main() entry point.
21#
22# We build these 2 libraries for the target device and for the host if
23# it is running linux and using ASTL.
24#
25
26# TODO: The targets below have some redundancy. Check if we cannot
27# condense them using function(s) for the common code.
28
29LOCAL_PATH := $(call my-dir)
30
31ifeq ($(BUILD_WITH_ASTL),true)
32libgtest_includes:= \
33    bionic/libstdc++/include \
34    external/astl/include \
35    $(LOCAL_PATH)/.. \
36    $(LOCAL_PATH)/../include
37else
38# BUILD_WITH_ASTL could be undefined, force it to false.
39BUILD_WITH_ASTL := false
40libgtest_includes := \
41    bionic \
42    external/stlport/stlport \
43    $(LOCAL_PATH)/.. \
44    $(LOCAL_PATH)/../include
45endif
46
47# Gtest depends on STLPort which does not build on host/simulator.
48ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
49
50#######################################################################
51# gtest lib host
52
53include $(CLEAR_VARS)
54
55LOCAL_CPP_EXTENSION := .cc
56
57LOCAL_SRC_FILES := gtest-all.cc
58
59LOCAL_C_INCLUDES := $(libgtest_includes)
60
61LOCAL_CFLAGS += -O0
62
63LOCAL_MODULE := libgtest_host
64LOCAL_MODULE_TAGS := eng
65
66include $(BUILD_HOST_STATIC_LIBRARY)
67
68#######################################################################
69# gtest_main lib host
70
71include $(CLEAR_VARS)
72
73LOCAL_CPP_EXTENSION := .cc
74
75LOCAL_SRC_FILES := gtest_main.cc
76
77LOCAL_C_INCLUDES := $(libgtest_includes)
78
79LOCAL_CFLAGS += -O0
80
81LOCAL_STATIC_LIBRARIES := libgtest
82
83LOCAL_MODULE := libgtest_main_host
84LOCAL_MODULE_TAGS := eng
85
86include $(BUILD_HOST_STATIC_LIBRARY)
87
88endif # HOST_OS == linux
89
90#######################################################################
91# gtest lib target
92
93include $(CLEAR_VARS)
94
95LOCAL_CPP_EXTENSION := .cc
96
97LOCAL_SRC_FILES := gtest-all.cc
98
99LOCAL_C_INCLUDES := $(libgtest_includes)
100
101LOCAL_MODULE := libgtest
102LOCAL_MODULE_TAGS := eng
103
104include $(BUILD_STATIC_LIBRARY)
105
106#######################################################################
107# gtest_main lib target
108
109include $(CLEAR_VARS)
110
111LOCAL_CPP_EXTENSION := .cc
112
113LOCAL_SRC_FILES := gtest_main.cc
114
115LOCAL_C_INCLUDES := $(libgtest_includes)
116
117LOCAL_STATIC_LIBRARIES := libgtest
118
119LOCAL_MODULE := libgtest_main
120LOCAL_MODULE_TAGS := eng
121
122include $(BUILD_STATIC_LIBRARY)
123