From 8d8bd4bec8226a9db6633c1887753ff293ef9e0e Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Fri, 26 Jun 2020 18:32:29 +0000 Subject: [PATCH] Reland "Add gtest absl deps to the absl component." This is a reland of 3a2a481f5c08eaeb0ce57abbfafa90135ded324b This CL moves the declare_arg of gtest_enable_absl_printers to //build_overrides (which is already imported by googletest and abseil-cpp BUILD.gn files) in order to avoid the "undefined identifier" error when build_with_chromium=true. Original change's description: > Add gtest absl deps to the absl component. > > This CL conditionally adds absl/debugging deps to the absl component > if build_with_chromium=false. This will allow downstream projects to > use gtest with absl (for pretty printers and matchers) but it will > remove these dependencies in Chromium to avoid to add static > initializers. > > When static initializers will be removed, the dependency will not be > conditional so Chromium will also be able to set > 'gtest_enable_absl_printers=true'. > > Bug: 1046390 > Change-Id: Ifffea81ba8f7a9412bebc3798e8f79eaff2777d7 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262972 > Commit-Queue: Mirko Bonadei > Auto-Submit: Mirko Bonadei > Reviewed-by: Nico Weber > Cr-Commit-Position: refs/heads/master@{#782889} Bug: 1046390 Change-Id: Id977a6a868b389b4d9924eb3af5a5f5cd0c3f4ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270298 Auto-Submit: Mirko Bonadei Commit-Queue: Nico Weber Reviewed-by: Nico Weber Cr-Commit-Position: refs/heads/master@{#783087} --- build_overrides/build.gni | 4 ++++ third_party/abseil-cpp/BUILD.gn | 12 ++++++++++++ third_party/googletest/BUILD.gn | 5 ----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build_overrides/build.gni b/build_overrides/build.gni index a86048fbbcfee6..2c241cb319f764 100644 --- a/build_overrides/build.gni +++ b/build_overrides/build.gni @@ -26,6 +26,10 @@ declare_args() { # no-op to set up trybot infrastructure. # TODO(crbug/1006769): Switch to perfetto's client library. use_perfetto_client_library = false + + # If true, it assumes that //third_party/abseil-cpp is an available + # dependency for googletest. + gtest_enable_absl_printers = false } # Allows different projects to specify their own suppressions and blacklist diff --git a/third_party/abseil-cpp/BUILD.gn b/third_party/abseil-cpp/BUILD.gn index b96d354205f4e0..a674df1f26ccc0 100644 --- a/third_party/abseil-cpp/BUILD.gn +++ b/third_party/abseil-cpp/BUILD.gn @@ -7,6 +7,7 @@ # without these options will be part of the same program. import("//build/toolchain/toolchain.gni") +import("//build_overrides/build.gni") import("//testing/test.gni") config("absl_component_build") { @@ -62,6 +63,17 @@ component("absl") { "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] + if (!build_with_chromium && gtest_enable_absl_printers) { + # The following dependencies contain static initializers which are + # banned by Chromium. They are needed by gtest when the GN arg + # gtest_enable_absl_printers is set to true (this is never done by + # Chromium). + public_deps += [ + "//third_party/abseil-cpp/absl/debugging:failure_signal_handler", + "//third_party/abseil-cpp/absl/debugging:stacktrace", + "//third_party/abseil-cpp/absl/debugging:symbolize", + ] + } } group("default") { diff --git a/third_party/googletest/BUILD.gn b/third_party/googletest/BUILD.gn index dbcf8da7199945..66cbafc8deffaa 100644 --- a/third_party/googletest/BUILD.gn +++ b/third_party/googletest/BUILD.gn @@ -4,11 +4,6 @@ import("//build_overrides/build.gni") -declare_args() { - # If true, it assumes that //third_party/abseil-cpp is an available dependency. - gtest_enable_absl_printers = false -} - config("gtest_config") { visibility = [ ":*" ] # gmock also shares this config.