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

Side by Side Diff: native_client_sdk/src/build_tools/build_projects.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 multiprocessing 7 import multiprocessing
7 import optparse
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import sys 10 import sys
11 import urllib2 11 import urllib2
12 12
13 import buildbot_common 13 import buildbot_common
14 import build_version 14 import build_version
15 import generate_make 15 import generate_make
16 import parse_dsc 16 import parse_dsc
17 17
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 clean=False, config='Debug'): 236 clean=False, config='Debug'):
237 # Make sure we build libraries (which live in 'src') before 237 # Make sure we build libraries (which live in 'src') before
238 # any of the examples. 238 # any of the examples.
239 build_first = [p for p in project_tree if p != 'src'] 239 build_first = [p for p in project_tree if p != 'src']
240 build_second = [p for p in project_tree if p == 'src'] 240 build_second = [p for p in project_tree if p == 'src']
241 241
242 for branch in build_first + build_second: 242 for branch in build_first + build_second:
243 BuildProjectsBranch(pepperdir, branch, deps, clean, config) 243 BuildProjectsBranch(pepperdir, branch, deps, clean, config)
244 244
245 245
246 def main(argv): 246 def main(args):
247 parser = optparse.OptionParser() 247 parser = argparse.ArgumentParser(description=__doc__)
248 parser.add_option('-c', '--clobber', 248 parser.add_argument('-c', '--clobber',
249 help='Clobber project directories before copying new files', 249 help='Clobber project directories before copying new files',
250 action='store_true', default=False) 250 action='store_true', default=False)
251 parser.add_option('-b', '--build', 251 parser.add_argument('-b', '--build',
252 help='Build the projects. Otherwise the projects are only copied.', 252 help='Build the projects. Otherwise the projects are only copied.',
253 action='store_true') 253 action='store_true')
254 parser.add_option('--config', 254 parser.add_argument('--config',
255 help='Choose configuration to build (Debug or Release). Builds both ' 255 help='Choose configuration to build (Debug or Release). Builds both '
256 'by default') 256 'by default')
257 parser.add_option('--bionic', 257 parser.add_argument('--bionic',
258 help='Enable bionic projects', action='store_true') 258 help='Enable bionic projects', action='store_true')
259 parser.add_option('-x', '--experimental', 259 parser.add_argument('-x', '--experimental',
260 help='Build experimental projects', action='store_true') 260 help='Build experimental projects', action='store_true')
261 parser.add_option('-t', '--toolchain', 261 parser.add_argument('-t', '--toolchain',
262 help='Build using toolchain. Can be passed more than once.', 262 help='Build using toolchain. Can be passed more than once.',
263 action='append', default=[]) 263 action='append', default=[])
264 parser.add_option('-d', '--dest', 264 parser.add_argument('-d', '--dest',
265 help='Select which build destinations (project types) are valid.', 265 help='Select which build destinations (project types) are valid.',
266 action='append') 266 action='append')
267 parser.add_option('-v', '--verbose', action='store_true') 267 parser.add_argument('projects', nargs='*',
268 help='Select which projects to build.')
269 parser.add_argument('-v', '--verbose', action='store_true')
268 270
269 # To setup bash completion for this command first install optcomplete 271 # To setup bash completion for this command first install optcomplete
270 # and then add this line to your .bashrc: 272 # and then add this line to your .bashrc:
271 # complete -F _optcomplete build_projects.py 273 # complete -F _optcomplete build_projects.py
272 try: 274 try:
273 import optcomplete 275 import optcomplete
274 optcomplete.autocomplete(parser) 276 optcomplete.autocomplete(parser)
275 except ImportError: 277 except ImportError:
276 pass 278 pass
277 279
278 options, args = parser.parse_args(argv) 280 options = parser.parse_args(args)
279 281
280 global verbose 282 global verbose
281 if options.verbose: 283 if options.verbose:
282 verbose = True 284 verbose = True
283 285
284 buildbot_common.verbose = verbose 286 buildbot_common.verbose = verbose
285 287
286 if 'NACL_SDK_ROOT' in os.environ: 288 if 'NACL_SDK_ROOT' in os.environ:
287 # We don't want the currently configured NACL_SDK_ROOT to have any effect 289 # We don't want the currently configured NACL_SDK_ROOT to have any effect
288 # on the build. 290 # on the build.
(...skipping 20 matching lines...) Expand all
309 311
310 filters = {} 312 filters = {}
311 if options.toolchain: 313 if options.toolchain:
312 filters['TOOLS'] = options.toolchain 314 filters['TOOLS'] = options.toolchain
313 Trace('Filter by toolchain: ' + str(options.toolchain)) 315 Trace('Filter by toolchain: ' + str(options.toolchain))
314 if not options.experimental: 316 if not options.experimental:
315 filters['EXPERIMENTAL'] = False 317 filters['EXPERIMENTAL'] = False
316 if options.dest: 318 if options.dest:
317 filters['DEST'] = options.dest 319 filters['DEST'] = options.dest
318 Trace('Filter by type: ' + str(options.dest)) 320 Trace('Filter by type: ' + str(options.dest))
319 if args: 321 if options.projects:
320 filters['NAME'] = args 322 filters['NAME'] = options.projects
321 Trace('Filter by name: ' + str(args)) 323 Trace('Filter by name: ' + str(options.projects))
322 324
323 try: 325 try:
324 project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) 326 project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters)
325 except parse_dsc.ValidationError as e: 327 except parse_dsc.ValidationError as e:
326 buildbot_common.ErrorExit(str(e)) 328 buildbot_common.ErrorExit(str(e))
327 329
328 if verbose: 330 if verbose:
329 parse_dsc.PrintProjectTree(project_tree) 331 parse_dsc.PrintProjectTree(project_tree)
330 332
331 UpdateHelpers(pepperdir, clobber=options.clobber) 333 UpdateHelpers(pepperdir, clobber=options.clobber)
(...skipping 12 matching lines...) Expand all
344 346
345 347
346 if __name__ == '__main__': 348 if __name__ == '__main__':
347 script_name = os.path.basename(sys.argv[0]) 349 script_name = os.path.basename(sys.argv[0])
348 try: 350 try:
349 sys.exit(main(sys.argv[1:])) 351 sys.exit(main(sys.argv[1:]))
350 except parse_dsc.ValidationError as e: 352 except parse_dsc.ValidationError as e:
351 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) 353 buildbot_common.ErrorExit('%s: %s' % (script_name, e))
352 except KeyboardInterrupt: 354 except KeyboardInterrupt:
353 buildbot_common.ErrorExit('%s: interrupted' % script_name) 355 buildbot_common.ErrorExit('%s: interrupted' % script_name)
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/build_app.py ('k') | native_client_sdk/src/build_tools/build_sdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698