Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 hashlib | 6 import hashlib |
| 7 import os | 7 import os |
| 8 import shutil | 8 import shutil |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 if (os.path.isdir(os.path.dirname(target)) and | 36 if (os.path.isdir(os.path.dirname(target)) and |
| 37 ((not os.path.isfile(target)) or | 37 ((not os.path.isfile(target)) or |
| 38 _HexDigest(source) != _HexDigest(target))): | 38 _HexDigest(source) != _HexDigest(target))): |
| 39 if verbose: | 39 if verbose: |
| 40 print 'Copying %s to %s...' % (source, target) | 40 print 'Copying %s to %s...' % (source, target) |
| 41 if os.path.exists(target): | 41 if os.path.exists(target): |
| 42 os.unlink(target) | 42 os.unlink(target) |
| 43 shutil.copy(source, target) | 43 shutil.copy(source, target) |
| 44 | 44 |
| 45 | 45 |
| 46 def _ConditionalMkdir(output_dir): | |
| 47 if not os.path.isdir(output_dir): | |
| 48 os.makedirs(output_dir) | |
| 49 | |
| 50 | |
| 46 def _CopyCDBToOutput(output_dir, target_arch): | 51 def _CopyCDBToOutput(output_dir, target_arch): |
| 47 """Copies the Windows debugging executable cdb.exe to the output | 52 """Copies the Windows debugging executable cdb.exe to the output |
| 48 directory, which is created if it does not exist. The output | 53 directory, which is created if it does not exist. The output |
| 49 directory, and target architecture that should be copied, are | 54 directory, and target architecture that should be copied, are |
| 50 passed. Supported values for the target architecture are the GYP | 55 passed. Supported values for the target architecture are the GYP |
| 51 values "ia32" and "x64" and the GN values "x86" and "x64". | 56 values "ia32" and "x64" and the GN values "x86" and "x64". |
| 52 """ | 57 """ |
| 53 if not os.path.isdir(output_dir): | 58 _ConditionalMkdir(output_dir) |
| 54 os.makedirs(output_dir) | |
| 55 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | 59 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
| 56 # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case | 60 # If WINDOWSSDKDIR is not set use the default SDK path. This will be the case |
| 57 # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run. | 61 # when DEPOT_TOOLS_WIN_TOOLCHAIN=0 and vcvarsall.bat has not been run. |
| 58 win_sdk_dir = os.path.normpath( | 62 win_sdk_dir = os.path.normpath( |
| 59 os.environ.get('WINDOWSSDKDIR', | 63 os.environ.get('WINDOWSSDKDIR', |
| 60 'C:\\Program Files (x86)\\Windows Kits\\10')) | 64 'C:\\Program Files (x86)\\Windows Kits\\10')) |
| 61 if target_arch == 'ia32' or target_arch == 'x86': | 65 if target_arch == 'ia32' or target_arch == 'x86': |
| 62 src_arch = 'x86' | 66 src_arch = 'x86' |
| 63 elif target_arch == 'x64': | 67 elif target_arch == 'x64': |
| 64 src_arch = 'x64' | 68 src_arch = 'x64' |
| 65 else: | 69 else: |
| 66 print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch | 70 print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch |
| 67 sys.exit(1) | 71 sys.exit(1) |
| 68 # We need to copy multiple files, so cache the computed source directory. | 72 # We need to copy multiple files, so cache the computed source directory. |
| 69 src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch) | 73 src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch) |
| 74 # We need to copy some helper DLLs to get access to the !uniqstack | |
| 75 # command to dump all threads' stacks. | |
| 76 src_winext_dir = os.path.join(src_dir, 'winext') | |
| 77 dst_winext_dir = os.path.join(output_dir, 'winext') | |
| 78 src_winxp_dir = os.path.join(src_dir, 'winxp') | |
|
scottmg
2016/06/25 02:00:20
We shouldn't need winxp\ ?
Ken Russell (switch to Gerrit)
2016/06/27 18:46:36
That directory contains two of the CDB plugin DLLs
| |
| 79 dst_winxp_dir = os.path.join(output_dir, 'winxp') | |
| 80 _ConditionalMkdir(dst_winext_dir) | |
| 81 _ConditionalMkdir(dst_winxp_dir) | |
| 70 # Note that the outputs from the "copy_cdb_to_output" target need to | 82 # Note that the outputs from the "copy_cdb_to_output" target need to |
| 71 # be kept in sync with this list. | 83 # be kept in sync with this list. |
| 72 _CopyImpl('cdb.exe', output_dir, src_dir) | 84 _CopyImpl('cdb.exe', output_dir, src_dir) |
| 73 _CopyImpl('dbgeng.dll', output_dir, src_dir) | 85 _CopyImpl('dbgeng.dll', output_dir, src_dir) |
| 74 _CopyImpl('dbghelp.dll', output_dir, src_dir) | 86 _CopyImpl('dbghelp.dll', output_dir, src_dir) |
| 75 _CopyImpl('dbgmodel.dll', output_dir, src_dir) | 87 _CopyImpl('dbgmodel.dll', output_dir, src_dir) |
| 88 _CopyImpl('ext.dll', dst_winext_dir, src_winext_dir) | |
| 89 _CopyImpl('uext.dll', dst_winext_dir, src_winext_dir) | |
| 90 _CopyImpl('exts.dll', dst_winxp_dir, src_winxp_dir) | |
| 91 _CopyImpl('ntsdexts.dll', dst_winxp_dir, src_winxp_dir) | |
| 76 return 0 | 92 return 0 |
| 77 | 93 |
| 78 | 94 |
| 79 def main(): | 95 def main(): |
| 80 if len(sys.argv) < 2: | 96 if len(sys.argv) < 2: |
| 81 print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \ | 97 print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \ |
| 82 '<target_arch>' | 98 '<target_arch>' |
| 83 return 1 | 99 return 1 |
| 84 return _CopyCDBToOutput(sys.argv[1], sys.argv[2]) | 100 return _CopyCDBToOutput(sys.argv[1], sys.argv[2]) |
| 85 | 101 |
| 86 | 102 |
| 87 if __name__ == '__main__': | 103 if __name__ == '__main__': |
| 88 sys.exit(main()) | 104 sys.exit(main()) |
| OLD | NEW |