OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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 | |
4 # found in the LICENSE file. | |
5 | |
6 import glob | |
7 import optparse | |
8 import os | |
9 import shutil | |
10 import subprocess | |
11 import sys | |
12 | |
13 def reorder_imports(input_dir, output_dir): | |
14 """Run swapimports.exe on the initial chrome.exe, and write to the output | |
15 directory. Also copy over any related files that might be needed | |
16 (pdbs, manifests etc.). | |
17 """ | |
18 input_image = '--input-image=%s' % (os.path.join(input_dir, 'chrome.exe')) | |
19 output_image = '--output-image=%s' % (os.path.join(output_dir, 'chrome.exe')) | |
20 | |
21 swap_exe = os.path.join( | |
22 __file__, '..\\..\\..\\third_party\\syzygy\\binaries\\exe\\swapimport.exe') | |
robertshield
2014/01/11 02:16:07
are in-statement indents 2 or 4 spaces in Chromium
| |
23 subprocess.call( | |
24 [swap_exe, input_image, output_image, '--overwrite', 'chrome_elf.dll']) | |
25 | |
26 for fname in glob.iglob(os.path.join(input_dir, 'chrome.exe.*')): | |
27 shutil.copy(fname, os.path.join(output_dir, os.path.basename(fname))) | |
28 return 0 | |
29 | |
30 | |
31 def main(argv): | |
32 usage = 'reorder_imports.py -i <input_dir> -o <output_dir>' | |
33 parser = optparse.OptionParser(usage=usage) | |
34 parser.add_option('-i', '--input', help='reorder chrome.exe in DIR', | |
35 metavar='DIR') | |
36 parser.add_option('-o', '--output', help='write new chrome.exe to DIR', | |
37 metavar='DIR') | |
38 opts, args = parser.parse_args() | |
39 | |
40 if not opts.input or not opts.output: | |
41 print 'Please provide and input and output directory' | |
42 return 0; | |
43 return reorder_imports(opts.input, opts.output) | |
44 | |
45 if __name__ == "__main__": | |
46 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |