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 _NormalizePath(path): | |
18 while path.endswith("\\"): | |
19 path = path[:-1] | |
20 return path | |
21 | |
22 | |
23 def _CopyImpl(file_name, target_dir, source_dir, verbose=True): | |
24 """Copy |source| to |target| if it doesn't already exist or if it | |
25 needs to be updated. | |
26 """ | |
27 target = os.path.join(target_dir, file_name) | |
28 source = os.path.join(source_dir, file_name) | |
29 if (os.path.isdir(os.path.dirname(target)) and | |
30 (not os.path.isfile(target) or | |
31 os.stat(target).st_mtime != os.stat(source).st_mtime)): | |
scottmg
2016/04/05 16:41:28
+1 space on this line, otherwise it's a bit mislea
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
Done.
| |
32 if verbose: | |
33 print 'Copying %s to %s...' % (source, target) | |
34 if os.path.exists(target): | |
35 os.unlink(target) | |
36 shutil.copy2(source, target) | |
37 | |
38 | |
39 def _CopyCDBToOutput(output_dir, target_arch): | |
40 """Copies the Windows debugging executable cdb.exe to the output | |
41 directory. The output directory, and target architecture that should | |
42 be copied, are passed. Supported values for the target architecture | |
43 are the GYP values "ia32" and "x64". | |
44 """ | |
45 vs_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() | |
M-A Ruel
2016/04/05 10:41:06
Does this work when it finds the directory in c:\p
scottmg
2016/04/05 16:41:28
You don't use the return value here, just remove t
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
Done.
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
It shouldn't find it there -- that script is what
| |
46 win_sdk_dir = _NormalizePath(os.environ['WINDOWSSDKDIR']) | |
scottmg
2016/04/05 16:41:28
How about `os.path.normpath(os.environ['WINDOWSSDK
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
Sure. I was just following the pattern in vs_toolc
| |
47 if target_arch == 'ia32': | |
48 src_arch = 'x86' | |
49 elif target_arch == 'x64': | |
50 src_arch = 'x64' | |
51 else: | |
52 print 'copy_cdb_to_output.py: unknown target_arch %s' % target_arch | |
53 sys.exit(1) | |
54 # We need to copy multiple files, so cache the computed source directory. | |
55 src_dir = os.path.join(win_sdk_dir, 'Debuggers', src_arch) | |
56 _CopyImpl('cdb.exe', output_dir, src_dir) | |
scottmg
2016/04/05 16:41:28
Hopefully this set is sufficient. Note here that t
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
Added a note. Will update this set, and the isolat
| |
57 _CopyImpl('dbgeng.dll', output_dir, src_dir) | |
58 _CopyImpl('dbghelp.dll', output_dir, src_dir) | |
59 _CopyImpl('dbgmodel.dll', output_dir, src_dir) | |
60 return 0 | |
61 | |
62 | |
63 def main(): | |
64 if len(sys.argv) < 2: | |
65 print >>sys.stderr, 'Usage: copy_cdb_to_output.py [output_dir] ' + \ | |
scottmg
2016/04/05 16:41:28
nit; normally [] indicate optional arguments, but
Ken Russell (switch to Gerrit)
2016/04/05 17:18:09
Changed to use <>.
| |
66 '[target_arch]' | |
67 return 1 | |
68 return _CopyCDBToOutput(sys.argv[1], sys.argv[2]) | |
69 | |
70 | |
71 if __name__ == '__main__': | |
72 sys.exit(main()) | |
OLD | NEW |