Skip to content

Commit 1e79366

Browse files
committed
Tweaks
1 parent ef0f2c4 commit 1e79366

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

toolchain/internal/llvm_distributions.bzl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,12 @@ def _distribution_urls(rctx):
876876

877877
sha256 = _llvm_distributions[basename]
878878

879-
if basename.endswith(".tar.xz"):
880-
strip_prefix = basename[:(len(basename) - len(".tar.xz"))]
881-
elif basename.endswith(".tar.gz"):
882-
strip_prefix = basename[:(len(basename) - len(".tar.gz"))]
883-
elif basename.endswith(".tar.zst"):
884-
strip_prefix = basename[:(len(basename) - len(".tar.zst"))]
885-
else:
879+
strip_prefix = ""
880+
for suffix in [".tar.gz", ".tar.xz", ".tar.zst"]:
881+
if basename.endswith(suffix):
882+
strip_prefix = basename.rstrip(suffix)
883+
break
884+
if not strip_prefix:
886885
fail("Unknown URL file extension {url}", url = basename)
887886

888887
strip_prefix = strip_prefix.rstrip("-rhel86")
@@ -926,11 +925,11 @@ def _write_distributions_impl(ctx):
926925
version_list = []
927926
for name in _llvm_distributions.keys():
928927
for prefix in ["LLVM-", "clang+llvm-"]:
929-
name = name.removeprefix(prefix)
930-
version = name.split("-", 1)[0]
931-
if not _version_ge(version, MIN_VERSION):
932-
continue
933-
version_list.append(version)
928+
if name.startswith(prefix):
929+
version = name.split("-", 2)[1]
930+
if _version_ge(version, MIN_VERSION):
931+
version_list.append(version)
932+
break
934933
for version in _llvm_distributions_base_url.keys():
935934
if not _version_ge(version, MIN_VERSION):
936935
continue

0 commit comments

Comments
 (0)