Skip to content

Commit

Permalink
Make bzlmod repo rules compatible with Bazel 8 (#1083)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yukawa authored Oct 16, 2024
1 parent 0377ddd commit 8c8a446
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/bazel/dotnet_tool_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def _dotnet_tool_repo_impl(repo_ctx):
tool_name = repo_ctx.attr.tool_name
if not tool_name:
# In bzlmod, repo_ctx.attr.name has a prefix like "_main~_repo_rules~wix".
tool_name = repo_ctx.attr.name.split("~")[-1]
# Note also that Bazel 8.0+ uses "+" instead of "~".
# https://github.com/bazelbuild/bazel/issues/23127
tool_name = repo_ctx.attr.name.replace("~", "+").split("+")[-1]
version = repo_ctx.attr.version

repo_ctx.execute([
Expand Down
4 changes: 3 additions & 1 deletion src/bazel/pkg_config_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def _pkg_config_repository_impl(repo_ctx):
_symlinks(repo_ctx, includes)
data = {
# In bzlmod, repo_ctx.attr.name has a prefix like "_main~_repo_rules~ibus".
"name": repo_ctx.attr.name.split("~")[-1],
# Note also that Bazel 8.0+ uses "+" instead of "~".
# https://github.com/bazelbuild/bazel/issues/23127
"name": repo_ctx.attr.name.replace("~", "+").split("+")[-1],
"hdrs": _make_strlist([item + "/**" for item in includes]),
"copts": _make_strlist(_exec_pkg_config(repo_ctx, "--cflags-only-other")),
"includes": _make_strlist(includes),
Expand Down

0 comments on commit 8c8a446

Please sign in to comment.