Skip to content

Commit

Permalink
Ship abseil and re2 as required by googletest
Browse files Browse the repository at this point in the history
zcbenz committed Dec 19, 2024

Verified

This commit was signed with the committer’s verified signature.
lucacome Luca Comellini
1 parent 4c827fd commit cd5d502
Showing 24 changed files with 820 additions and 37 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -16,3 +16,9 @@
[submodule "third_party/libunwind/src"]
path = third_party/libunwind/src
url = https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp
[submodule "third_party/re2/src"]
path = third_party/re2/src
url = https://github.com/google/re2
4 changes: 3 additions & 1 deletion scripts/create_dist.js
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ const files =
searchFiles('tools/cfi')).concat(
searchFiles('tools/clang/scripts')).concat(
searchFiles('tools/win')).concat(
searchFiles('third_party/abseil-cpp')).concat(
searchFiles('third_party/catapult')).concat(
searchFiles('third_party/depot_tools')).concat(
searchFiles('third_party/googletest')).concat(
@@ -44,7 +45,8 @@ const files =
searchFiles('third_party/libc++abi/src/src')).concat(
searchFiles('third_party/libc++abi/src/include')).concat(
searchFiles('third_party/libunwind/src/src')).concat(
searchFiles('third_party/libunwind/src/include'))
searchFiles('third_party/libunwind/src/include')).concat(
searchFiles('third_party/re2'))
addFileToZip(gnzip, 'buildtools/deps_revisions.gni', '.')
addFileToZip(gnzip, 'buildtools/third_party/eu-strip/bin/eu-strip', '.')
addFileToZip(gnzip, 'buildtools/third_party/libc++/__assertion_handler', '.')
2 changes: 1 addition & 1 deletion testing
Submodule testing updated from ea5668 to 0305a8
1 change: 1 addition & 0 deletions third_party/abseil-cpp
Submodule abseil-cpp added at 79b08c
136 changes: 102 additions & 34 deletions third_party/googletest/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Copyright 2014 The Chromium Authors
# 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") {
# PATCH(build-gn): Causes problems when using gmock.
# visibility = [ ":*" ] # gmock also shares this config.
# webrtc wants to push this config without a public_dep chain
# TODO(crbug.com/1249254): figure out what to do with this
visibility = [
":*", # gmock also shares this config.
"//test:*", # webrts standalone setup
"//third_party/webrtc/test:*",
]

defines = [
# Chromium always links googletest statically, so no API qualifier is
@@ -15,15 +22,34 @@ config("gtest_config") {
# In order to allow regex matches in gtest to be shared between Windows
# and other systems, we tell gtest to always use its internal engine.
"GTEST_HAS_POSIX_RE=0",

# Enables C++11 features.
"GTEST_LANG_CXX11=1",

# Prevents gtest from including both <tr1/tuple> and <tuple>.
"GTEST_HAS_TR1_TUPLE=0",

# Use Abseil, but without flags support: Abseil flags uses the
# `FastTypeId<T>()` pattern internally, which is known to be broken in
# subtle ways in the component build.
"GTEST_HAS_ABSL",
"GTEST_NO_ABSL_FLAGS",
]

# Gtest headers need to be able to find themselves.
include_dirs = [ "src/googletest/include" ]
include_dirs = [
"custom",
"src/googletest/include",
]

if (is_win) {
cflags = [ "/wd4800" ] # Unused variable warning.
}

configs = [
"//third_party/abseil-cpp:absl_include_config",
"//third_party/re2:re2_config",
]
}

config("gmock_config") {
@@ -32,14 +58,32 @@ config("gmock_config") {
"custom",
"src/googlemock/include",
]

if (is_clang) {
# TODO(crbug.com/40616204): remove this when we migrated to new MOCK_METHOD
# macro.
# ref: https://google.github.io/googletest/gmock_cook_book.html#old-style-mock_methodn-macros
cflags = [ "-Wno-inconsistent-missing-override" ]
}
}

# Do NOT depend on this directly. Use //testing/gtest instead.
# See README.chromium for details.
source_set("gtest") {
testonly = true
sources = [
"custom/gtest/internal/custom/gtest.h",
"custom/gtest/internal/custom/stack_trace_getter.cc",
"custom/gtest/internal/custom/stack_trace_getter.h",

# TODO(crbug.com/1009553): Remove this wrapper and custom temp dir
# after plumbing a workable temporary path into googletest on Android.
"custom/gtest/internal/custom/chrome_custom_temp_dir.cc",
"custom/gtest/internal/custom/chrome_custom_temp_dir.h",
"custom/gtest/internal/custom/gtest_port_wrapper.cc",
"src/googletest/include/gtest/gtest-assertion-result.h",
"src/googletest/include/gtest/gtest-death-test.h",
"src/googletest/include/gtest/gtest-matchers.h",
"src/googletest/include/gtest/gtest-message.h",
"src/googletest/include/gtest/gtest-param-test.h",
"src/googletest/include/gtest/gtest-printers.h",
@@ -48,22 +92,31 @@ source_set("gtest") {
"src/googletest/include/gtest/gtest-typed-test.h",
"src/googletest/include/gtest/gtest.h",
"src/googletest/include/gtest/gtest_pred_impl.h",
"src/googletest/include/gtest/gtest_prod.h",

#"src/googletest/include/gtest/internal/custom/gtest.h", # Superseded.
"src/googletest/include/gtest/internal/custom/gtest-port.h",
"src/googletest/include/gtest/internal/custom/gtest-printers.h",
"src/googletest/include/gtest/internal/gtest-death-test-internal.h",
"src/googletest/include/gtest/internal/gtest-filepath.h",
"src/googletest/include/gtest/internal/gtest-internal.h",
"src/googletest/include/gtest/internal/gtest-linked_ptr.h",
"src/googletest/include/gtest/internal/gtest-param-util-generated.h",
"src/googletest/include/gtest/internal/gtest-param-util.h",
"src/googletest/include/gtest/internal/gtest-port-arch.h",
"src/googletest/include/gtest/internal/gtest-port.h",
"src/googletest/include/gtest/internal/gtest-string.h",
"src/googletest/include/gtest/internal/gtest-tuple.h",
"src/googletest/include/gtest/internal/gtest-type-util.h",

#"src/googletest/src/gtest-all.cc", # Not needed by our build.
"src/googletest/src/gtest-assertion-result.cc",
"src/googletest/src/gtest-death-test.cc",
"src/googletest/src/gtest-filepath.cc",
"src/googletest/src/gtest-internal-inl.h",
"src/googletest/src/gtest-port.cc",
"src/googletest/src/gtest-matchers.cc",

# gtest_port_wrapper.cc is used instead of gtest-port.cc.
# TODO(crbug.com/1009553): Re-enable this file after plumbing a workable
# temporary path into googletest on Android.
#"src/googletest/src/gtest-port.cc",
"src/googletest/src/gtest-printers.cc",
"src/googletest/src/gtest-test-part.cc",
"src/googletest/src/gtest-typed-test.cc",
@@ -73,44 +126,62 @@ source_set("gtest") {
# Some files include "src/gtest-internal-inl.h".
include_dirs = [ "src/googletest" ]

all_dependent_configs = [ ":gtest_config" ]
public_configs = [ ":gtest_config" ]

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]

defines = []

# googletest only needs `absl`, but this makes gn check happier.
deps = [ "//third_party/abseil-cpp:absl_full" ]
public_deps = [ "//third_party/re2" ]
if (is_nacl || !build_with_chromium) {
defines += [ "GTEST_DISABLE_PRINT_STACK_TRACE" ]
sources -= [
"custom/gtest/internal/custom/stack_trace_getter.cc",
"custom/gtest/internal/custom/stack_trace_getter.h",
]
} else {
deps += [ "//base" ]
}

if (is_fuchsia) {
deps += [
"//third_party/fuchsia-sdk/sdk/pkg/fdio",
"//third_party/fuchsia-sdk/sdk/pkg/zx",
]
}
}

# Do NOT depend on this directly. Use //testing/gtest:gtest_main instead.
# See README.chromium for details.
source_set("gtest_main") {
testonly = true
sources = [
"src/googletest/src/gtest_main.cc",
]
deps = [
":gtest",
]
sources = [ "src/googletest/src/gtest_main.cc" ]
deps = [ ":gtest" ]
}

# Do NOT depend on this directly. Use //testing/gmock:gmock_main instead.
# Do NOT depend on this directly. Use //testing/gmock instead.
# See README.chromium for details.
source_set("gmock") {
testonly = true
sources = [
"src/googlemock/include/gmock/gmock-actions.h",
"src/googlemock/include/gmock/gmock-cardinalities.h",
"src/googlemock/include/gmock/gmock-generated-actions.h",
"src/googlemock/include/gmock/gmock-generated-function-mockers.h",
"src/googlemock/include/gmock/gmock-generated-matchers.h",
"src/googlemock/include/gmock/gmock-generated-nice-strict.h",
"src/googlemock/include/gmock/gmock-function-mocker.h",
"src/googlemock/include/gmock/gmock-matchers.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",
"src/googlemock/include/gmock/gmock.h",
"src/googlemock/include/gmock/internal/gmock-generated-internal-utils.h",

#"src/googlemock/include/gmock/internal/custom/gmock-port.h", # Superseded.
"src/googlemock/include/gmock/internal/custom/gmock-generated-actions.h",
"src/googlemock/include/gmock/internal/custom/gmock-matchers.h",
"src/googlemock/include/gmock/internal/gmock-internal-utils.h",
"src/googlemock/include/gmock/internal/gmock-port.h",

# gmock helpers.
"custom/gmock/internal/custom/gmock-port.h",
"src/googlemock/include/gmock/internal/gmock-pp.h",

#"src/googlemock/src/gmock-all.cc", # Not needed by our build.
"src/googlemock/src/gmock-cardinalities.cc",
@@ -120,20 +191,17 @@ source_set("gmock") {
"src/googlemock/src/gmock.cc",
]

public_configs = [
":gmock_config",
":gtest_config",
]
# googlemock only needs `absl`, but this makes gn check happier.
deps = [ "//third_party/abseil-cpp:absl_full" ]

public_deps = [ ":gtest" ]
public_configs = [ ":gmock_config" ]
}

# Do NOT depend on this directly. Use //testing/gmock:gmock_main instead.
# See README.chromium for details.
static_library("gmock_main") {
testonly = true
sources = [
"src/googlemock/src/gmock_main.cc",
]
deps = [
":gmock",
]
sources = [ "src/googlemock/src/gmock_main.cc" ]
deps = [ ":gmock" ]
}
18 changes: 18 additions & 0 deletions third_party/googletest/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is a dummy used so that non-Chromium clients can specify
# recursive DEPS. Otherwise the clients would need to nest DEPS inside
# each other. Nested DEPS are not supported by gclient.
#
# Clients *must* specify googletest_revision when using this DEPS file.

use_relative_paths = True

vars = {
'chromium_git': 'https://chromium.googlesource.com',

# We must specify a dummy variable here for recursedeps to work.
'googletest_revision': 'master',
}

deps = {
'src': '{chromium_git}/external/github.com/google/googletest.git@{googletest_revision}'
}
6 changes: 6 additions & 0 deletions third_party/googletest/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
monorail: {
component: "Test>gTest"
}
buganizer_public: {
component_id: 1457072
}
1 change: 1 addition & 0 deletions third_party/googletest/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file://testing/gtest/OWNERS
Loading

0 comments on commit cd5d502

Please sign in to comment.