Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
| 7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
| 8 | 8 |
| 9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
| 10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 def GetFileList(root): | 70 def GetFileList(root): |
| 71 """Gets a normalized list of files under |root|.""" | 71 """Gets a normalized list of files under |root|.""" |
| 72 assert not os.path.isabs(root) | 72 assert not os.path.isabs(root) |
| 73 assert os.path.normpath(root) == root | 73 assert os.path.normpath(root) == root |
| 74 file_list = [] | 74 file_list = [] |
| 75 # Ignore WER ReportQueue entries that vctip/cl leave in the bin dir if/when | 75 # Ignore WER ReportQueue entries that vctip/cl leave in the bin dir if/when |
| 76 # they crash. Also ignores the content of the win_sdk/debuggers/x(86|64)/sym/ | 76 # they crash. Also ignores the content of the win_sdk/debuggers/x(86|64)/sym/ |
| 77 # directories as this is just the temporarily location that Windbg might use | 77 # directories as this is just the temporarily location that Windbg might use |
| 78 # to store the symbol files. | 78 # to store the symbol files. |
| 79 # | |
| 80 # Note: These files are only created on a Windows host, so the | |
| 81 # ignored_directories list isn't relevant on non-Windows hosts. | |
| 82 | |
| 79 ignored_directories = ['wer\\reportqueue', | 83 ignored_directories = ['wer\\reportqueue', |
| 80 'win_sdk\\debuggers\\x86\\sym\\', | 84 'win_sdk\\debuggers\\x86\\sym\\', |
| 81 'win_sdk\\debuggers\\x64\\sym\\'] | 85 'win_sdk\\debuggers\\x64\\sym\\'] |
| 82 for base, _, files in os.walk(root): | 86 for base, _, files in os.walk(root): |
| 83 paths = [os.path.join(base, f).lower() for f in files] | 87 paths = [os.path.join(base, f) for f in files] |
| 84 for p in paths: | 88 for p in paths: |
| 85 if any(ignored_dir in p for ignored_dir in ignored_directories): | 89 if any(ignored_dir in p.lower() for ignored_dir in ignored_directories): |
| 86 continue | 90 continue |
| 87 file_list.append(p) | 91 file_list.append(p) |
| 88 return sorted(file_list, key=lambda s: s.replace('/', '\\')) | 92 return sorted(file_list, key=lambda s: s.replace('/', '\\').lower()) |
| 89 | 93 |
| 90 | 94 |
| 91 def MakeTimestampsFileName(root, sha1): | 95 def MakeTimestampsFileName(root, sha1): |
| 92 return os.path.join(root, os.pardir, '%s.timestamps' % sha1) | 96 return os.path.join(root, os.pardir, '%s.timestamps' % sha1) |
| 93 | 97 |
| 94 | 98 |
| 95 def CalculateHash(root, expected_hash): | 99 def CalculateHash(root, expected_hash): |
| 96 """Calculates the sha1 of the paths to all files in the given |root| and the | 100 """Calculates the sha1 of the paths to all files in the given |root| and the |
| 97 contents of those files, and returns as a hex string. | 101 contents of those files, and returns as a hex string. |
| 98 | 102 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 155 |
| 152 # Make long hangs when updating the toolchain less mysterious. | 156 # Make long hangs when updating the toolchain less mysterious. |
| 153 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path | 157 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path |
| 154 sys.stdout.flush() | 158 sys.stdout.flush() |
| 155 digest = hashlib.sha1() | 159 digest = hashlib.sha1() |
| 156 for path in file_list: | 160 for path in file_list: |
| 157 path_without_hash = str(path).replace('/', '\\') | 161 path_without_hash = str(path).replace('/', '\\') |
| 158 if expected_hash: | 162 if expected_hash: |
| 159 path_without_hash = path_without_hash.replace( | 163 path_without_hash = path_without_hash.replace( |
| 160 os.path.join(root, expected_hash).replace('/', '\\'), root) | 164 os.path.join(root, expected_hash).replace('/', '\\'), root) |
| 161 digest.update(path_without_hash) | 165 digest.update(path_without_hash.lower()) |
|
scottmg
2016/06/06 16:39:22
I don't really remember what the data looks like n
scottmg
2016/06/06 16:40:56
Oh, I missed the old lower(). I'm probably not the
| |
| 162 with open(path, 'rb') as f: | 166 with open(path, 'rb') as f: |
| 163 digest.update(f.read()) | 167 digest.update(f.read()) |
| 164 return digest.hexdigest() | 168 return digest.hexdigest() |
| 165 | 169 |
| 166 | 170 |
| 167 def CalculateToolchainHashes(root, remove_corrupt_toolchains): | 171 def CalculateToolchainHashes(root, remove_corrupt_toolchains): |
| 168 """Calculate the hash of the different toolchains installed in the |root| | 172 """Calculate the hash of the different toolchains installed in the |root| |
| 169 directory.""" | 173 directory.""" |
| 170 hashes = [] | 174 hashes = [] |
| 171 dir_list = [ | 175 dir_list = [ |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 536 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
| 533 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 537 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
| 534 | 538 |
| 535 RemoveUnusedToolchains(target_dir) | 539 RemoveUnusedToolchains(target_dir) |
| 536 | 540 |
| 537 return 0 | 541 return 0 |
| 538 | 542 |
| 539 | 543 |
| 540 if __name__ == '__main__': | 544 if __name__ == '__main__': |
| 541 sys.exit(main()) | 545 sys.exit(main()) |
| OLD | NEW |