Skip to content

Commit bb48152

Browse files
committed
Factor out workaround for bazelbuild/bazel#15916
1 parent c45508f commit bb48152

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

MODULE.bazel.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elisp/repositories.bzl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1818
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
19-
load("//private:repositories.bzl", "HTTP_ARCHIVE_ATTRS", "HTTP_ARCHIVE_DOC", "non_module_deps")
19+
load("//private:repositories.bzl", "HTTP_ARCHIVE_ATTRS", "HTTP_ARCHIVE_DOC", "label_str", "non_module_deps")
2020

2121
def rules_elisp_dependencies():
2222
"""Installs necessary dependencies for Emacs Lisp rules.
@@ -100,10 +100,6 @@ def _elisp_http_archive_impl(repository_ctx):
100100
integrity = repository_ctx.attr.integrity or fail("missing archive checksum"),
101101
stripPrefix = repository_ctx.attr.strip_prefix,
102102
)
103-
defs_bzl = str(repository_ctx.attr._defs_bzl)
104-
if not defs_bzl.startswith("@"):
105-
# Work around https://github.com/bazelbuild/bazel/issues/15916.
106-
defs_bzl = "@" + defs_bzl
107103
repository_ctx.template(
108104
"WORKSPACE.bazel",
109105
Label("//elisp:WORKSPACE.template"),
@@ -116,7 +112,7 @@ def _elisp_http_archive_impl(repository_ctx):
116112
"BUILD.bazel",
117113
Label("//elisp:BUILD.template"),
118114
{
119-
"[[defs_bzl]]": repr(defs_bzl),
115+
"[[defs_bzl]]": repr(label_str(repository_ctx.attr._defs_bzl)),
120116
"[[exclude]]": repr(repository_ctx.attr.exclude),
121117
},
122118
executable = False,

examples/ext/MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private/repositories.bzl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ def non_module_dev_deps():
7070
)
7171
_bazel_version(name = "phst_rules_elisp_bazel_version")
7272

73+
def label_str(label):
74+
"""Return a unique string form of a label.
75+
76+
Args:
77+
label: a Label object
78+
79+
Returns:
80+
a string representing an absolute form of the label
81+
"""
82+
83+
# TODO: Replace with plain ‘str’ once we drop support for Bazel 5.
84+
ret = str(label)
85+
if not ret.startswith("@"):
86+
# Work around https://github.com/bazelbuild/bazel/issues/15916.
87+
ret = "@" + ret
88+
return ret
89+
7390
def _toolchains_impl(repository_ctx):
7491
windows = repository_ctx.os.name.startswith("windows")
7592
target = Label("//elisp:windows-toolchains.BUILD" if windows else "//elisp:unix-toolchains.BUILD")

0 commit comments

Comments
 (0)