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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 68 |
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. |
Nico
2016/06/03 18:44:46
You could add a "# Note: These files are only crea
hans
2016/06/03 18:47:32
I figured this is why you hadn't done this on Mac,
Nico
2016/06/03 18:56:00
The comment says cl (which we don't run in cross-b
| |
79 ignored_directories = ['wer\\reportqueue', | 79 ignored_directories = ['wer\\reportqueue', |
80 'win_sdk\\debuggers\\x86\\sym\\', | 80 'win_sdk\\debuggers\\x86\\sym\\', |
81 'win_sdk\\debuggers\\x64\\sym\\'] | 81 'win_sdk\\debuggers\\x64\\sym\\'] |
82 for base, _, files in os.walk(root): | 82 for base, _, files in os.walk(root): |
83 paths = [os.path.join(base, f).lower() for f in files] | 83 paths = [os.path.join(base, f) for f in files] |
84 for p in paths: | 84 for p in paths: |
85 if any(ignored_dir in p for ignored_dir in ignored_directories): | 85 p_lower = p.replace('/', '\\').lower() |
86 if any(ignored_dir in p_lower for ignored_dir in ignored_directories): | |
86 continue | 87 continue |
87 file_list.append(p) | 88 file_list.append(p) |
88 return sorted(file_list, key=lambda s: s.replace('/', '\\')) | 89 return sorted(file_list, key=lambda s: s.replace('/', '\\').lower()) |
89 | 90 |
90 | 91 |
91 def MakeTimestampsFileName(root, sha1): | 92 def MakeTimestampsFileName(root, sha1): |
92 return os.path.join(root, os.pardir, '%s.timestamps' % sha1) | 93 return os.path.join(root, os.pardir, '%s.timestamps' % sha1) |
93 | 94 |
94 | 95 |
95 def CalculateHash(root, expected_hash): | 96 def CalculateHash(root, expected_hash): |
96 """Calculates the sha1 of the paths to all files in the given |root| and the | 97 """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. | 98 contents of those files, and returns as a hex string. |
98 | 99 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 | 152 |
152 # Make long hangs when updating the toolchain less mysterious. | 153 # Make long hangs when updating the toolchain less mysterious. |
153 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path | 154 print 'Calculating hash of toolchain in %s. Please wait...' % full_root_path |
154 sys.stdout.flush() | 155 sys.stdout.flush() |
155 digest = hashlib.sha1() | 156 digest = hashlib.sha1() |
156 for path in file_list: | 157 for path in file_list: |
157 path_without_hash = str(path).replace('/', '\\') | 158 path_without_hash = str(path).replace('/', '\\') |
158 if expected_hash: | 159 if expected_hash: |
159 path_without_hash = path_without_hash.replace( | 160 path_without_hash = path_without_hash.replace( |
160 os.path.join(root, expected_hash).replace('/', '\\'), root) | 161 os.path.join(root, expected_hash).replace('/', '\\'), root) |
161 digest.update(path_without_hash) | 162 digest.update(path_without_hash.lower()) |
162 with open(path, 'rb') as f: | 163 with open(path, 'rb') as f: |
163 digest.update(f.read()) | 164 digest.update(f.read()) |
164 return digest.hexdigest() | 165 return digest.hexdigest() |
165 | 166 |
166 | 167 |
167 def CalculateToolchainHashes(root, remove_corrupt_toolchains): | 168 def CalculateToolchainHashes(root, remove_corrupt_toolchains): |
168 """Calculate the hash of the different toolchains installed in the |root| | 169 """Calculate the hash of the different toolchains installed in the |root| |
169 directory.""" | 170 directory.""" |
170 hashes = [] | 171 hashes = [] |
171 dir_list = [ | 172 dir_list = [ |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 533 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
533 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 534 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
534 | 535 |
535 RemoveUnusedToolchains(target_dir) | 536 RemoveUnusedToolchains(target_dir) |
536 | 537 |
537 return 0 | 538 return 0 |
538 | 539 |
539 | 540 |
540 if __name__ == '__main__': | 541 if __name__ == '__main__': |
541 sys.exit(main()) | 542 sys.exit(main()) |
OLD | NEW |