Don't extract archives if unchanged.

This should shave 20% (40 seconds) off our Windows cycle times, going by
the graphs. It's 15% off our Linux ones, but that 15% is only 11
seconds.

Change-Id: I077c3924c722d597f66fc6dec72932ed0c81660a
Reviewed-on: https://boringssl-review.googlesource.com/12562
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2016-12-01 23:48:00 -05:00 committed by Adam Langley
parent 65241cf555
commit 0ec5639092
2 changed files with 20 additions and 4 deletions

View File

@ -104,8 +104,6 @@ hooks = [
'boringssl/util/bot/update_clang.py',
],
},
# TODO(davidben): Only extract archives when they've changed. Extracting perl
# on Windows is a significant part of the cycle time.
{
'name': 'cmake_linux64_extract',
'pattern': '.',

View File

@ -15,6 +15,7 @@
"""Extracts archives."""
import hashlib
import optparse
import os
import os.path
@ -78,6 +79,22 @@ def main(args):
# Skip archives that weren't downloaded.
return 0
with open(archive) as f:
sha256 = hashlib.sha256()
while True:
chunk = f.read(1024 * 1024)
if not chunk:
break
sha256.update(chunk)
digest = sha256.hexdigest()
stamp_path = os.path.join(output, ".boringssl_archive_digest")
if os.path.exists(stamp_path):
with open(stamp_path) as f:
if f.read().strip() == digest:
print "Already up-to-date."
return 0
if archive.endswith('.zip'):
entries = IterateZip(archive)
elif archive.endswith('.tar.gz'):
@ -129,9 +146,10 @@ def main(args):
finally:
entries.close()
if num_extracted % 100 == 0:
print "Done. Extracted %d files." % (num_extracted,)
with open(stamp_path, 'w') as f:
f.write(digest)
print "Done. Extracted %d files." % (num_extracted,)
return 0