Sync gtest/gmock build configs to Chromium's.
Sync to https://crrev.com/921126, minus some WebRTC-specific bits.
This is required to pass GN check in the near future.
This also adds support for gtest_enable_absl_printers.
Change-Id: I950fb2bdb9761c7f79f767718e50e99cbf784512
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85728
Reviewed-by: Hui Yingst <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/build_overrides/build.gni b/build_overrides/build.gni
index 1daa919..e30656a 100644
--- a/build_overrides/build.gni
+++ b/build_overrides/build.gni
@@ -36,6 +36,10 @@
# obtained with gclient sync after setting the environment variable
# FORCE_MAC_TOOLCHAIN].
use_system_xcode = ""
+
+ # Allows googletest to pretty-print various absl types.
+ # Assumes //third_party/abseil-cpp is an available dependency for googletest.
+ gtest_enable_absl_printers = true
}
if (use_system_xcode == "") {
diff --git a/testing/gmock/BUILD.gn b/testing/gmock/BUILD.gn
index d7de2e9..971f733 100644
--- a/testing/gmock/BUILD.gn
+++ b/testing/gmock/BUILD.gn
@@ -6,31 +6,14 @@
# it stabilizes, Chromium code MUST use this target instead of reaching directly
# into //third_party/googletest.
-import("//build_overrides/build.gni")
-
source_set("gmock") {
testonly = true
sources = [
"include/gmock/gmock-actions.h",
- "include/gmock/gmock-generated-function-mockers.h",
"include/gmock/gmock-matchers.h",
"include/gmock/gmock.h",
]
- deps = [ "//third_party/googletest:gmock" ]
-
- # TODO(crbug.com/806952): Depending on gmock_mutant only if build_with_chromium,
- # because gmock_mutant depends on //base which uses C++14. Since gmock is a
- # third_party library used by other projects it should not include C++14 only code.
- if (build_with_chromium) {
- # Allow Chromium targets depending on gmock to #include testing/gmock_mutant.h
- # without triggering a `gn check` error.
- public_deps = [ "//testing:gmock_mutant" ]
- }
-
- public_configs = [
- "//third_party/googletest:gmock_config",
- "//third_party/googletest:gtest_config",
- ]
+ public_deps = [ "//third_party/googletest:gmock" ]
}
# The file/directory layout of Google Test is not yet considered stable. Until
diff --git a/testing/gtest/BUILD.gn b/testing/gtest/BUILD.gn
index f4f95fe..127bc6a 100644
--- a/testing/gtest/BUILD.gn
+++ b/testing/gtest/BUILD.gn
@@ -66,11 +66,7 @@
}
if (is_ios && gtest_include_ios_coverage) {
- sources += [
- "../coverage_util_ios.h",
- "../coverage_util_ios.mm",
- ]
- deps = [ ":ios_enable_coverage" ]
+ public_deps += [ ":ios_coverage_utils" ]
}
}
@@ -83,6 +79,16 @@
}
if (is_ios) {
+ # These headers are needed in some non test targets for iOS code coverage. So
+ # can not be testonly.
+ source_set("ios_coverage_utils") {
+ sources = [
+ "../coverage_util_ios.h",
+ "../coverage_util_ios.mm",
+ ]
+ deps = [ ":ios_enable_coverage" ]
+ }
+
buildflag_header("ios_enable_coverage") {
header = "ios_enable_coverage.h"
flags = [ "IOS_ENABLE_COVERAGE=$use_clang_coverage" ]
diff --git a/third_party/googletest/BUILD.gn b/third_party/googletest/BUILD.gn
index aff9a75..8e35af6 100644
--- a/third_party/googletest/BUILD.gn
+++ b/third_party/googletest/BUILD.gn
@@ -2,8 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build_overrides/build.gni")
+
config("gtest_config") {
- visibility = [ ":*" ] # gmock also shares this config.
+ visibility = [
+ ":*", # gmock also shares this config.
+ ]
defines = [
# Chromium always links googletest statically, so no API qualifier is
@@ -31,6 +35,11 @@
if (is_win) {
cflags = [ "/wd4800" ] # Unused variable warning.
}
+
+ if (gtest_enable_absl_printers) {
+ configs = [ "//third_party/abseil-cpp:absl_include_config" ]
+ defines += [ "GTEST_HAS_ABSL=1" ]
+ }
}
config("gmock_config") {
@@ -39,6 +48,12 @@
"custom",
"src/googlemock/include",
]
+
+ if (is_clang) {
+ # TODO(tikuta): remove this when the issue is fixed.
+ # https://github.com/google/googletest/issues/533
+ cflags = [ "-Wno-inconsistent-missing-override" ]
+ }
}
# Do NOT depend on this directly. Use //testing/gtest instead.
@@ -108,6 +123,20 @@
"custom/gtest/internal/custom/stack_trace_getter.cc",
"custom/gtest/internal/custom/stack_trace_getter.h",
]
+
+ deps = []
+ public_deps = []
+
+ if (is_fuchsia) {
+ deps += [
+ "//third_party/fuchsia-sdk/sdk/pkg/fdio",
+ "//third_party/fuchsia-sdk/sdk/pkg/zx",
+ ]
+ }
+
+ if (gtest_enable_absl_printers) {
+ deps += [ "//third_party/abseil-cpp:absl" ]
+ }
}
# Do NOT depend on this directly. Use //testing/gtest:gtest_main instead.
@@ -127,7 +156,6 @@
"src/googlemock/include/gmock/gmock-cardinalities.h",
"src/googlemock/include/gmock/gmock-function-mocker.h",
"src/googlemock/include/gmock/gmock-matchers.h",
- "src/googlemock/include/gmock/gmock-more-actions.h",
"src/googlemock/include/gmock/gmock-more-matchers.h",
"src/googlemock/include/gmock/gmock-nice-strict.h",
"src/googlemock/include/gmock/gmock-spec-builders.h",