Skip to content

Commit fc7d485

Browse files
committed
fix: add support for --incompatible_use_plus_in_repo_names
It was [found][1] the `~` character slows down C/C++ includes on Windows. Bazel 8 will change to the `+` symbol. The [--incompatible_use_plus_in_repo_names][2] flag allows testing this early. This patch supports any separator. [1]: bazelbuild/bazel#22865 [2]: bazelbuild/bazel#23127
1 parent 08baa79 commit fc7d485

File tree

5 files changed

+14
-27
lines changed

5 files changed

+14
-27
lines changed

e2e/MODULE.bazel.lock

+2-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toolchain/local/select/repository.bzl

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("//toolchain:separator.bzl", "SEPARATOR")
12
load(":resolve.bzl", resolve = "key")
23

34
visibility("//toolchain/...")
@@ -32,10 +33,8 @@ toolchian_local_select(
3233
}
3334

3435
def canonical(rctx, label):
35-
# This is _flaky_, it depends on `MODULE.bazel` repository naming[1]
36-
# [1]: https://bazel.build/external/extension#repository_names_and_visibility
37-
prefix = "~".join(rctx.name.split("~")[:-1])
38-
return "@@{}~{}".format(prefix, label.removeprefix("@"))
36+
prefix = SEPARATOR.join(rctx.name.split(SEPARATOR)[:-1])
37+
return "@@{}{}{}".format(prefix, SEPARATOR, label.removeprefix("@"))
3938

4039
def implementation(rctx):
4140
label = resolve(rctx.attr.map, no_match_error = rctx.attr.no_match_error)

toolchain/local/which/repository.bzl

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("//toolchain:separator.bzl", "SEPARATOR")
12
load("//toolchain/local/select:resolve.bzl", resolve = "value")
23

34
visibility("//toolchain/...")
@@ -56,8 +57,9 @@ ATTRS = {
5657
}
5758

5859
def implementation(rctx):
59-
program = rctx.attr.program or rctx.attr.name.rsplit("~", 1)[1].removeprefix("which-")
60-
target = rctx.attr.target or rctx.attr.name.rsplit("~", 1)[1]
60+
name = rctx.attr.name.rsplit(SEPARATOR, 1)[1]
61+
program = rctx.attr.program or name.removeprefix("which-")
62+
target = rctx.attr.target or name
6163
basename = rctx.attr.basename or program
6264
variable = rctx.attr.variable or basename.upper()
6365
entrypoint = resolve(rctx.attr.entrypoint)

toolchain/resolved/repository.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("//toolchain:separator.bzl", "SEPARATOR")
12
load("//toolchain:resolved.bzl", _ATTRS = "ATTRS")
23

34
visibility("//toolchain/...")
@@ -33,7 +34,7 @@ ATTRS = _ATTRS | {
3334
}
3435

3536
def implementation(rctx):
36-
target = rctx.attr.target or rctx.attr.name.rsplit("~", 1)[1]
37+
target = rctx.attr.target or rctx.attr.name.rsplit(SEPARATOR, 1)[1]
3738
basename = rctx.attr.basename or target.removeprefix("resolved-")
3839
substitutions = {
3940
"{{toolchain_type}}": str(rctx.attr.toolchain_type),

toolchain/separator.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
visibility("//...")
2+
3+
SEPARATOR = Label("@local").workspace_name.removesuffix("local")[-1]

0 commit comments

Comments
 (0)