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() |
Simon Glass | 53af22a | 2018-07-17 13:25:32 -0600 | [diff] [blame] | 21 | parser.add_option('-a', '--entry-arg', type='string', action='append', |
| 22 | help='Set argument value arg=value') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 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)') |
Simon Glass | fd8d1f7 | 2018-07-17 13:25:36 -0600 | [diff] [blame] | 31 | parser.add_option('-E', '--entry-docs', action='store_true', |
| 32 | help='Write out entry documentation (see README.entries)') |
Simon Glass | 93d1741 | 2018-09-14 04:57:23 -0600 | [diff] [blame] | 33 | parser.add_option('--fake-dtb', action='store_true', |
| 34 | help='Use fake device tree contents (for testing only)') |
Simon Glass | 0bfa7b0 | 2018-09-14 04:57:12 -0600 | [diff] [blame] | 35 | parser.add_option('-i', '--image', type='string', action='append', |
| 36 | help='Image filename to build (if not specified, build all)') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 37 | parser.add_option('-I', '--indir', action='append', |
| 38 | help='Add a path to a directory to use for input files') |
| 39 | parser.add_option('-H', '--full-help', action='store_true', |
| 40 | default=False, help='Display the README file') |
Simon Glass | 3b0c382 | 2018-06-01 09:38:20 -0600 | [diff] [blame] | 41 | parser.add_option('-m', '--map', action='store_true', |
| 42 | default=False, help='Output a map file for each image') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 43 | parser.add_option('-O', '--outdir', type='string', |
| 44 | action='store', help='Path to directory to use for intermediate and ' |
| 45 | 'output files') |
| 46 | parser.add_option('-p', '--preserve', action='store_true',\ |
| 47 | help='Preserve temporary output directory even if option -O is not ' |
| 48 | 'given') |
Simon Glass | 11ae93e | 2018-10-01 21:12:47 -0600 | [diff] [blame] | 49 | parser.add_option('-P', '--processes', type=int, |
| 50 | help='set number of processes to use for running tests') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 51 | parser.add_option('-t', '--test', action='store_true', |
| 52 | default=False, help='run tests') |
| 53 | parser.add_option('-T', '--test-coverage', action='store_true', |
| 54 | default=False, help='run tests and check for 100% coverage') |
Simon Glass | c7d8035 | 2019-07-08 13:18:28 -0600 | [diff] [blame] | 55 | parser.add_option('--toolpath', type='string', action='append', |
| 56 | help='Add a path to the directories containing tools') |
Simon Glass | 078ab1a | 2018-07-06 10:27:41 -0600 | [diff] [blame] | 57 | parser.add_option('-u', '--update-fdt', action='store_true', |
Simon Glass | 3ab9598 | 2018-08-01 15:22:37 -0600 | [diff] [blame] | 58 | default=False, help='Update the binman node with offset/size info') |
Simon Glass | bf7fd50 | 2016-11-25 20:15:51 -0700 | [diff] [blame] | 59 | parser.add_option('-v', '--verbosity', default=1, |
| 60 | type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, ' |
| 61 | '4=debug') |
| 62 | |
| 63 | parser.usage += """ |
| 64 | |
| 65 | Create images for a board from a set of binaries. It is controlled by a |
| 66 | description in the board device tree.""" |
| 67 | |
| 68 | return parser.parse_args(argv) |