1# Copyright 2014 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build_overrides/build.gni") 6 7config("gtest_config") { 8 # webrtc wants to push this config without a public_dep chain 9 # TODO(crbug.com/1249254): figure out what to do with this 10 visibility = [ 11 ":*", # gmock also shares this config. 12 "//test:*", # webrts standalone setup 13 "//third_party/webrtc/test:*", 14 ] 15 16 defines = [ 17 # Chromium always links googletest statically, so no API qualifier is 18 # necessary. The definition in gtest-port.h at the time of this writing 19 # causes crashes in content_browsertests. 20 "GTEST_API_=", 21 22 # In order to allow regex matches in gtest to be shared between Windows 23 # and other systems, we tell gtest to always use its internal engine. 24 "GTEST_HAS_POSIX_RE=0", 25 26 # Enables C++11 features. 27 "GTEST_LANG_CXX11=1", 28 29 # Prevents gtest from including both <tr1/tuple> and <tuple>. 30 "GTEST_HAS_TR1_TUPLE=0", 31 32 # Use Abseil, but without flags support: Abseil flags uses the 33 # `FastTypeId<T>()` pattern internally, which is known to be broken in 34 # subtle ways in the component build. 35 "GTEST_HAS_ABSL", 36 "GTEST_NO_ABSL_FLAGS", 37 ] 38 39 # Gtest headers need to be able to find themselves. 40 include_dirs = [ 41 "custom", 42 "src/googletest/include", 43 ] 44 45 if (is_win) { 46 cflags = [ "/wd4800" ] # Unused variable warning. 47 } 48 49 configs = [ 50 "//third_party/abseil-cpp:absl_include_config", 51 "//third_party/re2:re2_config", 52 ] 53} 54 55config("gmock_config") { 56 # Gmock headers need to be able to find themselves. 57 include_dirs = [ 58 "custom", 59 "src/googlemock/include", 60 ] 61 62 if (is_clang) { 63 # TODO(tikuta): remove this when the issue is fixed. 64 # https://github.com/google/googletest/issues/533 65 cflags = [ "-Wno-inconsistent-missing-override" ] 66 } 67} 68 69# Do NOT depend on this directly. Use //testing/gtest instead. 70# See README.chromium for details. 71source_set("gtest") { 72 testonly = true 73 sources = [ 74 "custom/gtest/internal/custom/gtest.h", 75 "custom/gtest/internal/custom/stack_trace_getter.cc", 76 "custom/gtest/internal/custom/stack_trace_getter.h", 77 78 # TODO(crbug.com/1009553): Remove this wrapper and custom temp dir 79 # after plumbing a workable temporary path into googletest on Android. 80 "custom/gtest/internal/custom/chrome_custom_temp_dir.cc", 81 "custom/gtest/internal/custom/chrome_custom_temp_dir.h", 82 "custom/gtest/internal/custom/gtest_port_wrapper.cc", 83 "src/googletest/include/gtest/gtest-assertion-result.h", 84 "src/googletest/include/gtest/gtest-death-test.h", 85 "src/googletest/include/gtest/gtest-matchers.h", 86 "src/googletest/include/gtest/gtest-message.h", 87 "src/googletest/include/gtest/gtest-param-test.h", 88 "src/googletest/include/gtest/gtest-printers.h", 89 "src/googletest/include/gtest/gtest-spi.h", 90 "src/googletest/include/gtest/gtest-test-part.h", 91 "src/googletest/include/gtest/gtest-typed-test.h", 92 "src/googletest/include/gtest/gtest.h", 93 "src/googletest/include/gtest/gtest_pred_impl.h", 94 "src/googletest/include/gtest/gtest_prod.h", 95 96 #"src/googletest/include/gtest/internal/custom/gtest.h", # Superseded. 97 "src/googletest/include/gtest/internal/custom/gtest-port.h", 98 "src/googletest/include/gtest/internal/custom/gtest-printers.h", 99 "src/googletest/include/gtest/internal/gtest-death-test-internal.h", 100 "src/googletest/include/gtest/internal/gtest-filepath.h", 101 "src/googletest/include/gtest/internal/gtest-internal.h", 102 "src/googletest/include/gtest/internal/gtest-param-util.h", 103 "src/googletest/include/gtest/internal/gtest-port-arch.h", 104 "src/googletest/include/gtest/internal/gtest-port.h", 105 "src/googletest/include/gtest/internal/gtest-string.h", 106 "src/googletest/include/gtest/internal/gtest-type-util.h", 107 108 #"src/googletest/src/gtest-all.cc", # Not needed by our build. 109 "src/googletest/src/gtest-assertion-result.cc", 110 "src/googletest/src/gtest-death-test.cc", 111 "src/googletest/src/gtest-filepath.cc", 112 "src/googletest/src/gtest-internal-inl.h", 113 "src/googletest/src/gtest-matchers.cc", 114 115 # gtest_port_wrapper.cc is used instead of gtest-port.cc. 116 # TODO(crbug.com/1009553): Re-enable this file after plumbing a workable 117 # temporary path into googletest on Android. 118 #"src/googletest/src/gtest-port.cc", 119 "src/googletest/src/gtest-printers.cc", 120 "src/googletest/src/gtest-test-part.cc", 121 "src/googletest/src/gtest-typed-test.cc", 122 "src/googletest/src/gtest.cc", 123 ] 124 125 # Some files include "src/gtest-internal-inl.h". 126 include_dirs = [ "src/googletest" ] 127 128 public_configs = [ ":gtest_config" ] 129 130 configs -= [ "//build/config/compiler:chromium_code" ] 131 configs += [ "//build/config/compiler:no_chromium_code" ] 132 133 defines = [] 134 135 # googletest only needs `absl`, but this makes gn check happier. 136 deps = [ "//third_party/abseil-cpp:absl_full" ] 137 public_deps = [ "//third_party/re2" ] 138 if (is_nacl || !build_with_chromium) { 139 defines += [ "GTEST_DISABLE_PRINT_STACK_TRACE" ] 140 sources -= [ 141 "custom/gtest/internal/custom/stack_trace_getter.cc", 142 "custom/gtest/internal/custom/stack_trace_getter.h", 143 ] 144 } else { 145 deps += [ "//base" ] 146 } 147 148 if (is_fuchsia) { 149 deps += [ 150 "//third_party/fuchsia-sdk/sdk/pkg/fdio", 151 "//third_party/fuchsia-sdk/sdk/pkg/zx", 152 ] 153 } 154} 155 156# Do NOT depend on this directly. Use //testing/gtest:gtest_main instead. 157# See README.chromium for details. 158source_set("gtest_main") { 159 testonly = true 160 sources = [ "src/googletest/src/gtest_main.cc" ] 161 deps = [ ":gtest" ] 162} 163 164# Do NOT depend on this directly. Use //testing/gmock instead. 165# See README.chromium for details. 166source_set("gmock") { 167 testonly = true 168 sources = [ 169 "src/googlemock/include/gmock/gmock-actions.h", 170 "src/googlemock/include/gmock/gmock-cardinalities.h", 171 "src/googlemock/include/gmock/gmock-function-mocker.h", 172 "src/googlemock/include/gmock/gmock-matchers.h", 173 "src/googlemock/include/gmock/gmock-more-matchers.h", 174 "src/googlemock/include/gmock/gmock-nice-strict.h", 175 "src/googlemock/include/gmock/gmock-spec-builders.h", 176 "src/googlemock/include/gmock/gmock.h", 177 178 #"src/googlemock/include/gmock/internal/custom/gmock-port.h", # Superseded. 179 "src/googlemock/include/gmock/internal/custom/gmock-generated-actions.h", 180 "src/googlemock/include/gmock/internal/custom/gmock-matchers.h", 181 "src/googlemock/include/gmock/internal/gmock-internal-utils.h", 182 "src/googlemock/include/gmock/internal/gmock-port.h", 183 "src/googlemock/include/gmock/internal/gmock-pp.h", 184 185 #"src/googlemock/src/gmock-all.cc", # Not needed by our build. 186 "src/googlemock/src/gmock-cardinalities.cc", 187 "src/googlemock/src/gmock-internal-utils.cc", 188 "src/googlemock/src/gmock-matchers.cc", 189 "src/googlemock/src/gmock-spec-builders.cc", 190 "src/googlemock/src/gmock.cc", 191 ] 192 193 # googlemock only needs `absl`, but this makes gn check happier. 194 deps = [ "//third_party/abseil-cpp:absl_full" ] 195 196 public_deps = [ ":gtest" ] 197 public_configs = [ ":gmock_config" ] 198} 199 200# Do NOT depend on this directly. Use //testing/gmock:gmock_main instead. 201# See README.chromium for details. 202static_library("gmock_main") { 203 testonly = true 204 sources = [ "src/googlemock/src/gmock_main.cc" ] 205 deps = [ ":gmock" ] 206} 207