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 29cc_defaults { 30 name: "libgtest_defaults", 31 local_include_dirs: [ 32 "include", 33 ], 34 export_include_dirs: [ 35 "include", 36 ], 37 cflags: ["-Wno-missing-field-initializers"], 38 cppflags: ["-std=gnu++98"], 39 target: { 40 android: { 41 product_variables: { 42 unbundled_build: { 43 // Don't build for unbundled branches 44 enabled: false, 45 }, 46 }, 47 }, 48 }, 49} 50 51cc_defaults { 52 name: "libgtest_host_defaults", 53 54 target: { 55 windows: { 56 enabled: true, 57 }, 58 }, 59} 60 61//###################################################################### 62// gtest lib for the NDK 63 64cc_library_static { 65 name: "libgtest_ndk", 66 defaults: ["libgtest_defaults"], 67 68 sdk_version: "9", 69 stl: "stlport_static", 70 71 srcs: ["src/gtest-all.cc"], 72} 73 74//###################################################################### 75// gtest_main for the NDK 76 77cc_library_static { 78 name: "libgtest_main_ndk", 79 defaults: ["libgtest_defaults"], 80 81 sdk_version: "9", 82 stl: "stlport_static", 83 84 srcs: ["src/gtest_main.cc"], 85} 86 87 88 89//###################################################################### 90// gtest lib 91 92cc_library_static { 93 name: "libgtest", 94 defaults: ["libgtest_defaults", "libgtest_host_defaults"], 95 96 host_supported: true, 97 clang: true, 98 99 srcs: ["src/gtest-all.cc"], 100 101 sanitize: ["never"], 102 rtti: true, 103} 104 105//###################################################################### 106// gtest_main lib 107 108cc_library_static { 109 name: "libgtest_main", 110 defaults: ["libgtest_defaults", "libgtest_host_defaults"], 111 112 host_supported: true, 113 clang: true, 114 115 srcs: ["src/gtest_main.cc"], 116 117 sanitize: ["never"], 118} 119 120// Legacy libraries for makefiles that refer to libgtest_host 121 122cc_library_host_static { 123 name: "libgtest_host", 124 whole_static_libs: ["libgtest"], 125 defaults: ["libgtest_host_defaults"], 126} 127 128cc_library_host_static { 129 name: "libgtest_main_host", 130 whole_static_libs: ["libgtest_main"], 131 defaults: ["libgtest_host_defaults"], 132} 133 134 135// Test for gtest. Run using 'runtest'. 136// The linux build and tests are run under valgrind by 'runtest'. 137 138cc_test { 139 name: "gtest", 140 cflags: ["-Wno-empty-body"], 141 local_include_dirs: ["include"], 142 host_supported: true, 143 target: { 144 android: { 145 product_variables: { 146 unbundled_build: { 147 // Don't build for unbundled branches 148 enabled: false, 149 }, 150 }, 151 }, 152 }, 153 test_per_src: true, 154 srcs: [ 155 "test/gtest_all_test.cc", 156 "test/gtest-death-test_test.cc", 157 "test/gtest_environment_test.cc", 158 "test/gtest-listener_test.cc", 159 "test/gtest_main_unittest.cc", 160 "test/gtest_no_test_unittest.cc", 161 "test/gtest-param-test2_test.cc", 162 "test/gtest_premature_exit_test.cc", 163 "test/gtest_repeat_test.cc", 164 "test/gtest_sole_header_test.cc", 165 "test/gtest_stress_test.cc", 166 "test/gtest-unittest-api_test.cc", 167 168 // We don't have exceptions. 169 //"test/gtest-death-test_ex_test.cc", 170 //"test/gtest_throw_on_failure_ex_test.cc", 171 // We don't have tr1::tuple. 172 //"test/gtest-tuple_test.cc", 173 // These don't build. 174 //"test/gtest-param-test_test.cc", 175 //"test/gtest-printers_test.cc", 176 ], 177} 178 179