Skip to content

Commit 3c3afcf

Browse files
dwsjbedard
authored andcommitted
fix: update build_test() fork for compatibility with Bazel 8.3.0
We here imitate the changes in bazel_skylib 1.8.1 to avoid referring to `@bazel_tools//src/conditions:host_windows`. As of Bazel 8.3.0 referring to `@bazel_tools//src/conditions:host_windows` yields a deprecation warning. In concert with this, we go ahead and bump the minimum required version of bazel_skylib to 1.8.1. Fixes #824
1 parent 7f902c5 commit 3c3afcf

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module(
99
# Lower-bounds (minimum) versions for direct runtime dependencies
1010
bazel_dep(name = "aspect_bazel_lib", version = "2.9.3")
1111
bazel_dep(name = "aspect_rules_js", version = "2.0.0")
12-
bazel_dep(name = "bazel_skylib", version = "1.5.0")
12+
bazel_dep(name = "bazel_skylib", version = "1.8.1")
1313
bazel_dep(name = "platforms", version = "0.0.5")
1414

1515
# TODO(4.x): remove support for non-toolchainized protoc

ts/private/build_test.bzl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ It is used to force Bazel to build some of its dependencies, in the case where
1111
"""
1212

1313
def _build_test_impl(ctx):
14-
# See https://github.com/bazelbuild/bazel-skylib/blob/1.7.1/rules/build_test.bzl#L19-L33
14+
# See https://github.com/bazelbuild/bazel-skylib/blob/1.8.0/rules/build_test.bzl#L19-L34
1515

16-
extension = ".bat" if ctx.attr.is_windows else ".sh"
17-
content = "exit 0" if ctx.attr.is_windows else "#!/usr/bin/env bash\nexit 0"
16+
is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo])
17+
extension = ".bat" if is_windows else ".sh"
18+
content = "exit 0" if is_windows else "#!/usr/bin/env bash\nexit 0"
1819
executable = ctx.actions.declare_file(ctx.label.name + extension)
1920
ctx.actions.write(
2021
output = executable,
@@ -34,17 +35,13 @@ _build_test = rule(
3435
implementation = _build_test_impl,
3536
attrs = {
3637
"targets": attr.label_list(allow_files = True),
37-
"is_windows": attr.bool(mandatory = True),
38+
"_windows_constraint": attr.label(default = "@platforms//os:windows"),
3839
},
3940
test = True,
4041
)
4142

4243
def build_test(name, **kwargs):
4344
_build_test(
4445
name = name,
45-
is_windows = select({
46-
"@bazel_tools//src/conditions:host_windows": True,
47-
"//conditions:default": False,
48-
}),
4946
**kwargs
5047
)

ts/repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def http_archive(**kwargs):
2424
def rules_ts_bazel_dependencies():
2525
http_archive(
2626
name = "bazel_skylib",
27-
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
28-
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
27+
sha256 = "51b5105a760b353773f904d2bbc5e664d0987fbaf22265164de65d43e910d8ac",
28+
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.8.1/bazel-skylib-1.8.1.tar.gz"],
2929
)
3030

3131
http_archive(

0 commit comments

Comments
 (0)