blob: 03211bd5aa5f3af949a7d884c9bf0ae166e0bf15 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glassd3d5c122014-09-05 19:00:10 -06002# Copyright (c) 2014 Google, Inc
3#
Simon Glassd3d5c122014-09-05 19:00:10 -06004
Simon Glass988b9162023-07-19 17:49:02 -06005"""Handles parsing of buildman arguments
6
7This creates the argument parser and uses it to parse the arguments passed in
8"""
9
Simon Glass529957c2023-07-19 17:49:04 -060010import argparse
Simon Glass5cfb73b2023-02-23 18:18:10 -070011import os
12import pathlib
13
14BUILDMAN_DIR = pathlib.Path(__file__).parent
15HAS_TESTS = os.path.exists(BUILDMAN_DIR / "test.py")
Simon Glassd3d5c122014-09-05 19:00:10 -060016
Simon Glass17a75b92023-07-19 17:49:07 -060017def add_upto_m(parser):
18 """Add arguments up to 'M'
Simon Glassd3d5c122014-09-05 19:00:10 -060019
Simon Glass17a75b92023-07-19 17:49:07 -060020 Args:
21 parser (ArgumentParser): Parse to add to
22
23 This is split out to avoid having too many statements in one function
Simon Glassd3d5c122014-09-05 19:00:10 -060024 """
Simon Glass529957c2023-07-19 17:49:04 -060025 parser.add_argument('-a', '--adjust-cfg', type=str, action='append',
Simon Glass2b4806e2022-01-22 05:07:33 -070026 help='Adjust the Kconfig settings in .config before building')
Simon Glass529957c2023-07-19 17:49:04 -060027 parser.add_argument('-A', '--print-prefix', action='store_true',
Simon Glass57cb9d52019-12-05 15:59:14 -070028 help='Print the tool-chain prefix for a board (CROSS_COMPILE=)')
Simon Glass529957c2023-07-19 17:49:04 -060029 parser.add_argument('-b', '--branch', type=str,
Simon Glass843312d2015-02-05 22:06:15 -070030 help='Branch name to build, or range of commits to build')
Simon Glass529957c2023-07-19 17:49:04 -060031 parser.add_argument('-B', '--bloat', dest='show_bloat',
Simon Glassd3d5c122014-09-05 19:00:10 -060032 action='store_true', default=False,
33 help='Show changes in function code size for each board')
Simon Glass529957c2023-07-19 17:49:04 -060034 parser.add_argument('--boards', type=str, action='append',
Simon Glass06890362018-06-11 23:26:46 -060035 help='List of board names to build separated by comma')
Simon Glass529957c2023-07-19 17:49:04 -060036 parser.add_argument('-c', '--count', dest='count', type=int,
Simon Glassd3d5c122014-09-05 19:00:10 -060037 default=-1, help='Run build on the top n commits')
Simon Glass529957c2023-07-19 17:49:04 -060038 parser.add_argument('-C', '--force-reconfig', dest='force_reconfig',
Simon Glassd3d5c122014-09-05 19:00:10 -060039 action='store_true', default=False,
40 help='Reconfigure for every commit (disable incremental build)')
Simon Glass39dbcaa2023-07-19 17:49:29 -060041 parser.add_argument('--config-only', action='store_true',
42 default=False,
43 help="Don't build, just configure each commit")
Simon Glass529957c2023-07-19 17:49:04 -060044 parser.add_argument('-d', '--detail', dest='show_detail',
Simon Glassd3d5c122014-09-05 19:00:10 -060045 action='store_true', default=False,
Simon Glassf9c094b2020-03-18 09:42:43 -060046 help='Show detailed size delta for each board in the -S summary')
Simon Glass39dbcaa2023-07-19 17:49:29 -060047 parser.add_argument('-D', '--debug', action='store_true',
Simon Glass433fa542022-01-22 05:07:29 -070048 help='Enabling debugging (provides a full traceback on error)')
Simon Glass529957c2023-07-19 17:49:04 -060049 parser.add_argument('-e', '--show_errors', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -060050 default=False, help='Show errors and warnings')
Simon Glass529957c2023-07-19 17:49:04 -060051 parser.add_argument('-E', '--warnings-as-errors', action='store_true',
Daniel Schwierzeck2371d1b2018-01-26 16:31:05 +010052 default=False, help='Treat all compiler warnings as errors')
Simon Glass529957c2023-07-19 17:49:04 -060053 parser.add_argument('-f', '--force-build', dest='force_build',
Simon Glassd3d5c122014-09-05 19:00:10 -060054 action='store_true', default=False,
55 help='Force build of boards even if already built')
Simon Glass529957c2023-07-19 17:49:04 -060056 parser.add_argument('-F', '--force-build-failures', dest='force_build_failures',
Simon Glassd3d5c122014-09-05 19:00:10 -060057 action='store_true', default=False,
58 help='Force build of previously-failed build')
Simon Glass529957c2023-07-19 17:49:04 -060059 parser.add_argument('--fetch-arch', type=str,
Simon Glass827e37b2014-12-01 17:34:06 -070060 help="Fetch a toolchain for architecture FETCH_ARCH ('list' to list)."
61 ' You can also fetch several toolchains separate by comma, or'
62 " 'all' to download all")
Simon Glassba8d0992023-07-19 17:49:30 -060063 parser.add_argument(
64 '--full-check', action='store_true',
65 help='Check maintainer entries and TARGET configs')
Simon Glass529957c2023-07-19 17:49:04 -060066 parser.add_argument('-g', '--git', type=str,
Simon Glassd3d5c122014-09-05 19:00:10 -060067 help='Git repo containing branch to build', default='.')
Simon Glass529957c2023-07-19 17:49:04 -060068 parser.add_argument('-G', '--config-file', type=str,
Simon Glassd3d5c122014-09-05 19:00:10 -060069 help='Path to buildman config file', default='')
Simon Glass529957c2023-07-19 17:49:04 -060070 parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
Simon Glassd3d5c122014-09-05 19:00:10 -060071 default=False, help='Display the README file')
Simon Glass529957c2023-07-19 17:49:04 -060072 parser.add_argument('-i', '--in-tree', dest='in_tree',
Simon Glassd3d5c122014-09-05 19:00:10 -060073 action='store_true', default=False,
74 help='Build in the source tree instead of a separate directory')
Simon Glass529957c2023-07-19 17:49:04 -060075 parser.add_argument('-I', '--ide', action='store_true', default=False,
Simon Glassae1a09f2022-07-11 19:03:56 -060076 help='Create build output that can be parsed by an IDE')
Simon Glass529957c2023-07-19 17:49:04 -060077 parser.add_argument('-j', '--jobs', dest='jobs', type=int,
Simon Glassd3d5c122014-09-05 19:00:10 -060078 default=None, help='Number of jobs to run at once (passed to make)')
Simon Glass529957c2023-07-19 17:49:04 -060079 parser.add_argument('-k', '--keep-outputs', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -060080 default=False, help='Keep all build output files (e.g. binaries)')
Simon Glass529957c2023-07-19 17:49:04 -060081 parser.add_argument('-K', '--show-config', action='store_true',
Simon Glass988b9162023-07-19 17:49:02 -060082 default=False,
83 help='Show configuration changes in summary (both board config files and Kconfig)')
Simon Glass529957c2023-07-19 17:49:04 -060084 parser.add_argument('--preserve-config-y', action='store_true',
Simon Glassb464f8e2016-11-13 14:25:53 -070085 default=False, help="Don't convert y to 1 in configs")
Simon Glass529957c2023-07-19 17:49:04 -060086 parser.add_argument('-l', '--list-error-boards', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -060087 default=False, help='Show a list of boards next to each error/warning')
Simon Glass529957c2023-07-19 17:49:04 -060088 parser.add_argument('-L', '--no-lto', action='store_true',
Simon Glass93202d72023-02-21 12:40:28 -070089 default=False, help='Disable Link-time Optimisation (LTO) for builds')
Simon Glass529957c2023-07-19 17:49:04 -060090 parser.add_argument('--list-tool-chains', action='store_true', default=False,
Simon Glass40232c92018-11-06 16:02:10 -070091 help='List available tool chains (use -v to see probing detail)')
Simon Glass529957c2023-07-19 17:49:04 -060092 parser.add_argument('-m', '--mrproper', action='store_true',
Simon Glasseb70a2c2020-04-09 15:08:51 -060093 default=False, help="Run 'make mrproper before reconfiguring")
Simon Glass529957c2023-07-19 17:49:04 -060094 parser.add_argument(
Tom Rinid7713ad2022-11-09 19:14:53 -070095 '-M', '--allow-missing', action='store_true', default=False,
Simon Glass988b9162023-07-19 17:49:02 -060096 help='Tell binman to allow missing blobs and generate fake ones as needed')
Simon Glass529957c2023-07-19 17:49:04 -060097 parser.add_argument(
98 '--maintainer-check', action='store_true',
99 help='Check that maintainer entries exist for each board')
100 parser.add_argument(
Tom Rinid7713ad2022-11-09 19:14:53 -0700101 '--no-allow-missing', action='store_true', default=False,
Simon Glass988b9162023-07-19 17:49:02 -0600102 help='Disable telling binman to allow missing blobs')
Simon Glass529957c2023-07-19 17:49:04 -0600103 parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
Masahiro Yamadad0ea61d2014-09-05 02:23:27 +0900104 default=False, help="Do a dry run (describe actions, but do nothing)")
Simon Glass529957c2023-07-19 17:49:04 -0600105 parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
Simon Glass988b9162023-07-19 17:49:02 -0600106 default=False,
107 help="Don't create subdirectories when building current source for a single board")
Simon Glass17a75b92023-07-19 17:49:07 -0600108
109
110def add_after_m(parser):
111 """Add arguments after 'M'
112
113 Args:
114 parser (ArgumentParser): Parse to add to
115
116 This is split out to avoid having too many statements in one function
117 """
Simon Glass529957c2023-07-19 17:49:04 -0600118 parser.add_argument('-o', '--output-dir', type=str, dest='output_dir',
Simon Glassd3d5c122014-09-05 19:00:10 -0600119 help='Directory where all builds happen and buildman has its workspace (default is ../)')
Simon Glass529957c2023-07-19 17:49:04 -0600120 parser.add_argument('-O', '--override-toolchain', type=str,
Simon Glass00beb242019-01-07 16:44:20 -0700121 help="Override host toochain to use for sandbox (e.g. 'clang-7')")
Simon Glass529957c2023-07-19 17:49:04 -0600122 parser.add_argument('-Q', '--quick', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -0600123 default=False, help='Do a rough build, with limited warning resolution')
Simon Glass529957c2023-07-19 17:49:04 -0600124 parser.add_argument('-p', '--full-path', action='store_true',
Simon Glassbb1501f2014-12-01 17:34:00 -0700125 default=False, help="Use full toolchain path in CROSS_COMPILE")
Simon Glass529957c2023-07-19 17:49:04 -0600126 parser.add_argument('-P', '--per-board-out-dir', action='store_true',
Stephen Warrenf79f1e02016-04-11 10:48:44 -0600127 default=False, help="Use an O= (output) directory per board rather than per thread")
Simon Glassad037872023-07-19 17:49:28 -0600128 parser.add_argument('--print-arch', action='store_true',
129 default=False, help="Print the architecture for a board (ARCH=)")
Simon Glass529957c2023-07-19 17:49:04 -0600130 parser.add_argument('-r', '--reproducible-builds', action='store_true',
Simon Glassbfb708a2023-02-21 12:40:29 -0700131 help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
Simon Glass529957c2023-07-19 17:49:04 -0600132 parser.add_argument('-R', '--regen-board-list', type=str,
Simon Glassa8a01412022-07-11 19:04:04 -0600133 help='Force regeneration of the list of boards, like the old boards.cfg file')
Simon Glass529957c2023-07-19 17:49:04 -0600134 parser.add_argument('-s', '--summary', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -0600135 default=False, help='Show a build summary')
Simon Glass529957c2023-07-19 17:49:04 -0600136 parser.add_argument('-S', '--show-sizes', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -0600137 default=False, help='Show image size variation in summary')
Simon Glass529957c2023-07-19 17:49:04 -0600138 parser.add_argument('--step', type=int,
Simon Glassd3d5c122014-09-05 19:00:10 -0600139 default=1, help='Only build every n commits (0=just first and last)')
Simon Glass5cfb73b2023-02-23 18:18:10 -0700140 if HAS_TESTS:
Simon Glass529957c2023-07-19 17:49:04 -0600141 parser.add_argument('--skip-net-tests', action='store_true', default=False,
Simon Glass5cfb73b2023-02-23 18:18:10 -0700142 help='Skip tests which need the network')
Simon Glass529957c2023-07-19 17:49:04 -0600143 parser.add_argument('-t', '--test', action='store_true', dest='test',
Simon Glass5cfb73b2023-02-23 18:18:10 -0700144 default=False, help='run tests')
Simon Glass407a1412023-07-19 17:49:31 -0600145 parser.add_argument('--coverage', action='store_true',
146 help='Calculated test coverage')
Simon Glass529957c2023-07-19 17:49:04 -0600147 parser.add_argument('-T', '--threads', type=int,
Simon Glassb82492b2021-01-30 22:17:46 -0700148 default=None,
149 help='Number of builder threads to use (0=single-thread)')
Simon Glass529957c2023-07-19 17:49:04 -0600150 parser.add_argument('-u', '--show_unknown', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -0600151 default=False, help='Show boards with unknown build result')
Simon Glass529957c2023-07-19 17:49:04 -0600152 parser.add_argument('-U', '--show-environment', action='store_true',
Alex Kiernan48ae4122018-05-31 04:48:34 +0000153 default=False, help='Show environment changes in summary')
Simon Glass529957c2023-07-19 17:49:04 -0600154 parser.add_argument('-v', '--verbose', action='store_true',
Simon Glassd3d5c122014-09-05 19:00:10 -0600155 default=False, help='Show build results while the build progresses')
Simon Glass529957c2023-07-19 17:49:04 -0600156 parser.add_argument('-V', '--verbose-build', action='store_true',
Simon Glassc81d0d22016-03-12 18:50:33 -0700157 default=False, help='Run make with V=1, logging all output')
Simon Glass529957c2023-07-19 17:49:04 -0600158 parser.add_argument('-w', '--work-in-output', action='store_true',
Simon Glassd829f122020-03-18 09:42:42 -0600159 default=False, help='Use the output directory as the work directory')
Simon Glass529957c2023-07-19 17:49:04 -0600160 parser.add_argument('-W', '--ignore-warnings', action='store_true',
Simon Glass7beb43c2020-03-18 09:42:44 -0600161 default=False, help='Return success even if there are warnings')
Simon Glass529957c2023-07-19 17:49:04 -0600162 parser.add_argument('-x', '--exclude', dest='exclude',
163 type=str, action='append',
Simon Glassd3d5c122014-09-05 19:00:10 -0600164 help='Specify a list of boards to exclude, separated by comma')
Simon Glass529957c2023-07-19 17:49:04 -0600165 parser.add_argument('-y', '--filter-dtb-warnings', action='store_true',
Simon Glass174592b2020-04-09 15:08:52 -0600166 default=False,
Simon Glass113a8a52020-04-09 15:08:53 -0600167 help='Filter out device-tree-compiler warnings from output')
Simon Glass529957c2023-07-19 17:49:04 -0600168 parser.add_argument('-Y', '--filter-migration-warnings', action='store_true',
Simon Glass113a8a52020-04-09 15:08:53 -0600169 default=False,
170 help='Filter out migration warnings from output')
Simon Glass17a75b92023-07-19 17:49:07 -0600171
172
173def parse_args():
174 """Parse command line arguments from sys.argv[]
175
176 Returns:
177 tuple containing:
178 options: command line options
179 args: command lin arguments
180 """
181 epilog = """ [list of target/arch/cpu/board/vendor/soc to build]
182
183 Build U-Boot for all commits in a branch. Use -n to do a dry run"""
184
185 parser = argparse.ArgumentParser(epilog=epilog)
186 add_upto_m(parser)
187 add_after_m(parser)
Simon Glass529957c2023-07-19 17:49:04 -0600188 parser.add_argument('terms', type=str, nargs='*',
189 help='Board / SoC names to build')
Simon Glassd3d5c122014-09-05 19:00:10 -0600190
191 return parser.parse_args()