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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return timestamps_data['sha1'] | 123 return timestamps_data['sha1'] |
124 | 124 |
125 # Make long hangs when updating the toolchain less mysterious. | 125 # Make long hangs when updating the toolchain less mysterious. |
126 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path | 126 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path |
127 sys.stdout.flush() | 127 sys.stdout.flush() |
128 digest = hashlib.sha1() | 128 digest = hashlib.sha1() |
129 for path in file_list: | 129 for path in file_list: |
130 path_without_hash = str(path).replace('/', '\\') | 130 path_without_hash = str(path).replace('/', '\\') |
131 if expected_hash: | 131 if expected_hash: |
132 path_without_hash = path_without_hash.replace( | 132 path_without_hash = path_without_hash.replace( |
133 os.path.join(root, expected_hash), root) | 133 os.path.join(root, expected_hash).replace('/', '\\'), root) |
134 digest.update(path_without_hash) | 134 digest.update(path_without_hash) |
135 with open(path, 'rb') as f: | 135 with open(path, 'rb') as f: |
136 digest.update(f.read()) | 136 digest.update(f.read()) |
137 return digest.hexdigest() | 137 return digest.hexdigest() |
138 | 138 |
139 | 139 |
140 def CalculateToolchainHashes(root): | 140 def CalculateToolchainHashes(root): |
141 """Calculate the hash of the different toolchains installed in the |root| | 141 """Calculate the hash of the different toolchains installed in the |root| |
142 directory.""" | 142 directory.""" |
143 hashes = [] | 143 hashes = [] |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 474 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
475 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 475 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
476 | 476 |
477 RemoveUnusedToolchains(target_dir) | 477 RemoveUnusedToolchains(target_dir) |
478 | 478 |
479 return 0 | 479 return 0 |
480 | 480 |
481 | 481 |
482 if __name__ == '__main__': | 482 if __name__ == '__main__': |
483 sys.exit(main()) | 483 sys.exit(main()) |
OLD | NEW |