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.
12 from util
import build_utils
15 def StripLibrary(android_strip
, android_strip_args
, library_path
, output_path
):
16 if build_utils
.IsTimeStale(output_path
, [library_path
]):
17 strip_cmd
= ([android_strip
] +
19 ['-o', output_path
, library_path
])
20 build_utils
.CheckCallDie(strip_cmd
)
25 parser
= optparse
.OptionParser()
27 parser
.add_option('--android-strip',
28 help='Path to the toolchain\'s strip binary')
29 parser
.add_option('--android-strip-arg', action
='append',
30 help='Argument to be passed to strip')
31 parser
.add_option('--libraries-dir',
32 help='Directory for un-stripped libraries')
33 parser
.add_option('--stripped-libraries-dir',
34 help='Directory for stripped libraries')
35 parser
.add_option('--libraries-file',
36 help='Path to json file containing list of libraries')
37 parser
.add_option('--stamp', help='Path to touch on success')
40 options
, _
= parser
.parse_args()
42 with
open(options
.libraries_file
, 'r') as libfile
:
43 libraries
= json
.load(libfile
)
45 build_utils
.MakeDirectory(options
.stripped_libraries_dir
)
47 for library
in libraries
:
48 library_path
= os
.path
.join(options
.libraries_dir
, library
)
49 stripped_library_path
= os
.path
.join(
50 options
.stripped_libraries_dir
, library
)
51 StripLibrary(options
.android_strip
, options
.android_strip_arg
, library_path
,
52 stripped_library_path
)
55 build_utils
.Touch(options
.stamp
)
58 if __name__
== '__main__':
59 sys
.exit(main(sys
.argv
))