88import subprocess
99import sys
1010import tempfile
11- import zipfile
11+ import zlib
1212from collections import namedtuple
1313
1414DEPS = {"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
281281def 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
294294def 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
321322if __name__ == "__main__" :
0 commit comments