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

Side by Side Diff: native_client_sdk/src/build_tools/parse_dsc.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse
6 import collections 7 import collections
7 import fnmatch 8 import fnmatch
8 import optparse
9 import os 9 import os
10 import sys 10 import sys
11 11
12 VALID_TOOLCHAINS = [ 12 VALID_TOOLCHAINS = [
13 'bionic', 13 'bionic',
14 'newlib', 14 'newlib',
15 'glibc', 15 'glibc',
16 'pnacl', 16 'pnacl',
17 'win', 17 'win',
18 'linux', 18 'linux',
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return True 237 return True
238 238
239 239
240 def PrintProjectTree(tree): 240 def PrintProjectTree(tree):
241 for key in tree: 241 for key in tree:
242 print key + ':' 242 print key + ':'
243 for val in tree[key]: 243 for val in tree[key]:
244 print '\t' + val['NAME'] 244 print '\t' + val['NAME']
245 245
246 246
247 def main(argv): 247 def main(args):
248 parser = optparse.OptionParser(usage='%prog [options] <dir>') 248 parser = argparse.ArgumentParser(description=__doc__)
249 parser.add_option('-e', '--experimental', 249 parser.add_argument('-e', '--experimental',
250 help='build experimental examples and libraries', action='store_true') 250 help='build experimental examples and libraries', action='store_true')
251 parser.add_option('-t', '--toolchain', 251 parser.add_argument('-t', '--toolchain',
252 help='Build using toolchain. Can be passed more than once.', 252 help='Build using toolchain. Can be passed more than once.',
253 action='append') 253 action='append')
254 parser.add_argument('project_root', default='.')
254 255
255 options, args = parser.parse_args(argv) 256 options = parser.parse_args(args)
256 filters = {} 257 filters = {}
257 258
258 load_from_dir = '.'
259 if len(args) > 1:
260 parser.error('Expected 0 or 1 args, got %d.' % len(args))
261
262 if args:
263 load_from_dir = args[0]
264
265 if options.toolchain: 259 if options.toolchain:
266 filters['TOOLS'] = options.toolchain 260 filters['TOOLS'] = options.toolchain
267 261
268 if not options.experimental: 262 if not options.experimental:
269 filters['EXPERIMENTAL'] = False 263 filters['EXPERIMENTAL'] = False
270 264
271 try: 265 try:
272 tree = LoadProjectTree(load_from_dir, include=filters) 266 tree = LoadProjectTree(options.project_root, include=filters)
273 except ValidationError as e: 267 except ValidationError as e:
274 sys.stderr.write(str(e) + '\n') 268 sys.stderr.write(str(e) + '\n')
275 return 1 269 return 1
276 270
277 PrintProjectTree(tree) 271 PrintProjectTree(tree)
278 return 0 272 return 0
279 273
280 274
281 if __name__ == '__main__': 275 if __name__ == '__main__':
282 sys.exit(main(sys.argv[1:])) 276 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/nacl-mono-builder.py ('k') | native_client_sdk/src/build_tools/test_projects.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698