OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 glob | 6 import glob |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 13 matching lines...) Expand all Loading... |
24 '..\\..\\..\\third_party\\syzygy\\binaries\\exe\\swapimport.exe') | 24 '..\\..\\..\\third_party\\syzygy\\binaries\\exe\\swapimport.exe') |
25 | 25 |
26 args = [swap_exe, '--input-image=%s' % input_image, | 26 args = [swap_exe, '--input-image=%s' % input_image, |
27 '--output-image=%s' % output_image, '--overwrite', '--no-logo'] | 27 '--output-image=%s' % output_image, '--overwrite', '--no-logo'] |
28 | 28 |
29 if architecture == 'x64': | 29 if architecture == 'x64': |
30 args.append('--x64'); | 30 args.append('--x64'); |
31 | 31 |
32 args.append('chrome_elf.dll'); | 32 args.append('chrome_elf.dll'); |
33 | 33 |
34 subprocess.call(args) | 34 subprocess.check_call(args) |
35 | 35 |
36 for fname in glob.iglob(os.path.join(input_dir, 'chrome.exe.*')): | 36 for fname in glob.iglob(os.path.join(input_dir, 'chrome.exe.*')): |
37 shutil.copy(fname, os.path.join(output_dir, os.path.basename(fname))) | 37 shutil.copy(fname, os.path.join(output_dir, os.path.basename(fname))) |
38 return 0 | 38 return 0 |
39 | 39 |
40 | 40 |
41 def main(argv): | 41 def main(argv): |
42 usage = 'reorder_imports.py -i <input_dir> -o <output_dir> -a <target_arch>' | 42 usage = 'reorder_imports.py -i <input_dir> -o <output_dir> -a <target_arch>' |
43 parser = optparse.OptionParser(usage=usage) | 43 parser = optparse.OptionParser(usage=usage) |
44 parser.add_option('-i', '--input', help='reorder chrome.exe in DIR', | 44 parser.add_option('-i', '--input', help='reorder chrome.exe in DIR', |
45 metavar='DIR') | 45 metavar='DIR') |
46 parser.add_option('-o', '--output', help='write new chrome.exe to DIR', | 46 parser.add_option('-o', '--output', help='write new chrome.exe to DIR', |
47 metavar='DIR') | 47 metavar='DIR') |
48 parser.add_option('-a', '--arch', help='architecture of build (optional)', | 48 parser.add_option('-a', '--arch', help='architecture of build (optional)', |
49 default='ia32') | 49 default='ia32') |
50 opts, args = parser.parse_args() | 50 opts, args = parser.parse_args() |
51 | 51 |
52 if not opts.input or not opts.output: | 52 if not opts.input or not opts.output: |
53 parser.error('Please provide and input and output directory') | 53 parser.error('Please provide and input and output directory') |
54 return reorder_imports(opts.input, opts.output, opts.arch) | 54 return reorder_imports(opts.input, opts.output, opts.arch) |
55 | 55 |
56 if __name__ == "__main__": | 56 if __name__ == "__main__": |
57 sys.exit(main(sys.argv[1:])) | 57 sys.exit(main(sys.argv[1:])) |
OLD | NEW |