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.aspx |
| 364 """ |
| 365 if sys.platform == 'win32' and os.environ.get('CHROME_HEADLESS') == '1': |
| 366 key_name = r'SOFTWARE\Microsoft\Windows\Windows Error Reporting' |
| 367 try: |
| 368 key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, key_name) |
| 369 # Merely creating LocalDumps is sufficient to enable the defaults. |
| 370 winreg.CreateKey(key, "LocalDumps") |
| 371 # Disable the WER UI, as documented here: |
| 372 # https://msdn.microsoft.com/en-us/library/windows/desktop/bb513638.aspx |
| 373 winreg.SetValueEx(key, "DontShowUI", 0, winreg.REG_DWORD, 1) |
| 374 # Trap OSError instead of WindowsError so pylint will succeed on Linux. |
| 375 # Catching errors is important because some build machines are not elevated |
| 376 # and writing to HKLM requires elevation. |
| 377 except OSError: |
| 378 pass |
| 379 |
| 380 |
360 def main(): | 381 def main(): |
361 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 382 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
362 parser.add_option('--output-json', metavar='FILE', | 383 parser.add_option('--output-json', metavar='FILE', |
363 help='write information about toolchain to FILE') | 384 help='write information about toolchain to FILE') |
364 parser.add_option('--force', action='store_true', | 385 parser.add_option('--force', action='store_true', |
365 help='force script to run on non-Windows hosts') | 386 help='force script to run on non-Windows hosts') |
366 options, args = parser.parse_args() | 387 options, args = parser.parse_args() |
367 | 388 |
368 if not (sys.platform.startswith(('cygwin', 'win32')) or options.force): | 389 if not (sys.platform.startswith(('cygwin', 'win32')) or options.force): |
369 return 0 | 390 return 0 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 'Got wrong hash after pulling a new toolchain. ' | 485 'Got wrong hash after pulling a new toolchain. ' |
465 'Wanted \'%s\', got one of \'%s\'.' % ( | 486 'Wanted \'%s\', got one of \'%s\'.' % ( |
466 desired_hash, ', '.join(current_hashes))) | 487 desired_hash, ', '.join(current_hashes))) |
467 return 1 | 488 return 1 |
468 SaveTimestampsAndHash(target_dir, desired_hash) | 489 SaveTimestampsAndHash(target_dir, desired_hash) |
469 | 490 |
470 if options.output_json: | 491 if options.output_json: |
471 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 492 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
472 options.output_json) | 493 options.output_json) |
473 | 494 |
| 495 EnableCrashDumpCollection() |
| 496 |
474 if os.environ.get('GYP_MSVS_VERSION') == '2015': | 497 if os.environ.get('GYP_MSVS_VERSION') == '2015': |
475 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) | 498 InstallUniversalCRTIfNeeded(abs_toolchain_target_dir) |
476 | 499 |
477 RemoveUnusedToolchains(target_dir) | 500 RemoveUnusedToolchains(target_dir) |
478 | 501 |
479 return 0 | 502 return 0 |
480 | 503 |
481 | 504 |
482 if __name__ == '__main__': | 505 if __name__ == '__main__': |
483 sys.exit(main()) | 506 sys.exit(main()) |
OLD | NEW |