8
8
import subprocess
9
9
import sys
10
10
import tempfile
11
- import zipfile
11
+ import zlib
12
12
from collections import namedtuple
13
13
14
14
DEPS = {"llvm" : ["LLVMSupport" ],
@@ -20,7 +20,7 @@ def getoptions():
20
20
for p in DEPS :
21
21
parser .add_argument (f"--{ p } " , required = True , type = resolve ,
22
22
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 ()} "
24
24
parser .add_argument ("--keep-tmp-dir" , "-K" , action = "store_true" ,
25
25
help = "do not clean up the temporary directory" )
26
26
parser .add_argument ("--output" , "-o" , type = pathlib .Path , metavar = "DIR_OR_ZIP" ,
@@ -279,16 +279,16 @@ def create_export_dir(tmp, installed, libs):
279
279
280
280
281
281
def zip_dir (src , tgt ):
282
- print (f"compressing { src .name } to { tgt } " )
283
282
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 } " )
292
292
293
293
294
294
def main (opts ):
@@ -316,6 +316,7 @@ def main(opts):
316
316
libs = get_libs (configured )
317
317
exported = create_export_dir (tmp , installed , libs )
318
318
zip_dir (exported , opts .output )
319
+ tar_dir (exported , opts .output )
319
320
320
321
321
322
if __name__ == "__main__" :
0 commit comments