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 31libgtest_target_includes := \ 32 $(LOCAL_PATH)/.. \ 33 $(LOCAL_PATH)/../include \ 34 35libgtest_host_includes := \ 36 $(LOCAL_PATH)/.. \ 37 $(LOCAL_PATH)/../include \ 38 39libgtest_export_include_dirs := \ 40 $(LOCAL_PATH)/../include 41 42libgtest_cflags := \ 43 -Wno-missing-field-initializers \ 44 45####################################################################### 46# gtest lib for the NDK 47 48include $(CLEAR_VARS) 49LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 50 51LOCAL_SDK_VERSION := 9 52LOCAL_NDK_STL_VARIANT := stlport_static 53 54LOCAL_CPP_EXTENSION := .cc 55LOCAL_SRC_FILES := gtest-all.cc 56LOCAL_C_INCLUDES := $(libgtest_target_includes) 57LOCAL_CPPFLAGS := -std=gnu++98 58LOCAL_CFLAGS += $(libgtest_cflags) 59LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 60LOCAL_MODULE := libgtest_ndk 61 62include $(BUILD_STATIC_LIBRARY) 63 64####################################################################### 65# gtest_main for the NDK 66 67include $(CLEAR_VARS) 68LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 69 70LOCAL_SDK_VERSION := 9 71LOCAL_NDK_STL_VARIANT := stlport_static 72 73LOCAL_CPP_EXTENSION := .cc 74LOCAL_SRC_FILES := gtest_main.cc 75LOCAL_C_INCLUDES := $(libgtest_target_includes) 76LOCAL_CPPFLAGS := -std=gnu++98 77LOCAL_CFLAGS += $(libgtest_cflags) 78LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 79LOCAL_MODULE := libgtest_main_ndk 80 81include $(BUILD_STATIC_LIBRARY) 82 83####################################################################### 84# gtest lib host 85 86include $(CLEAR_VARS) 87 88LOCAL_CPP_EXTENSION := .cc 89LOCAL_SRC_FILES := gtest-all.cc 90LOCAL_C_INCLUDES := $(libgtest_host_includes) 91LOCAL_CFLAGS += $(libgtest_cflags) 92LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 93LOCAL_MODULE := libgtest_host 94LOCAL_MODULE_HOST_OS := darwin linux windows 95LOCAL_MULTILIB := both 96LOCAL_SANITIZE := never 97LOCAL_RTTI_FLAG := -frtti 98 99include $(BUILD_HOST_STATIC_LIBRARY) 100 101####################################################################### 102# gtest_main lib host 103 104include $(CLEAR_VARS) 105 106LOCAL_CPP_EXTENSION := .cc 107LOCAL_SRC_FILES := gtest_main.cc 108LOCAL_C_INCLUDES := $(libgtest_host_includes) 109LOCAL_CFLAGS += $(libgtest_cflags) 110LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 111LOCAL_MODULE := libgtest_main_host 112LOCAL_MODULE_HOST_OS := darwin linux windows 113LOCAL_MULTILIB := both 114LOCAL_SANITIZE := never 115 116include $(BUILD_HOST_STATIC_LIBRARY) 117 118####################################################################### 119# Don't build for unbundled branches 120ifeq (,$(TARGET_BUILD_APPS)) 121# gtest lib target 122 123include $(CLEAR_VARS) 124 125LOCAL_CLANG := true 126LOCAL_CPP_EXTENSION := .cc 127LOCAL_SRC_FILES := gtest-all.cc 128LOCAL_C_INCLUDES := $(libgtest_target_includes) 129LOCAL_CFLAGS += $(libgtest_cflags) 130LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 131LOCAL_MODULE := libgtest 132LOCAL_SANITIZE := never 133LOCAL_RTTI_FLAG := -frtti 134 135include $(BUILD_STATIC_LIBRARY) 136 137####################################################################### 138# gtest_main lib target 139 140include $(CLEAR_VARS) 141 142LOCAL_CLANG := true 143LOCAL_CPP_EXTENSION := .cc 144LOCAL_SRC_FILES := gtest_main.cc 145LOCAL_C_INCLUDES := $(libgtest_target_includes) 146LOCAL_CFLAGS += $(libgtest_cflags) 147LOCAL_EXPORT_C_INCLUDE_DIRS := $(libgtest_export_include_dirs) 148LOCAL_MODULE := libgtest_main 149LOCAL_SANITIZE := never 150 151include $(BUILD_STATIC_LIBRARY) 152endif 153