Chromium Code Reviews| Index: native_client_sdk/src/build_tools/build_projects.py |
| diff --git a/native_client_sdk/src/build_tools/build_projects.py b/native_client_sdk/src/build_tools/build_projects.py |
| index 640bd0c9001cc8b9515eacedc763bd6d2e0878e2..6f83a731c40b0cf6f9e6a2bf25cb60c6b50e2305 100755 |
| --- a/native_client_sdk/src/build_tools/build_projects.py |
| +++ b/native_client_sdk/src/build_tools/build_projects.py |
| @@ -4,7 +4,7 @@ |
| # found in the LICENSE file. |
| import multiprocessing |
| -import optparse |
| +import argparse |
|
binji
2014/11/13 23:57:01
sort
Sam Clegg
2014/11/30 17:55:11
Done.
|
| import os |
| import posixpath |
| import sys |
| @@ -243,28 +243,30 @@ def BuildProjects(pepperdir, project_tree, deps=True, |
| BuildProjectsBranch(pepperdir, branch, deps, clean, config) |
| -def main(argv): |
| - parser = optparse.OptionParser() |
| - parser.add_option('-c', '--clobber', |
| +def main(args): |
| + parser = argparse.ArgumentParser(description=__doc__) |
| + parser.add_argument('-c', '--clobber', |
| help='Clobber project directories before copying new files', |
| action='store_true', default=False) |
| - parser.add_option('-b', '--build', |
| + parser.add_argument('-b', '--build', |
| help='Build the projects. Otherwise the projects are only copied.', |
| action='store_true') |
| - parser.add_option('--config', |
| + parser.add_argument('--config', |
| help='Choose configuration to build (Debug or Release). Builds both ' |
| 'by default') |
| - parser.add_option('--bionic', |
| + parser.add_argument('--bionic', |
| help='Enable bionic projects', action='store_true') |
| - parser.add_option('-x', '--experimental', |
| + parser.add_argument('-x', '--experimental', |
| help='Build experimental projects', action='store_true') |
| - parser.add_option('-t', '--toolchain', |
| + parser.add_argument('-t', '--toolchain', |
| help='Build using toolchain. Can be passed more than once.', |
| action='append', default=[]) |
| - parser.add_option('-d', '--dest', |
| + parser.add_argument('-d', '--dest', |
| help='Select which build destinations (project types) are valid.', |
| action='append') |
| - parser.add_option('-v', '--verbose', action='store_true') |
| + parser.add_argument('projects', nargs='*', |
| + help='Select which projects to build.') |
| + parser.add_argument('-v', '--verbose', action='store_true') |
| # To setup bash completion for this command first install optcomplete |
| # and then add this line to your .bashrc: |
| @@ -275,7 +277,7 @@ def main(argv): |
| except ImportError: |
| pass |
| - options, args = parser.parse_args(argv[1:]) |
| + options = parser.parse_args(args) |
| global verbose |
| if options.verbose: |
| @@ -316,9 +318,9 @@ def main(argv): |
| if options.dest: |
| filters['DEST'] = options.dest |
| Trace('Filter by type: ' + str(options.dest)) |
| - if args: |
| - filters['NAME'] = args |
| - Trace('Filter by name: ' + str(args)) |
| + if options.projects: |
| + filters['NAME'] = options.projects |
| + Trace('Filter by name: ' + str(options.projects)) |
| try: |
| project_tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) |
| @@ -346,7 +348,7 @@ def main(argv): |
| if __name__ == '__main__': |
| script_name = os.path.basename(sys.argv[0]) |
| try: |
| - sys.exit(main(sys.argv)) |
| + sys.exit(main(sys.argv[1:])) |
| except parse_dsc.ValidationError as e: |
| buildbot_common.ErrorExit('%s: %s' % (script_name, e)) |
| except KeyboardInterrupt: |