mirror of
https://github.com/google/googletest.git
synced 2024-12-26 09:31:02 +08:00
Reland 9756ee7cba
Since Fuchsia engineers rarely work within this repo, initialize a lightweight fake @fuchsia_sdk repo rather than distributing the Fuchsia SDK here. Tested locally via `bazel query --[no]enable_bzlmod "deps(set(//googletest/test:gtest_all_test))"` (#4472) PiperOrigin-RevId: 610826859 Change-Id: I7d41b1dbe9e7f133fe535d7337dc5bff5bf97d3a
This commit is contained in:
parent
814ba36338
commit
3b6d48e8d5
17
BUILD.bazel
17
BUILD.bazel
@ -56,6 +56,12 @@ config_setting(
|
||||
constraint_values = ["@platforms//os:openbsd"],
|
||||
)
|
||||
|
||||
# NOTE: Fuchsia is not an officially supported platform.
|
||||
config_setting(
|
||||
name = "fuchsia",
|
||||
constraint_values = ["@platforms//os:fuchsia"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "msvc_compiler",
|
||||
flag_values = {
|
||||
@ -147,6 +153,17 @@ cc_library(
|
||||
"@com_googlesource_code_re2//:re2",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
# `gtest-death-test.cc` has `EXPECT_DEATH` that spawns a process,
|
||||
# expects it to crash and inspects its logs with the given matcher,
|
||||
# so that's why these libraries are needed.
|
||||
# Otherwise, builds targeting Fuchsia would fail to compile.
|
||||
":fuchsia": [
|
||||
"@fuchsia_sdk//pkg/fdio",
|
||||
"@fuchsia_sdk//pkg/syslog",
|
||||
"@fuchsia_sdk//pkg/zx",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
|
@ -53,5 +53,9 @@ bazel_dep(name = "re2",
|
||||
bazel_dep(name = "rules_python",
|
||||
version = "0.29.0")
|
||||
|
||||
|
||||
fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
|
||||
fake_fuchsia_sdk(name = "fuchsia_sdk")
|
||||
|
||||
# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
|
||||
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")
|
||||
|
33
fake_fuchsia_sdk.bzl
Normal file
33
fake_fuchsia_sdk.bzl
Normal file
@ -0,0 +1,33 @@
|
||||
"""Provides a fake @fuchsia_sdk implementation that's used when the real one isn't available.
|
||||
|
||||
This is needed since bazel queries on targets that depend on //:gtest (eg:
|
||||
`bazel query "deps(set(//googletest/test:gtest_all_test))"`) will fail if @fuchsia_sdk is not
|
||||
defined when bazel is evaluating the transitive closure of the query target.
|
||||
|
||||
See https://github.com/google/googletest/issues/4472.
|
||||
"""
|
||||
|
||||
def _fake_fuchsia_sdk_impl(repo_ctx):
|
||||
for stub_target in repo_ctx.attr._stub_build_targets:
|
||||
stub_package = stub_target
|
||||
stub_target_name = stub_target.split("/")[-1]
|
||||
repo_ctx.file("%s/BUILD.bazel" % stub_package, """
|
||||
filegroup(
|
||||
name = "%s",
|
||||
)
|
||||
""" % stub_target_name)
|
||||
|
||||
fake_fuchsia_sdk = repository_rule(
|
||||
doc = "Used to create a fake @fuchsia_sdk repository with stub build targets.",
|
||||
implementation = _fake_fuchsia_sdk_impl,
|
||||
attrs = {
|
||||
"_stub_build_targets": attr.string_list(
|
||||
doc = "The stub build targets to initialize.",
|
||||
default = [
|
||||
"pkg/fdio",
|
||||
"pkg/syslog",
|
||||
"pkg/zx",
|
||||
],
|
||||
),
|
||||
},
|
||||
)
|
@ -1,6 +1,7 @@
|
||||
"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
|
||||
|
||||
def googletest_deps():
|
||||
"""Loads common dependencies needed to use the googletest library."""
|
||||
@ -20,3 +21,8 @@ def googletest_deps():
|
||||
strip_prefix = "abseil-cpp-20240116.0",
|
||||
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz"],
|
||||
)
|
||||
|
||||
if not native.existing_rule("fuchsia_sdk"):
|
||||
fake_fuchsia_sdk(
|
||||
name = "fuchsia_sdk",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user