Chromium Code Reviews| Index: build/android/gyp/util/md5_check.py |
| diff --git a/build/android/gyp/util/md5_check.py b/build/android/gyp/util/md5_check.py |
| index 9f365aa08162c83b22192b675a1a53a5e9acb87f..14ba8f1d96dc6fbbcc6b719d2fa28eea9ee73692 100644 |
| --- a/build/android/gyp/util/md5_check.py |
| +++ b/build/android/gyp/util/md5_check.py |
| @@ -6,6 +6,11 @@ import hashlib |
| import os |
| +# When set, record_path will include a per-file breakdown of md5s so that it is |
| +# possible to see exactly which file changed. |
| +_RECORD_EXTRA_INFO = int(os.environ.get('RECORD_EXTRA_MD5_INFO', 0)) |
| + |
| + |
| def CallAndRecordIfStale( |
| function, record_path=None, input_paths=None, input_strings=None, |
| force=False): |
| @@ -29,6 +34,8 @@ def CallAndRecordIfStale( |
| if force or md5_checker.IsStale(): |
| function() |
| md5_checker.Write() |
| + elif _RECORD_EXTRA_INFO: |
| + md5_checker.Write() |
| def _UpdateMd5ForFile(md5, path, block_size=2**16): |
| @@ -67,16 +74,24 @@ class _Md5Checker(object): |
| self.record_path = record_path |
| md5 = hashlib.md5() |
| + extended_info = [] |
| for i in sorted(input_paths): |
| _UpdateMd5ForPath(md5, i) |
| + extended_info.append(i + '=' + md5.hexdigest()) |
| + |
| for s in input_strings: |
| md5.update(s) |
| + extended_info.append(s) |
| + |
| self.new_digest = md5.hexdigest() |
| + self.extended_info = extended_info |
| self.old_digest = '' |
| if os.path.exists(self.record_path): |
| with open(self.record_path, 'r') as old_record: |
| - self.old_digest = old_record.read() |
| + for line in old_record: |
|
jbudorick
2015/08/23 02:31:01
self.old_digest = old_record.readline().strip()
?
|
| + self.old_digest = line.strip() |
| + break |
| def IsStale(self): |
| return self.old_digest != self.new_digest |
| @@ -84,3 +99,5 @@ class _Md5Checker(object): |
| def Write(self): |
| with open(self.record_path, 'w') as new_record: |
| new_record.write(self.new_digest) |
| + if _RECORD_EXTRA_INFO: |
| + new_record.write('\n' + '\n'.join(self.extended_info)) |