Commit 3b6d48e 1 parent 814ba36 commit 3b6d48e Copy full SHA for 3b6d48e
File tree 4 files changed +60
-0
lines changed
4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ config_setting(
56
56
constraint_values = ["@platforms//os:openbsd" ],
57
57
)
58
58
59
+ # NOTE: Fuchsia is not an officially supported platform.
60
+ config_setting (
61
+ name = "fuchsia" ,
62
+ constraint_values = ["@platforms//os:fuchsia" ],
63
+ )
64
+
59
65
config_setting (
60
66
name = "msvc_compiler" ,
61
67
flag_values = {
@@ -147,6 +153,17 @@ cc_library(
147
153
"@com_googlesource_code_re2//:re2" ,
148
154
],
149
155
"//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" : [],
150
167
}),
151
168
)
152
169
Original file line number Diff line number Diff line change @@ -53,5 +53,9 @@ bazel_dep(name = "re2",
53
53
bazel_dep (name = "rules_python" ,
54
54
version = "0.29.0" )
55
55
56
+
57
+ fake_fuchsia_sdk = use_repo_rule ("//:fake_fuchsia_sdk.bzl" , "fake_fuchsia_sdk" )
58
+ fake_fuchsia_sdk (name = "fuchsia_sdk" )
59
+
56
60
# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
57
61
register_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 1
1
"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
2
2
3
3
load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
4
+ load ("//:fake_fuchsia_sdk.bzl" , "fake_fuchsia_sdk" )
4
5
5
6
def googletest_deps ():
6
7
"""Loads common dependencies needed to use the googletest library."""
@@ -20,3 +21,8 @@ def googletest_deps():
20
21
strip_prefix = "abseil-cpp-20240116.0" ,
21
22
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz" ],
22
23
)
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