Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: build/android/gyp/strip_library_for_device.py

Issue 1647353002: Use gn_helpers to [se]serialize GN lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@python_impl
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gyp/insert_chromium_version.py ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ast
7 import optparse 8 import optparse
8 import os 9 import os
9 import sys 10 import sys
10 11
11 from util import build_utils 12 from util import build_utils
12 13
13 14
14 def StripLibrary(android_strip, android_strip_args, library_path, output_path): 15 def StripLibrary(android_strip, android_strip_args, library_path, output_path):
15 if build_utils.IsTimeStale(output_path, [library_path]): 16 if build_utils.IsTimeStale(output_path, [library_path]):
16 strip_cmd = ([android_strip] + 17 strip_cmd = ([android_strip] +
17 android_strip_args + 18 android_strip_args +
18 ['-o', output_path, library_path]) 19 ['-o', output_path, library_path])
19 build_utils.CheckOutput(strip_cmd) 20 build_utils.CheckOutput(strip_cmd)
20 21
21 22
22 def main(args): 23 def main(args):
23 args = build_utils.ExpandFileArgs(args) 24 args = build_utils.ExpandFileArgs(args)
24 25
25 parser = optparse.OptionParser() 26 parser = optparse.OptionParser()
26 build_utils.AddDepfileOption(parser) 27 build_utils.AddDepfileOption(parser)
27 28
28 parser.add_option('--android-strip', 29 parser.add_option('--android-strip',
29 help='Path to the toolchain\'s strip binary') 30 help='Path to the toolchain\'s strip binary')
30 parser.add_option('--android-strip-arg', action='append', 31 parser.add_option('--android-strip-arg', action='append',
31 help='Argument to be passed to strip') 32 help='Argument to be passed to strip')
32 parser.add_option('--libraries-dir', 33 parser.add_option('--libraries-dir',
33 help='Directory for un-stripped libraries') 34 help='Directory for un-stripped libraries')
34 parser.add_option('--stripped-libraries-dir', 35 parser.add_option('--stripped-libraries-dir',
35 help='Directory for stripped libraries') 36 help='Directory for stripped libraries in JSON format')
36 parser.add_option('--libraries', 37 parser.add_option('--libraries',
37 help='List of libraries to strip') 38 help='List of libraries to strip in JSON format.')
38 parser.add_option('--stamp', help='Path to touch on success') 39 parser.add_option('--stamp', help='Path to touch on success')
39 40
40 options, _ = parser.parse_args(args) 41 options, _ = parser.parse_args(args)
41 42
42 libraries = build_utils.ParseGypList(options.libraries) 43 libraries = ast.literal_eval(options.libraries)
Dirk Pranke 2016/01/30 00:26:48 if this is in JSON format, why are you using liter
brettw 2016/01/30 05:48:22 Clarified to "Python dictionary format"
43 44
44 build_utils.MakeDirectory(options.stripped_libraries_dir) 45 build_utils.MakeDirectory(options.stripped_libraries_dir)
45 46
46 for library in libraries: 47 for library in libraries:
47 for base_path in options.libraries_dir.split(','): 48 for base_path in options.libraries_dir.split(','):
48 library_path = os.path.join(base_path, library) 49 library_path = os.path.join(base_path, library)
49 if (os.path.exists(library_path)): 50 if (os.path.exists(library_path)):
50 break 51 break
51 stripped_library_path = os.path.join( 52 stripped_library_path = os.path.join(
52 options.stripped_libraries_dir, library) 53 options.stripped_libraries_dir, library)
53 StripLibrary(options.android_strip, options.android_strip_arg, library_path, 54 StripLibrary(options.android_strip, options.android_strip_arg, library_path,
54 stripped_library_path) 55 stripped_library_path)
55 56
56 if options.stamp: 57 if options.stamp:
57 build_utils.Touch(options.stamp) 58 build_utils.Touch(options.stamp)
58 59
59 60
60 if __name__ == '__main__': 61 if __name__ == '__main__':
61 sys.exit(main(sys.argv[1:])) 62 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/insert_chromium_version.py ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698