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