]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | # SPDX-License-Identifier: GPL-2.0+ |
bf7fd50b SG |
2 | # Copyright (c) 2016 Google, Inc |
3 | # Written by Simon Glass <[email protected]> | |
4 | # | |
bf7fd50b SG |
5 | # Command-line parser for binman |
6 | # | |
7 | ||
53cd5d92 | 8 | from argparse import ArgumentParser |
bf7fd50b SG |
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 | """ | |
53cd5d92 SG |
20 | if '-H' in argv: |
21 | argv.append('build') | |
22 | ||
23 | epilog = '''Binman creates and manipulate images for a board from a set of binaries. Binman is | |
24 | controlled by a description in the board device tree.''' | |
25 | ||
26 | parser = ArgumentParser(epilog=epilog) | |
27 | parser.add_argument('-B', '--build-dir', type=str, default='b', | |
28 | help='Directory containing the build output') | |
29 | parser.add_argument('-D', '--debug', action='store_true', | |
30 | help='Enabling debugging (provides a full traceback on error)') | |
31 | parser.add_argument('-H', '--full-help', action='store_true', | |
32 | default=False, help='Display the README file') | |
33 | parser.add_argument('--toolpath', type=str, action='append', | |
34 | help='Add a path to the directories containing tools') | |
35 | parser.add_argument('-v', '--verbosity', default=1, | |
36 | type=int, help='Control verbosity: 0=silent, 1=warnings, 2=notices, ' | |
37 | '3=info, 4=detail, 5=debug') | |
38 | ||
39 | subparsers = parser.add_subparsers(dest='cmd') | |
680e3c6e | 40 | subparsers.required = True |
53cd5d92 SG |
41 | |
42 | build_parser = subparsers.add_parser('build', help='Build firmware image') | |
43 | build_parser.add_argument('-a', '--entry-arg', type=str, action='append', | |
53af22a9 | 44 | help='Set argument value arg=value') |
53cd5d92 | 45 | build_parser.add_argument('-b', '--board', type=str, |
bf7fd50b | 46 | help='Board name to build') |
53cd5d92 | 47 | build_parser.add_argument('-d', '--dt', type=str, |
bf7fd50b | 48 | help='Configuration file (.dtb) to use') |
53cd5d92 | 49 | build_parser.add_argument('--fake-dtb', action='store_true', |
93d17413 | 50 | help='Use fake device tree contents (for testing only)') |
53cd5d92 | 51 | build_parser.add_argument('-i', '--image', type=str, action='append', |
0bfa7b09 | 52 | help='Image filename to build (if not specified, build all)') |
53cd5d92 | 53 | build_parser.add_argument('-I', '--indir', action='append', |
497409fe | 54 | help='Add a path to the list of directories to use for input files') |
53cd5d92 | 55 | build_parser.add_argument('-m', '--map', action='store_true', |
3b0c3821 | 56 | default=False, help='Output a map file for each image') |
4f9f1056 SG |
57 | build_parser.add_argument('-M', '--allow-missing', action='store_true', |
58 | default=False, help='Allow external blobs to be missing') | |
53cd5d92 | 59 | build_parser.add_argument('-O', '--outdir', type=str, |
bf7fd50b SG |
60 | action='store', help='Path to directory to use for intermediate and ' |
61 | 'output files') | |
53cd5d92 | 62 | build_parser.add_argument('-p', '--preserve', action='store_true',\ |
bf7fd50b SG |
63 | help='Preserve temporary output directory even if option -O is not ' |
64 | 'given') | |
53cd5d92 | 65 | build_parser.add_argument('-u', '--update-fdt', action='store_true', |
3ab9598d | 66 | default=False, help='Update the binman node with offset/size info') |
53cd5d92 SG |
67 | |
68 | entry_parser = subparsers.add_parser('entry-docs', | |
69 | help='Write out entry documentation (see README.entries)') | |
70 | ||
61f564d1 SG |
71 | list_parser = subparsers.add_parser('ls', help='List files in an image') |
72 | list_parser.add_argument('-i', '--image', type=str, required=True, | |
73 | help='Image filename to list') | |
74 | list_parser.add_argument('paths', type=str, nargs='*', | |
75 | help='Paths within file to list (wildcard)') | |
76 | ||
71ce0ba2 SG |
77 | extract_parser = subparsers.add_parser('extract', |
78 | help='Extract files from an image') | |
79 | extract_parser.add_argument('-i', '--image', type=str, required=True, | |
80 | help='Image filename to extract') | |
81 | extract_parser.add_argument('-f', '--filename', type=str, | |
82 | help='Output filename to write to') | |
83 | extract_parser.add_argument('-O', '--outdir', type=str, default='', | |
84 | help='Path to directory to use for output files') | |
85 | extract_parser.add_argument('paths', type=str, nargs='*', | |
86 | help='Paths within file to extract (wildcard)') | |
87 | extract_parser.add_argument('-U', '--uncompressed', action='store_true', | |
88 | help='Output raw uncompressed data for compressed entries') | |
89 | ||
a6cb9950 SG |
90 | replace_parser = subparsers.add_parser('replace', |
91 | help='Replace entries in an image') | |
92 | replace_parser.add_argument('-C', '--compressed', action='store_true', | |
93 | help='Input data is already compressed if needed for the entry') | |
94 | replace_parser.add_argument('-i', '--image', type=str, required=True, | |
95 | help='Image filename to extract') | |
96 | replace_parser.add_argument('-f', '--filename', type=str, | |
97 | help='Input filename to read from') | |
98 | replace_parser.add_argument('-F', '--fix-size', action='store_true', | |
99 | help="Don't allow entries to be resized") | |
100 | replace_parser.add_argument('-I', '--indir', type=str, default='', | |
101 | help='Path to directory to use for input files') | |
102 | replace_parser.add_argument('-m', '--map', action='store_true', | |
103 | default=False, help='Output a map file for the updated image') | |
104 | replace_parser.add_argument('paths', type=str, nargs='*', | |
105 | help='Paths within file to extract (wildcard)') | |
106 | ||
53cd5d92 SG |
107 | test_parser = subparsers.add_parser('test', help='Run tests') |
108 | test_parser.add_argument('-P', '--processes', type=int, | |
109 | help='set number of processes to use for running tests') | |
110 | test_parser.add_argument('-T', '--test-coverage', action='store_true', | |
111 | default=False, help='run tests and check for 100%% coverage') | |
112 | test_parser.add_argument('-X', '--test-preserve-dirs', action='store_true', | |
d5164a79 SG |
113 | help='Preserve and display test-created input directories; also ' |
114 | 'preserve the output directory if a single test is run (pass test ' | |
115 | 'name at the end of the command line') | |
53cd5d92 SG |
116 | test_parser.add_argument('tests', nargs='*', |
117 | help='Test names to run (omit for all)') | |
bf7fd50b SG |
118 | |
119 | return parser.parse_args(argv) |