Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 2 | # Copyright (c) 2016 Google, Inc |
| 3 | # Written by Simon Glass <sjg@chromium.org> |
| 4 | # |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 5 | # Command-line parser for binman |
| 6 | # |
| 7 | |
| 8 | from optparse import OptionParser |
| 9 | |
| 10 | def 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('-b', '--board', type='string', |
| 22 | help='Board name to build') |
| 23 | parser.add_option('-B', '--build-dir', type='string', default='b', |
| 24 | help='Directory containing the build output') |
| 25 | parser.add_option('-d', '--dt', type='string', |
| 26 | help='Configuration file (.dtb) to use') |
| 27 | parser.add_option('-D', '--debug', action='store_true', |
| 28 | help='Enabling debugging (provides a full traceback on error)') |
| 29 | parser.add_option('-I', '--indir', action='append', |
| 30 | help='Add a path to a directory to use for input files') |
| 31 | parser.add_option('-H', '--full-help', action='store_true', |
| 32 | default=False, help='Display the README file') |
Simon Glass | 3b0c3821 | 2018-06-01 09:38:20 -0600 | [diff] [blame] | 33 | parser.add_option('-m', '--map', action='store_true', |
| 34 | default=False, help='Output a map file for each image') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 35 | parser.add_option('-O', '--outdir', type='string', |
| 36 | action='store', help='Path to directory to use for intermediate and ' |
| 37 | 'output files') |
| 38 | parser.add_option('-p', '--preserve', action='store_true',\ |
| 39 | help='Preserve temporary output directory even if option -O is not ' |
| 40 | 'given') |
| 41 | parser.add_option('-t', '--test', action='store_true', |
| 42 | default=False, help='run tests') |
| 43 | parser.add_option('-T', '--test-coverage', action='store_true', |
| 44 | default=False, help='run tests and check for 100% coverage') |
| 45 | parser.add_option('-v', '--verbosity', default=1, |
| 46 | type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, ' |
| 47 | '4=debug') |
| 48 | |
| 49 | parser.usage += """ |
| 50 | |
| 51 | Create images for a board from a set of binaries. It is controlled by a |
| 52 | description in the board device tree.""" |
| 53 | |
| 54 | return parser.parse_args(argv) |