Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / build / android / gyp / strip_library_for_device.py
blob9e2daae33acfa057f23eb2c53b1cd6ed47c9bfb5
1 #!/usr/bin/env python
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
5 # found in the LICENSE file.
7 import optparse
8 import os
9 import sys
11 from util import build_utils
14 def StripLibrary(android_strip, android_strip_args, library_path, output_path):
15 if build_utils.IsTimeStale(output_path, [library_path]):
16 strip_cmd = ([android_strip] +
17 android_strip_args +
18 ['-o', output_path, library_path])
19 build_utils.CheckOutput(strip_cmd)
22 def main(args):
23 args = build_utils.ExpandFileArgs(args)
25 parser = optparse.OptionParser()
26 build_utils.AddDepfileOption(parser)
28 parser.add_option('--android-strip',
29 help='Path to the toolchain\'s strip binary')
30 parser.add_option('--android-strip-arg', action='append',
31 help='Argument to be passed to strip')
32 parser.add_option('--libraries-dir',
33 help='Directory for un-stripped libraries')
34 parser.add_option('--stripped-libraries-dir',
35 help='Directory for stripped libraries')
36 parser.add_option('--libraries',
37 help='List of libraries to strip')
38 parser.add_option('--stamp', help='Path to touch on success')
40 options, _ = parser.parse_args(args)
42 libraries = build_utils.ParseGypList(options.libraries)
44 build_utils.MakeDirectory(options.stripped_libraries_dir)
46 for library in libraries:
47 for base_path in options.libraries_dir.split(','):
48 library_path = os.path.join(base_path, library)
49 if (os.path.exists(library_path)):
50 break
51 stripped_library_path = os.path.join(
52 options.stripped_libraries_dir, library)
53 StripLibrary(options.android_strip, options.android_strip_arg, library_path,
54 stripped_library_path)
56 if options.stamp:
57 build_utils.Touch(options.stamp)
60 if __name__ == '__main__':
61 sys.exit(main(sys.argv[1:]))