xref: /openbmc/u-boot/tools/binman/cmdline.py (revision 341032d3)
1# SPDX-License-Identifier: GPL-2.0+
2# Copyright (c) 2016 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5# Command-line parser for binman
6#
7
8from optparse import OptionParser
9
10def ParseArgs(argv):
11    """Parse the binman command-line arguments
12
13    Args:
14        argv: List of string arguments
15    Returns:
16        Tuple (options, args) with the command-line options and arugments.
17            options provides access to the options (e.g. option.debug)
18            args is a list of string arguments
19    """
20    parser = OptionParser()
21    parser.add_option('-a', '--entry-arg', type='string', action='append',
22            help='Set argument value arg=value')
23    parser.add_option('-b', '--board', type='string',
24            help='Board name to build')
25    parser.add_option('-B', '--build-dir', type='string', default='b',
26            help='Directory containing the build output')
27    parser.add_option('-d', '--dt', type='string',
28            help='Configuration file (.dtb) to use')
29    parser.add_option('-D', '--debug', action='store_true',
30            help='Enabling debugging (provides a full traceback on error)')
31    parser.add_option('-E', '--entry-docs', action='store_true',
32            help='Write out entry documentation (see README.entries)')
33    parser.add_option('-I', '--indir', action='append',
34            help='Add a path to a directory to use for input files')
35    parser.add_option('-H', '--full-help', action='store_true',
36        default=False, help='Display the README file')
37    parser.add_option('-m', '--map', action='store_true',
38        default=False, help='Output a map file for each image')
39    parser.add_option('-O', '--outdir', type='string',
40        action='store', help='Path to directory to use for intermediate and '
41        'output files')
42    parser.add_option('-p', '--preserve', action='store_true',\
43        help='Preserve temporary output directory even if option -O is not '
44             'given')
45    parser.add_option('-t', '--test', action='store_true',
46                    default=False, help='run tests')
47    parser.add_option('-T', '--test-coverage', action='store_true',
48                    default=False, help='run tests and check for 100% coverage')
49    parser.add_option('-u', '--update-fdt', action='store_true',
50        default=False, help='Update the binman node with offset/size info')
51    parser.add_option('-v', '--verbosity', default=1,
52        type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, '
53        '4=debug')
54
55    parser.usage += """
56
57Create images for a board from a set of binaries. It is controlled by a
58description in the board device tree."""
59
60    return parser.parse_args(argv)
61