Skip to content

Commit dc65bf7

Browse files
author
Alex Denisov
committed
Produce zip and tar.gz
1 parent f73bce0 commit dc65bf7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg_swift_llvm.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import subprocess
99
import sys
1010
import tempfile
11-
import zipfile
11+
import zlib
1212
from collections import namedtuple
1313

1414
DEPS = {"llvm": ["LLVMSupport"],
@@ -20,7 +20,7 @@ def getoptions():
2020
for p in DEPS:
2121
parser.add_argument(f"--{p}", required=True, type=resolve,
2222
metavar="DIR", help=f"path to {p} build root")
23-
default_output = f"swift-prebuilt-{get_platform()}.zip"
23+
default_output = f"swift-prebuilt-{get_platform()}"
2424
parser.add_argument("--keep-tmp-dir", "-K", action="store_true",
2525
help="do not clean up the temporary directory")
2626
parser.add_argument("--output", "-o", type=pathlib.Path, metavar="DIR_OR_ZIP",
@@ -279,16 +279,16 @@ def create_export_dir(tmp, installed, libs):
279279

280280

281281
def zip_dir(src, tgt):
282-
print(f"compressing {src.name} to {tgt}")
283282
tgt = get_tgt(tgt, f"swift-prebuilt-{get_platform()}.zip")
284-
with zipfile.ZipFile(tgt, "w",
285-
compression=zipfile.ZIP_DEFLATED,
286-
compresslevel=6) as archive:
287-
for srcfile in src.rglob("*"):
288-
if srcfile.is_file():
289-
print(f"deflating {srcfile.relative_to(src)}")
290-
archive.write(srcfile, arcname=srcfile.relative_to(src))
291-
print(f"created {tgt}")
283+
print(f"compressing {src.name} to {tgt}")
284+
archive = shutil.make_archive(tgt, 'zip', src)
285+
print(f"created {archive}")
286+
287+
def tar_dir(src, tgt):
288+
tgt = get_tgt(tgt, f"swift-prebuilt-{get_platform()}.tar.gz")
289+
print(f"compressing {src.name} to {tgt}")
290+
archive = shutil.make_archive(tgt, 'gztar', src)
291+
print(f"created {archive}")
292292

293293

294294
def main(opts):
@@ -316,6 +316,7 @@ def main(opts):
316316
libs = get_libs(configured)
317317
exported = create_export_dir(tmp, installed, libs)
318318
zip_dir(exported, opts.output)
319+
tar_dir(exported, opts.output)
319320

320321

321322
if __name__ == "__main__":

0 commit comments

Comments
 (0)