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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 return 'Windows8.1-KB2999226-x64.msu' | 350 return 'Windows8.1-KB2999226-x64.msu' |
351 else: | 351 else: |
352 # Some future OS. | 352 # Some future OS. |
353 return None | 353 return None |
354 | 354 |
355 | 355 |
356 def InstallUniversalCRTIfNeeded(abs_target_dir): | 356 def InstallUniversalCRTIfNeeded(abs_target_dir): |
357 return | 357 return |
358 | 358 |
359 | 359 |
360 def EnableCrashDumpCollection(): | |
361 """Tell Windows Error Reporting to record crash dumps so that we can diagnose | |
362 linker crashes and other toolchain failures. Documented at: | |
363 https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181(v=vs.85).asp x | |
scottmg
2016/03/22 19:27:44
Remove "(v=vs.85)" to make it fix in 80 col
brucedawson
2016/03/22 20:39:18
Done.
| |
364 """ | |
365 key_name = r'SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps' | |
scottmg
2016/03/22 19:27:44
if not sys.platform.startswith('win'):
return
b
brucedawson
2016/03/22 20:39:18
sys.platform == 'win32' seems to be standard in th
| |
366 try: | |
367 key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, key_name) | |
368 # None of the settings are touched because that could over-ride user | |
369 # specific settings. Merely creating LocalDumps is sufficient to enable the | |
370 # defaults. | |
371 key.Close() | |
372 # Trap OSError instead of WindowsError so pylint will succeed on Linux. | |
373 # Catching errors is important because some build machines and most user | |
374 # machines are not elevated and writing to HKLM requires elevation. | |
375 except OSError: | |
376 return | |
scottmg
2016/03/22 19:27:44
Normally just "pass" instead of "return" to indica
brucedawson
2016/03/22 20:39:18
Yep. I previously had the except elsewhere where '
| |
377 | |
378 | |
360 def main(): | 379 def main(): |
361 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 380 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
362 parser.add_option('--output-json', metavar='FILE', | 381 parser.add_option('--output-json', metavar='FILE', |
363 help='write information about toolchain to FILE') | 382 help='write information about toolchain to FILE') |
364 parser.add_option('--force', action='store_true', | 383 parser.add_option('--force', action='store_true', |
365 help='force script to run on non-Windows hosts') | 384 help='force script to run on non-Windows hosts') |
366 options, args = parser.parse_args() | 385 options, args = parser.parse_args() |
367 | 386 |
368 if not (sys.platform.startswith(('cygwin', 'win32')) or options.force): | 387 if not (sys.platform.startswith(('cygwin', 'win32')) or options.force): |
369 return 0 | 388 return 0 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 'Got wrong hash after pulling a new toolchain. ' | 483 'Got wrong hash after pulling a new toolchain. ' |
465 'Wanted \'%s\', got one of \'%s\'.' % ( | 484 'Wanted \'%s\', got one of \'%s\'.' % ( |
466 desired_hash, ', '.join(current_hashes))) | 485 desired_hash, ', '.join(current_hashes))) |
467 return 1 | 486 return 1 |
468 SaveTimestampsAndHash(target_dir, desired_hash) | 487 SaveTimestampsAndHash(target_dir, desired_hash) |
469 | 488 |
470 if options.output_json: | 489 if options.output_json: |
471 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 490 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
472 options.output_json) | 491 options.output_json) |
473 | 492 |
493 EnableCrashDumpCollection() | |
494 | |
474 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 495 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
475 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 496 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
476 | 497 |
477 RemoveUnusedToolchains(target_dir) | 498 RemoveUnusedToolchains(target_dir) |
478 | 499 |
479 return 0 | 500 return 0 |
480 | 501 |
481 | 502 |
482 if __name__ == '__main__': | 503 if __name__ == '__main__': |
483 sys.exit(main()) | 504 sys.exit(main()) |
OLD | NEW |