summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-03-25 11:32:27 +0000
committerNico Weber <nicolasweber@gmx.de>2019-03-25 11:32:27 +0000
commitd59857c334777d92afd3da2218e8d669751166b7 (patch)
treec98badaee4436c1969fc999f209b77b182ebb3db
parent3dfa368d5d7cfb9ba2ab06fb9fc6dd2d01c0b7ca (diff)
downloadbcm5719-llvm-d59857c334777d92afd3da2218e8d669751166b7.tar.gz
bcm5719-llvm-d59857c334777d92afd3da2218e8d669751166b7.zip
gn build: Let get.py keep zip file in memory instead of using a temp file
The zip is small, and it's a bit less code this way. No intended behavior change. Differential Revision: https://reviews.llvm.org/D59677 llvm-svn: 356884
-rwxr-xr-xllvm/utils/gn/get.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/llvm/utils/gn/get.py b/llvm/utils/gn/get.py
index 4015d5986c9..c39649df78a 100755
--- a/llvm/utils/gn/get.py
+++ b/llvm/utils/gn/get.py
@@ -3,27 +3,20 @@
from __future__ import print_function
+import io
import os
import urllib2
import sys
-import tempfile
import zipfile
-def download_url(url, output_file):
- """Download url into output_file."""
+def download_and_unpack(url, output_dir, gn):
+ """Download an archive from url and extract gn from it into output_dir."""
print('downloading %s ...' % url, end='')
sys.stdout.flush()
- output_file.write(urllib2.urlopen(url).read())
+ data = urllib2.urlopen(url).read()
print(' done')
-
-
-def download_and_unpack(url, output_dir, gn):
- """Download an archive from url and extract gn from it into output_dir."""
- with tempfile.TemporaryFile() as f:
- download_url(url, f)
- f.seek(0)
- zipfile.ZipFile(f).extract(gn, path=output_dir)
+ zipfile.ZipFile(io.BytesIO(data)).extract(gn, path=output_dir)
def set_executable_bit(path):
OpenPOWER on IntegriCloud