OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import os |
| 7 import shutil |
| 8 import sys |
| 9 |
| 10 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 11 src_build_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) |
| 12 sys.path.insert(0, src_build_dir) |
| 13 |
| 14 import vs_toolchain |
| 15 |
| 16 |
| 17 def _CopyImpl(file_name, target_dir, source_dir, verbose=True): |
| 18 """Copy |source| to |target| if it doesn't already exist or if it |
| 19 needs to be updated. |
| 20 """ |
| 21 target = os.path.join(target_dir, file_name) |
| 22 source = os.path.join(source_dir, file_name) |
| 23 if (os.path.isdir(os.path.dirname(target)) and |
| 24 (not os.path.isfile(target) or |
| 25 os.stat(target).st_mtime != os.stat(source).st_mtime)): |
| 26 if verbose: |
| 27 print 'Copying %s to %s...' % (source, target) |
| 28 if os.path.exists(target): |
| 29 os.unlink(target) |
| 30 shutil.copy2(source, target) |
| 31 |
| 32 |
| 33 def _CopyCDBToOutput(output_dir, target_arch): |
| 34 """Copies the Windows debugging executable cdb.exe to the output |
| 35 directory. The output directory, and target architecture that should |
| 36 be copied, are passed. Supported values for the target architecture |
| 37 are the GYP values "ia32" and "x64". |
| 38 """ |
| 39 vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() |
| 40 win_sdk_dir = os.path.normpath(os.environ['WINDOWSSDKDIR']) |
| 41 if target_arch == 'ia32': |
| 42 src_arch = 'x86' |
| 43 elif target_arch == 'x64': |
| 44 src_arch = 'x64' |
| 45 else: |
| 46 print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch |
| 47 sys.exit(1) |
| 48 # We need to copy multiple files, so cache the computed source directory. |
| 49 src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch) |
| 50 # Note that the outputs from the "copy_cdb_to_output" target need to |
| 51 # be kept in sync with this list. |
| 52 _CopyImpl('cdb.exe', output_dir, src_dir) |
| 53 _CopyImpl('dbgeng.dll', output_dir, src_dir) |
| 54 _CopyImpl('dbghelp.dll', output_dir, src_dir) |
| 55 _CopyImpl('dbgmodel.dll', output_dir, src_dir) |
| 56 return 0 |
| 57 |
| 58 |
| 59 def main(): |
| 60 if len(sys.argv) < 2: |
| 61 print >>sys.stderr, 'Usage: copy_cdb_to_output.py <output_dir> ' + \ |
| 62 '<target_arch>' |
| 63 return 1 |
| 64 return _CopyCDBToOutput(sys.argv[1], sys.argv[2]) |
| 65 |
| 66 |
| 67 if __name__ == '__main__': |
| 68 sys.exit(main()) |
OLD | NEW |