Skip to content

Commit 8c8a446

Browse files
authored
Make bzlmod repo rules compatible with Bazel 8 (#1083)
There is an upcoming behavior change in bzlmod --incompatible_use_plus_in_repo_names, which changes the separator character in canonical repo names from tilde `~` to plus `+` due to I/O performance issue in Windows. * bazelbuild/bazel#23127 The above flag is planned to be enabled by default in Bazel 8.0, which is expected to be released on November 2024. Let's update our custom repository rules so that they can continue working with Bazel 8.0. PiperOrigin-RevId: 686421798
1 parent 0377ddd commit 8c8a446

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/bazel/dotnet_tool_repository.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def _dotnet_tool_repo_impl(repo_ctx):
5050
tool_name = repo_ctx.attr.tool_name
5151
if not tool_name:
5252
# In bzlmod, repo_ctx.attr.name has a prefix like "_main~_repo_rules~wix".
53-
tool_name = repo_ctx.attr.name.split("~")[-1]
53+
# Note also that Bazel 8.0+ uses "+" instead of "~".
54+
# https://github.com/bazelbuild/bazel/issues/23127
55+
tool_name = repo_ctx.attr.name.replace("~", "+").split("+")[-1]
5456
version = repo_ctx.attr.version
5557

5658
repo_ctx.execute([

src/bazel/pkg_config_repository.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ def _pkg_config_repository_impl(repo_ctx):
105105
_symlinks(repo_ctx, includes)
106106
data = {
107107
# In bzlmod, repo_ctx.attr.name has a prefix like "_main~_repo_rules~ibus".
108-
"name": repo_ctx.attr.name.split("~")[-1],
108+
# Note also that Bazel 8.0+ uses "+" instead of "~".
109+
# https://github.com/bazelbuild/bazel/issues/23127
110+
"name": repo_ctx.attr.name.replace("~", "+").split("+")[-1],
109111
"hdrs": _make_strlist([item + "/**" for item in includes]),
110112
"copts": _make_strlist(_exec_pkg_config(repo_ctx, "--cflags-only-other")),
111113
"includes": _make_strlist(includes),

0 commit comments

Comments
 (0)