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 json | |
8 import optparse | 7 import optparse |
9 import os | 8 import os |
10 import sys | 9 import sys |
11 | 10 |
12 from util import build_utils | 11 from util 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 if build_utils.IsTimeStale(output_path, [library_path]): | 15 if build_utils.IsTimeStale(output_path, [library_path]): |
17 strip_cmd = ([android_strip] + | 16 strip_cmd = ([android_strip] + |
18 android_strip_args + | 17 android_strip_args + |
19 ['-o', output_path, library_path]) | 18 ['-o', output_path, library_path]) |
20 build_utils.CheckOutput(strip_cmd) | 19 build_utils.CheckOutput(strip_cmd) |
21 | 20 |
22 | 21 |
| 22 def main(args): |
| 23 args = build_utils.ExpandFileArgs(args) |
23 | 24 |
24 def main(): | |
25 parser = optparse.OptionParser() | 25 parser = optparse.OptionParser() |
| 26 build_utils.AddDepfileOption(parser) |
26 | 27 |
27 parser.add_option('--android-strip', | 28 parser.add_option('--android-strip', |
28 help='Path to the toolchain\'s strip binary') | 29 help='Path to the toolchain\'s strip binary') |
29 parser.add_option('--android-strip-arg', action='append', | 30 parser.add_option('--android-strip-arg', action='append', |
30 help='Argument to be passed to strip') | 31 help='Argument to be passed to strip') |
31 parser.add_option('--libraries-dir', | 32 parser.add_option('--libraries-dir', |
32 help='Directory for un-stripped libraries') | 33 help='Directory for un-stripped libraries') |
33 parser.add_option('--stripped-libraries-dir', | 34 parser.add_option('--stripped-libraries-dir', |
34 help='Directory for stripped libraries') | 35 help='Directory for stripped libraries') |
35 parser.add_option('--libraries-file', | 36 parser.add_option('--libraries', |
36 help='Path to json file containing list of libraries') | 37 help='List of libraries to strip') |
37 parser.add_option('--stamp', help='Path to touch on success') | 38 parser.add_option('--stamp', help='Path to touch on success') |
38 | 39 |
| 40 options, _ = parser.parse_args(args) |
39 | 41 |
40 options, _ = parser.parse_args() | 42 libraries = build_utils.ParseGypList(options.libraries) |
41 | |
42 with open(options.libraries_file, 'r') as libfile: | |
43 libraries = json.load(libfile) | |
44 | 43 |
45 build_utils.MakeDirectory(options.stripped_libraries_dir) | 44 build_utils.MakeDirectory(options.stripped_libraries_dir) |
46 | 45 |
47 for library in libraries: | 46 for library in libraries: |
48 for base_path in options.libraries_dir.split(','): | 47 for base_path in options.libraries_dir.split(','): |
49 library_path = os.path.join(base_path, library) | 48 library_path = os.path.join(base_path, library) |
50 if (os.path.exists(library_path)): | 49 if (os.path.exists(library_path)): |
51 break | 50 break |
52 stripped_library_path = os.path.join( | 51 stripped_library_path = os.path.join( |
53 options.stripped_libraries_dir, library) | 52 options.stripped_libraries_dir, library) |
54 StripLibrary(options.android_strip, options.android_strip_arg, library_path, | 53 StripLibrary(options.android_strip, options.android_strip_arg, library_path, |
55 stripped_library_path) | 54 stripped_library_path) |
56 | 55 |
57 if options.stamp: | 56 if options.stamp: |
58 build_utils.Touch(options.stamp) | 57 build_utils.Touch(options.stamp) |
59 | 58 |
60 | 59 |
61 if __name__ == '__main__': | 60 if __name__ == '__main__': |
62 sys.exit(main()) | 61 sys.exit(main(sys.argv[1:])) |
OLD | NEW |