2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2016-11-26 03:15:51 +00:00
|
|
|
# Copyright (c) 2016 Google, Inc
|
|
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
|
|
#
|
|
|
|
# Command-line parser for binman
|
|
|
|
#
|
|
|
|
|
2019-07-08 20:25:29 +00:00
|
|
|
from argparse import ArgumentParser
|
2016-11-26 03:15:51 +00:00
|
|
|
|
|
|
|
def ParseArgs(argv):
|
|
|
|
"""Parse the binman command-line arguments
|
|
|
|
|
|
|
|
Args:
|
|
|
|
argv: List of string arguments
|
|
|
|
Returns:
|
|
|
|
Tuple (options, args) with the command-line options and arugments.
|
|
|
|
options provides access to the options (e.g. option.debug)
|
|
|
|
args is a list of string arguments
|
|
|
|
"""
|
2019-07-08 20:25:29 +00:00
|
|
|
if '-H' in argv:
|
|
|
|
argv.append('build')
|
|
|
|
|
|
|
|
epilog = '''Binman creates and manipulate images for a board from a set of binaries. Binman is
|
|
|
|
controlled by a description in the board device tree.'''
|
|
|
|
|
|
|
|
parser = ArgumentParser(epilog=epilog)
|
|
|
|
parser.add_argument('-B', '--build-dir', type=str, default='b',
|
|
|
|
help='Directory containing the build output')
|
|
|
|
parser.add_argument('-D', '--debug', action='store_true',
|
|
|
|
help='Enabling debugging (provides a full traceback on error)')
|
|
|
|
parser.add_argument('-H', '--full-help', action='store_true',
|
|
|
|
default=False, help='Display the README file')
|
|
|
|
parser.add_argument('--toolpath', type=str, action='append',
|
|
|
|
help='Add a path to the directories containing tools')
|
|
|
|
parser.add_argument('-v', '--verbosity', default=1,
|
|
|
|
type=int, help='Control verbosity: 0=silent, 1=warnings, 2=notices, '
|
|
|
|
'3=info, 4=detail, 5=debug')
|
|
|
|
|
|
|
|
subparsers = parser.add_subparsers(dest='cmd')
|
|
|
|
|
|
|
|
build_parser = subparsers.add_parser('build', help='Build firmware image')
|
|
|
|
build_parser.add_argument('-a', '--entry-arg', type=str, action='append',
|
2018-07-17 19:25:32 +00:00
|
|
|
help='Set argument value arg=value')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-b', '--board', type=str,
|
2016-11-26 03:15:51 +00:00
|
|
|
help='Board name to build')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-d', '--dt', type=str,
|
2016-11-26 03:15:51 +00:00
|
|
|
help='Configuration file (.dtb) to use')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('--fake-dtb', action='store_true',
|
2018-09-14 10:57:23 +00:00
|
|
|
help='Use fake device tree contents (for testing only)')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-i', '--image', type=str, action='append',
|
2018-09-14 10:57:12 +00:00
|
|
|
help='Image filename to build (if not specified, build all)')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-I', '--indir', action='append',
|
2019-07-08 19:18:31 +00:00
|
|
|
help='Add a path to the list of directories to use for input files')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-m', '--map', action='store_true',
|
2018-06-01 15:38:20 +00:00
|
|
|
default=False, help='Output a map file for each image')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-O', '--outdir', type=str,
|
2016-11-26 03:15:51 +00:00
|
|
|
action='store', help='Path to directory to use for intermediate and '
|
|
|
|
'output files')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-p', '--preserve', action='store_true',\
|
2016-11-26 03:15:51 +00:00
|
|
|
help='Preserve temporary output directory even if option -O is not '
|
|
|
|
'given')
|
2019-07-08 20:25:29 +00:00
|
|
|
build_parser.add_argument('-u', '--update-fdt', action='store_true',
|
2018-08-01 21:22:37 +00:00
|
|
|
default=False, help='Update the binman node with offset/size info')
|
2019-07-08 20:25:29 +00:00
|
|
|
|
|
|
|
entry_parser = subparsers.add_parser('entry-docs',
|
|
|
|
help='Write out entry documentation (see README.entries)')
|
|
|
|
|
2019-07-08 20:25:48 +00:00
|
|
|
list_parser = subparsers.add_parser('ls', help='List files in an image')
|
|
|
|
list_parser.add_argument('-i', '--image', type=str, required=True,
|
|
|
|
help='Image filename to list')
|
|
|
|
list_parser.add_argument('paths', type=str, nargs='*',
|
|
|
|
help='Paths within file to list (wildcard)')
|
|
|
|
|
2019-07-08 20:25:29 +00:00
|
|
|
test_parser = subparsers.add_parser('test', help='Run tests')
|
|
|
|
test_parser.add_argument('-P', '--processes', type=int,
|
|
|
|
help='set number of processes to use for running tests')
|
|
|
|
test_parser.add_argument('-T', '--test-coverage', action='store_true',
|
|
|
|
default=False, help='run tests and check for 100%% coverage')
|
|
|
|
test_parser.add_argument('-X', '--test-preserve-dirs', action='store_true',
|
2019-07-08 19:18:49 +00:00
|
|
|
help='Preserve and display test-created input directories; also '
|
|
|
|
'preserve the output directory if a single test is run (pass test '
|
|
|
|
'name at the end of the command line')
|
2019-07-08 20:25:29 +00:00
|
|
|
test_parser.add_argument('tests', nargs='*',
|
|
|
|
help='Test names to run (omit for all)')
|
2016-11-26 03:15:51 +00:00
|
|
|
|
|
|
|
return parser.parse_args(argv)
|