Skip to content

Commit 6eb71f2

Browse files
committed
Extraxt exe with 7zip since msiexe does not work.
1 parent 86d5ea1 commit 6eb71f2

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

toolchain/internal/llvm_distributions.bzl

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,29 @@ def download_llvm(rctx):
714714
if not urls:
715715
urls, sha256, strip_prefix = _distribution_urls(rctx)
716716

717-
res = rctx.download_and_extract(
718-
urls,
719-
sha256 = sha256,
720-
stripPrefix = strip_prefix,
721-
auth = _get_auth(rctx, urls),
722-
)
717+
filename = urls[0].split("?")[0]
718+
basename = filename.split("/")[-1]
719+
if urls[0].endswith(".exe"):
720+
res = rctx.download(
721+
urls,
722+
sha256 = sha256,
723+
auth = _get_auth(rctx, urls),
724+
output = basename,
725+
)
726+
rctx.execute(
727+
arguments = [
728+
"C:/Program Files/7-Zip7z.exe",
729+
"x",
730+
basename,
731+
],
732+
)
733+
else:
734+
res = rctx.download_and_extract(
735+
urls,
736+
sha256 = sha256,
737+
stripPrefix = strip_prefix,
738+
auth = _get_auth(rctx, urls),
739+
)
723740

724741
if rctx.attr.libclang_rt:
725742
clang_versions = rctx.path("lib/clang").readdir()
@@ -784,11 +801,12 @@ def _distribution_urls(rctx):
784801

785802
sha256 = _llvm_distributions[basename]
786803

787-
if basename.endswith(".tar.xz"):
788-
strip_prefix = basename[:(len(basename) - len(".tar.xz"))]
789-
elif basename.endswith(".tar.zst"):
790-
strip_prefix = basename[:(len(basename) - len(".tar.zst"))]
791-
else:
804+
strip_prefix = ""
805+
for suffix in [".exe", ".tar.gz", ".tar.xz", ".tar.zst"]:
806+
if basename.endswith(suffix):
807+
strip_prefix = basename.rstrip(suffix)
808+
break
809+
if not strip_prefix:
792810
fail("Unknown URL file extension {url}", url = basename)
793811

794812
strip_prefix = strip_prefix.rstrip("-rhel86")
@@ -831,9 +849,9 @@ def _write_distributions_impl(ctx):
831849
for prefix in ["LLVM-", "clang+llvm-"]:
832850
if name.startswith(prefix):
833851
version = name.split("-", 2)[1]
834-
if not _version_ge(version, MIN_VERSION):
835-
continue
836-
version_list.append(version)
852+
if _version_ge(version, MIN_VERSION):
853+
version_list.append(version)
854+
break
837855
for version in _llvm_distributions_base_url.keys():
838856
if not _version_ge(version, MIN_VERSION):
839857
continue

0 commit comments

Comments
 (0)