OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import subprocess | |
10 import sys | 9 import sys |
11 | 10 |
12 from pylib import build_utils | 11 from pylib import build_utils |
13 | 12 |
14 | 13 |
15 def StripLibrary(android_strip, android_strip_args, library_path, output_path): | 14 def StripLibrary(android_strip, android_strip_args, library_path, output_path): |
16 strip_cmd = ([android_strip] + | 15 strip_cmd = ([android_strip] + |
17 android_strip_args + | 16 android_strip_args + |
18 ['-o', output_path, library_path]) | 17 ['-o', output_path, library_path]) |
19 subprocess.check_call(strip_cmd) | 18 build_utils.CheckCallDie(strip_cmd) |
20 | 19 |
21 | 20 |
22 def main(argv): | 21 def main(argv): |
23 parser = optparse.OptionParser() | 22 parser = optparse.OptionParser() |
24 | 23 |
25 parser.add_option('--android-strip', | 24 parser.add_option('--android-strip', |
26 help='Path to the toolchain\'s strip binary') | 25 help='Path to the toolchain\'s strip binary') |
27 parser.add_option('--android-strip-arg', action='append', | 26 parser.add_option('--android-strip-arg', action='append', |
28 help='Argument to be passed to strip') | 27 help='Argument to be passed to strip') |
29 parser.add_option('--stripped-libraries-dir', | 28 parser.add_option('--stripped-libraries-dir', |
30 help='Directory for stripped libraries') | 29 help='Directory for stripped libraries') |
31 | 30 |
32 options, paths = parser.parse_args() | 31 options, paths = parser.parse_args() |
33 | 32 |
34 build_utils.MakeDirectory(options.stripped_libraries_dir) | 33 build_utils.MakeDirectory(options.stripped_libraries_dir) |
35 | 34 |
36 for library_path in paths: | 35 for library_path in paths: |
37 stripped_library_path = os.path.join(options.stripped_libraries_dir, | 36 stripped_library_path = os.path.join(options.stripped_libraries_dir, |
38 os.path.basename(library_path)) | 37 os.path.basename(library_path)) |
39 StripLibrary(options.android_strip, options.android_strip_arg, library_path, | 38 StripLibrary(options.android_strip, options.android_strip_arg, library_path, |
40 stripped_library_path) | 39 stripped_library_path) |
41 | 40 |
42 | 41 |
43 if __name__ == '__main__': | 42 if __name__ == '__main__': |
44 sys.exit(main(sys.argv)) | 43 sys.exit(main(sys.argv)) |
OLD | NEW |