Skip to content

Commit c0f336b

Browse files
authored
Emit canonical labels if needed in pkg_name_from_label (#447)
Previously resulted in errors such as: ``` Traceback (most recent call last): File "/private/var/tmp/_bazel_fmeum/5d22c23119063f77cfcdafc5f5d52f01/external/toolchains_llvm+/toolchain/internal/configure.bzl", line 141, column 66, in llvm_config_impl sysroot_paths_dict, sysroot_labels_dict = _sysroot_paths_dict( File "/private/var/tmp/_bazel_fmeum/5d22c23119063f77cfcdafc5f5d52f01/external/toolchains_llvm+/toolchain/internal/sysroot.bzl", line 76, column 53, in sysroot_paths_dict path = _canonical_dir_path(str(rctx.path(label).dirname)) Error in path: Unable to load package for @@[unknown repo 'toy-toolchain++toy_sysroot+sysroot_amd64_ubuntu' requested from @@toolchains_llvm+]//:BUILD.bazel: The repository '@@[unknown repo 'toy-toolchain++toy_sysroot+sysroot_amd64_ubuntu' requested from @@toolchains_llvm+]' could not be resolved: No repository visible as '@toy-toolchain++toy_sysroot+sysroot_amd64_ubuntu' from repository '@@toolchains_llvm+ ```
1 parent ea61c5d commit c0f336b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

toolchain/internal/common.bzl

+2-4
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,8 @@ def is_absolute_path(val):
206206
return val and val[0] == "/" and (len(val) == 1 or val[1] != "/")
207207

208208
def pkg_name_from_label(label):
209-
if label.workspace_name:
210-
return "@" + label.workspace_name + "//" + label.package
211-
else:
212-
return label.package
209+
s = str(label)
210+
return s[:s.index(":")]
213211

214212
def pkg_path_from_label(label):
215213
if label.workspace_root:

0 commit comments

Comments
 (0)