File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ config_setting(
5656 constraint_values = ["@platforms//os:openbsd" ],
5757)
5858
59+ # NOTE: Fuchsia is not an officially supported platform.
60+ config_setting (
61+ name = "fuchsia" ,
62+ constraint_values = ["@platforms//os:fuchsia" ],
63+ )
64+
5965config_setting (
6066 name = "msvc_compiler" ,
6167 flag_values = {
@@ -147,6 +153,17 @@ cc_library(
147153 "@com_googlesource_code_re2//:re2" ,
148154 ],
149155 "//conditions:default" : [],
156+ }) + select ({
157+ # `gtest-death-test.cc` has `EXPECT_DEATH` that spawns a process,
158+ # expects it to crash and inspects its logs with the given matcher,
159+ # so that's why these libraries are needed.
160+ # Otherwise, builds targeting Fuchsia would fail to compile.
161+ ":fuchsia" : [
162+ "@fuchsia_sdk//pkg/fdio" ,
163+ "@fuchsia_sdk//pkg/syslog" ,
164+ "@fuchsia_sdk//pkg/zx" ,
165+ ],
166+ "//conditions:default" : [],
150167 }),
151168)
152169
Original file line number Diff line number Diff line change @@ -53,5 +53,9 @@ bazel_dep(name = "re2",
5353bazel_dep (name = "rules_python" ,
5454 version = "0.29.0" )
5555
56+
57+ fake_fuchsia_sdk = use_repo_rule ("//:fake_fuchsia_sdk.bzl" , "fake_fuchsia_sdk" )
58+ fake_fuchsia_sdk (name = "fuchsia_sdk" )
59+
5660# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
5761register_toolchains ("@bazel_tools//tools/python:autodetecting_toolchain" )
Original file line number Diff line number Diff line change 1+ """Provides a fake @fuchsia_sdk implementation that's used when the real one isn't available.
2+
3+ This is needed since bazel queries on targets that depend on //:gtest (eg:
4+ `bazel query "deps(set(//googletest/test:gtest_all_test))"`) will fail if @fuchsia_sdk is not
5+ defined when bazel is evaluating the transitive closure of the query target.
6+
7+ See https://github.com/google/googletest/issues/4472.
8+ """
9+
10+ def _fake_fuchsia_sdk_impl (repo_ctx ):
11+ for stub_target in repo_ctx .attr ._stub_build_targets :
12+ stub_package = stub_target
13+ stub_target_name = stub_target .split ("/" )[- 1 ]
14+ repo_ctx .file ("%s/BUILD.bazel" % stub_package , """
15+ filegroup(
16+ name = "%s",
17+ )
18+ """ % stub_target_name )
19+
20+ fake_fuchsia_sdk = repository_rule (
21+ doc = "Used to create a fake @fuchsia_sdk repository with stub build targets." ,
22+ implementation = _fake_fuchsia_sdk_impl ,
23+ attrs = {
24+ "_stub_build_targets" : attr .string_list (
25+ doc = "The stub build targets to initialize." ,
26+ default = [
27+ "pkg/fdio" ,
28+ "pkg/syslog" ,
29+ "pkg/zx" ,
30+ ],
31+ ),
32+ },
33+ )
Original file line number Diff line number Diff line change 11"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
22
33load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
4+ load ("//:fake_fuchsia_sdk.bzl" , "fake_fuchsia_sdk" )
45
56def googletest_deps ():
67 """Loads common dependencies needed to use the googletest library."""
@@ -20,3 +21,8 @@ def googletest_deps():
2021 strip_prefix = "abseil-cpp-20240116.0" ,
2122 urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz" ],
2223 )
24+
25+ if not native .existing_rule ("fuchsia_sdk" ):
26+ fake_fuchsia_sdk (
27+ name = "fuchsia_sdk" ,
28+ )
You can’t perform that action at this time.
0 commit comments