OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import glob | 6 import glob |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import shutil | 10 import shutil |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 vs_version = GetVisualStudioVersion() | 146 vs_version = GetVisualStudioVersion() |
147 if vs_version == '2013': | 147 if vs_version == '2013': |
148 return '120' | 148 return '120' |
149 elif vs_version == '2015': | 149 elif vs_version == '2015': |
150 return '140' | 150 return '140' |
151 else: | 151 else: |
152 raise ValueError('Unexpected GYP_MSVS_VERSION') | 152 raise ValueError('Unexpected GYP_MSVS_VERSION') |
153 | 153 |
154 | 154 |
155 def _CopyRuntimeImpl(target, source, verbose=True): | 155 def _CopyRuntimeImpl(target, source, verbose=True): |
156 """Copy |source| to |target| if it doesn't already exist or if it | 156 """Copy |source| to |target| if it doesn't already exist or if it needs to be |
157 needs to be updated. | 157 updated (comparing last modified time as an approximate float match as for |
158 some reason the values tend to differ by ~1e-07 despite being copies of the | |
159 same file... https://crbug.com/603603). | |
158 """ | 160 """ |
159 if (os.path.isdir(os.path.dirname(target)) and | 161 if (os.path.isdir(os.path.dirname(target)) and |
160 (not os.path.isfile(target) or | 162 (not os.path.isfile(target) or |
161 os.stat(target).st_mtime != os.stat(source).st_mtime)): | 163 abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)): |
scottmg
2016/04/18 16:48:39
Gah! Why the heck is mtime a float anyway :/
gab
2016/04/18 16:58:51
I know, right..! Casting to int() and doing strict
brucedawson
2016/04/18 18:25:17
WTF? There's something weird going on. When I run:
| |
162 if verbose: | 164 if verbose: |
163 print 'Copying %s to %s...' % (source, target) | 165 print 'Copying %s to %s...' % (source, target) |
164 if os.path.exists(target): | 166 if os.path.exists(target): |
165 os.unlink(target) | 167 os.unlink(target) |
166 shutil.copy2(source, target) | 168 shutil.copy2(source, target) |
167 | 169 |
168 | 170 |
169 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): | 171 def _CopyRuntime2013(target_dir, source_dir, dll_pattern): |
170 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't | 172 """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
171 exist, but the target directory does exist.""" | 173 exist, but the target directory does exist.""" |
172 for file_part in ('p', 'r'): | 174 for file_part in ('p', 'r'): |
173 dll = dll_pattern % file_part | 175 dll = dll_pattern % file_part |
174 target = os.path.join(target_dir, dll) | 176 target = os.path.join(target_dir, dll) |
175 source = os.path.join(source_dir, dll) | 177 source = os.path.join(source_dir, dll) |
176 _CopyRuntimeImpl(target, source) | 178 _CopyRuntimeImpl(target, source) |
177 | 179 |
178 | 180 |
179 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix): | 181 def _CopyRuntime2015(target_dir, source_dir, dll_pattern, suffix): |
180 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't | 182 """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't |
181 exist, but the target directory does exist.""" | 183 exist, but the target directory does exist.""" |
182 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): | 184 for file_part in ('msvcp', 'vccorlib', 'vcruntime'): |
183 dll = dll_pattern % file_part | 185 dll = dll_pattern % file_part |
184 target = os.path.join(target_dir, dll) | 186 target = os.path.join(target_dir, dll) |
185 source = os.path.join(source_dir, dll) | 187 source = os.path.join(source_dir, dll) |
186 _CopyRuntimeImpl(target, source) | 188 _CopyRuntimeImpl(target, source) |
187 ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll') | 189 ucrt_src_dir = os.path.join(source_dir, 'api-ms-win-*.dll') |
188 print 'Copying %s to %s...' % (ucrt_src_dir, target_dir) | |
189 for ucrt_src_file in glob.glob(ucrt_src_dir): | 190 for ucrt_src_file in glob.glob(ucrt_src_dir): |
190 file_part = os.path.basename(ucrt_src_file) | 191 file_part = os.path.basename(ucrt_src_file) |
191 ucrt_dst_file = os.path.join(target_dir, file_part) | 192 ucrt_dst_file = os.path.join(target_dir, file_part) |
192 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) | 193 _CopyRuntimeImpl(ucrt_dst_file, ucrt_src_file, False) |
193 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), | 194 _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), |
194 os.path.join(source_dir, 'ucrtbase' + suffix)) | 195 os.path.join(source_dir, 'ucrtbase' + suffix)) |
195 | 196 |
196 | 197 |
197 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): | 198 def _CopyRuntime(target_dir, source_dir, target_cpu, debug): |
198 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target | 199 """Copy the VS runtime DLLs, only if the target doesn't exist, but the target |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 'copy_dlls': CopyDlls, | 369 'copy_dlls': CopyDlls, |
369 } | 370 } |
370 if len(sys.argv) < 2 or sys.argv[1] not in commands: | 371 if len(sys.argv) < 2 or sys.argv[1] not in commands: |
371 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) | 372 print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
372 return 1 | 373 return 1 |
373 return commands[sys.argv[1]](*sys.argv[2:]) | 374 return commands[sys.argv[1]](*sys.argv[2:]) |
374 | 375 |
375 | 376 |
376 if __name__ == '__main__': | 377 if __name__ == '__main__': |
377 sys.exit(main()) | 378 sys.exit(main()) |
OLD | NEW |