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