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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 sys.stdout.flush() | 158 sys.stdout.flush() |
159 digest = hashlib.sha1() | 159 digest = hashlib.sha1() |
160 for path in file_list: | 160 for path in file_list: |
161 path_without_hash = str(path).replace('/', '\\') | 161 path_without_hash = str(path).replace('/', '\\') |
162 if expected_hash: | 162 if expected_hash: |
163 path_without_hash = path_without_hash.replace( | 163 path_without_hash = path_without_hash.replace( |
164 os.path.join(root, expected_hash).replace('/', '\\'), root) | 164 os.path.join(root, expected_hash).replace('/', '\\'), root) |
165 digest.update(path_without_hash.lower()) | 165 digest.update(path_without_hash.lower()) |
166 with open(path, 'rb') as f: | 166 with open(path, 'rb') as f: |
167 digest.update(f.read()) | 167 digest.update(f.read()) |
| 168 |
| 169 # Save the timestamp file if the calculated hash is the expected one. |
| 170 if digest.hexdigest() == expected_hash: |
| 171 SaveTimestampsAndHash(root, digest.hexdigest()) |
168 return digest.hexdigest() | 172 return digest.hexdigest() |
169 | 173 |
170 | 174 |
171 def CalculateToolchainHashes(root, remove_corrupt_toolchains): | 175 def CalculateToolchainHashes(root, remove_corrupt_toolchains): |
172 """Calculate the hash of the different toolchains installed in the |root| | 176 """Calculate the hash of the different toolchains installed in the |root| |
173 directory.""" | 177 directory.""" |
174 hashes = [] | 178 hashes = [] |
175 dir_list = [ | 179 dir_list = [ |
176 d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))] | 180 d for d in os.listdir(root) if os.path.isdir(os.path.join(root, d))] |
177 for d in dir_list: | 181 for d in dir_list: |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 540 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
537 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 541 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
538 | 542 |
539 RemoveUnusedToolchains(target_dir) | 543 RemoveUnusedToolchains(target_dir) |
540 | 544 |
541 return 0 | 545 return 0 |
542 | 546 |
543 | 547 |
544 if __name__ == '__main__': | 548 if __name__ == '__main__': |
545 sys.exit(main()) | 549 sys.exit(main()) |
OLD | NEW |