• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
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.
6
7import optparse
8import os
9import sys
10
11from util import build_utils
12
13
14def 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)
20
21
22def main(args):
23  args = build_utils.ExpandFileArgs(args)
24
25  parser = optparse.OptionParser()
26  build_utils.AddDepfileOption(parser)
27
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')
39
40  options, _ = parser.parse_args(args)
41
42  libraries = build_utils.ParseGypList(options.libraries)
43
44  build_utils.MakeDirectory(options.stripped_libraries_dir)
45
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)
55
56  if options.stamp:
57    build_utils.Touch(options.stamp)
58
59
60if __name__ == '__main__':
61  sys.exit(main(sys.argv[1:]))
62