blob: 7573e5bdfe87344bb423a1f461c59d1f5a4edaab [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass04bac6b2014-09-05 19:00:10 -06002# Copyright (c) 2014 Google, Inc
3#
Simon Glass04bac6b2014-09-05 19:00:10 -06004
Simon Glass54b2fe52023-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 Glassa56ac992023-07-19 17:49:04 -060010import argparse
Simon Glass69c4dc12023-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 Glass04bac6b2014-09-05 19:00:10 -060016
Simon Glass933875e2023-07-19 17:49:07 -060017def add_upto_m(parser):
18 """Add arguments up to 'M'
Simon Glassa56ac992023-07-19 17:49:04 -060019
Simon Glass933875e2023-07-19 17:49:07 -060020 Args:
21 parser (ArgumentParser): Parse to add to
Simon Glassa56ac992023-07-19 17:49:04 -060022
Simon Glass933875e2023-07-19 17:49:07 -060023 This is split out to avoid having too many statements in one function
24 """
Simon Glassa56ac992023-07-19 17:49:04 -060025 parser.add_argument('-a', '--adjust-cfg', type=str, action='append',
Simon Glasse5650a82022-01-22 05:07:33 -070026 help='Adjust the Kconfig settings in .config before building')
Simon Glassa56ac992023-07-19 17:49:04 -060027 parser.add_argument('-A', '--print-prefix', action='store_true',
Simon Glass48ac42e2019-12-05 15:59:14 -070028 help='Print the tool-chain prefix for a board (CROSS_COMPILE=)')
Simon Glassa56ac992023-07-19 17:49:04 -060029 parser.add_argument('-b', '--branch', type=str,
Simon Glassdb17fb82015-02-05 22:06:15 -070030 help='Branch name to build, or range of commits to build')
Simon Glassa56ac992023-07-19 17:49:04 -060031 parser.add_argument('-B', '--bloat', dest='show_bloat',
Simon Glass04bac6b2014-09-05 19:00:10 -060032 action='store_true', default=False,
33 help='Show changes in function code size for each board')
Simon Glassa56ac992023-07-19 17:49:04 -060034 parser.add_argument('--boards', type=str, action='append',
Simon Glassd9eb9f02018-06-11 23:26:46 -060035 help='List of board names to build separated by comma')
Simon Glassa56ac992023-07-19 17:49:04 -060036 parser.add_argument('-c', '--count', dest='count', type=int,
Simon Glass04bac6b2014-09-05 19:00:10 -060037 default=-1, help='Run build on the top n commits')
Simon Glassa56ac992023-07-19 17:49:04 -060038 parser.add_argument('-C', '--force-reconfig', dest='force_reconfig',
Simon Glass04bac6b2014-09-05 19:00:10 -060039 action='store_true', default=False,
40 help='Reconfigure for every commit (disable incremental build)')
Simon Glasse67e0212023-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 Glassa56ac992023-07-19 17:49:04 -060044 parser.add_argument('-d', '--detail', dest='show_detail',
Simon Glass04bac6b2014-09-05 19:00:10 -060045 action='store_true', default=False,
Simon Glassb4002462020-03-18 09:42:43 -060046 help='Show detailed size delta for each board in the -S summary')
Simon Glasse67e0212023-07-19 17:49:29 -060047 parser.add_argument('-D', '--debug', action='store_true',
Simon Glass838ddf32022-01-22 05:07:29 -070048 help='Enabling debugging (provides a full traceback on error)')
Simon Glass600ede92024-08-15 13:57:45 -060049 parser.add_argument('--dtc-skip', action='store_true', default=False,
50 help='Skip building of dtc and use the system version')
Simon Glassa56ac992023-07-19 17:49:04 -060051 parser.add_argument('-e', '--show_errors', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060052 default=False, help='Show errors and warnings')
Simon Glassa56ac992023-07-19 17:49:04 -060053 parser.add_argument('-E', '--warnings-as-errors', action='store_true',
Daniel Schwierzeck20e2ea92018-01-26 16:31:05 +010054 default=False, help='Treat all compiler warnings as errors')
Simon Glassa56ac992023-07-19 17:49:04 -060055 parser.add_argument('-f', '--force-build', dest='force_build',
Simon Glass04bac6b2014-09-05 19:00:10 -060056 action='store_true', default=False,
57 help='Force build of boards even if already built')
Simon Glassa56ac992023-07-19 17:49:04 -060058 parser.add_argument('-F', '--force-build-failures', dest='force_build_failures',
Simon Glass04bac6b2014-09-05 19:00:10 -060059 action='store_true', default=False,
60 help='Force build of previously-failed build')
Simon Glassa56ac992023-07-19 17:49:04 -060061 parser.add_argument('--fetch-arch', type=str,
Simon Glass7e803e12014-12-01 17:34:06 -070062 help="Fetch a toolchain for architecture FETCH_ARCH ('list' to list)."
63 ' You can also fetch several toolchains separate by comma, or'
64 " 'all' to download all")
Simon Glass66d4c882023-07-19 17:49:30 -060065 parser.add_argument(
66 '--full-check', action='store_true',
67 help='Check maintainer entries and TARGET configs')
Simon Glassa56ac992023-07-19 17:49:04 -060068 parser.add_argument('-g', '--git', type=str,
Simon Glass04bac6b2014-09-05 19:00:10 -060069 help='Git repo containing branch to build', default='.')
Simon Glassa56ac992023-07-19 17:49:04 -060070 parser.add_argument('-G', '--config-file', type=str,
Simon Glass04bac6b2014-09-05 19:00:10 -060071 help='Path to buildman config file', default='')
Simon Glassa56ac992023-07-19 17:49:04 -060072 parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
Simon Glass04bac6b2014-09-05 19:00:10 -060073 default=False, help='Display the README file')
Simon Glassa56ac992023-07-19 17:49:04 -060074 parser.add_argument('-i', '--in-tree', dest='in_tree',
Simon Glass04bac6b2014-09-05 19:00:10 -060075 action='store_true', default=False,
76 help='Build in the source tree instead of a separate directory')
Simon Glassa56ac992023-07-19 17:49:04 -060077 parser.add_argument('-I', '--ide', action='store_true', default=False,
Simon Glass6c435622022-07-11 19:03:56 -060078 help='Create build output that can be parsed by an IDE')
Simon Glassa56ac992023-07-19 17:49:04 -060079 parser.add_argument('-j', '--jobs', dest='jobs', type=int,
Simon Glass04bac6b2014-09-05 19:00:10 -060080 default=None, help='Number of jobs to run at once (passed to make)')
Simon Glassa56ac992023-07-19 17:49:04 -060081 parser.add_argument('-k', '--keep-outputs', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060082 default=False, help='Keep all build output files (e.g. binaries)')
Simon Glassa56ac992023-07-19 17:49:04 -060083 parser.add_argument('-K', '--show-config', action='store_true',
Simon Glass54b2fe52023-07-19 17:49:02 -060084 default=False,
85 help='Show configuration changes in summary (both board config files and Kconfig)')
Simon Glassa56ac992023-07-19 17:49:04 -060086 parser.add_argument('--preserve-config-y', action='store_true',
Simon Glasscde5c302016-11-13 14:25:53 -070087 default=False, help="Don't convert y to 1 in configs")
Simon Glassa56ac992023-07-19 17:49:04 -060088 parser.add_argument('-l', '--list-error-boards', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060089 default=False, help='Show a list of boards next to each error/warning')
Simon Glassa56ac992023-07-19 17:49:04 -060090 parser.add_argument('-L', '--no-lto', action='store_true',
Simon Glassf6bfcca2023-02-21 12:40:28 -070091 default=False, help='Disable Link-time Optimisation (LTO) for builds')
Simon Glassa56ac992023-07-19 17:49:04 -060092 parser.add_argument('--list-tool-chains', action='store_true', default=False,
Simon Glass74579fc2018-11-06 16:02:10 -070093 help='List available tool chains (use -v to see probing detail)')
Simon Glassa56ac992023-07-19 17:49:04 -060094 parser.add_argument('-m', '--mrproper', action='store_true',
Simon Glass222825b2024-06-23 11:55:13 -060095 default=False, help="Run 'make mrproper' before reconfiguring")
96 parser.add_argument('--fallback-mrproper', action='store_true',
97 default=False, help="Run 'make mrproper' and retry on build failure")
Simon Glassa56ac992023-07-19 17:49:04 -060098 parser.add_argument(
Tom Rini93ebd462022-11-09 19:14:53 -070099 '-M', '--allow-missing', action='store_true', default=False,
Simon Glass54b2fe52023-07-19 17:49:02 -0600100 help='Tell binman to allow missing blobs and generate fake ones as needed')
Simon Glassa56ac992023-07-19 17:49:04 -0600101 parser.add_argument(
102 '--maintainer-check', action='store_true',
103 help='Check that maintainer entries exist for each board')
104 parser.add_argument(
Tom Rini93ebd462022-11-09 19:14:53 -0700105 '--no-allow-missing', action='store_true', default=False,
Simon Glass54b2fe52023-07-19 17:49:02 -0600106 help='Disable telling binman to allow missing blobs')
Simon Glassa56ac992023-07-19 17:49:04 -0600107 parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
Masahiro Yamadaf11c6062014-09-05 02:23:27 +0900108 default=False, help="Do a dry run (describe actions, but do nothing)")
Simon Glassa56ac992023-07-19 17:49:04 -0600109 parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
Simon Glass54b2fe52023-07-19 17:49:02 -0600110 default=False,
111 help="Don't create subdirectories when building current source for a single board")
Simon Glass933875e2023-07-19 17:49:07 -0600112
113
114def add_after_m(parser):
115 """Add arguments after 'M'
116
117 Args:
118 parser (ArgumentParser): Parse to add to
119
120 This is split out to avoid having too many statements in one function
121 """
Simon Glassa56ac992023-07-19 17:49:04 -0600122 parser.add_argument('-o', '--output-dir', type=str, dest='output_dir',
Simon Glass04bac6b2014-09-05 19:00:10 -0600123 help='Directory where all builds happen and buildman has its workspace (default is ../)')
Simon Glassa56ac992023-07-19 17:49:04 -0600124 parser.add_argument('-O', '--override-toolchain', type=str,
Simon Glassf77ca5b2019-01-07 16:44:20 -0700125 help="Override host toochain to use for sandbox (e.g. 'clang-7')")
Simon Glassa56ac992023-07-19 17:49:04 -0600126 parser.add_argument('-Q', '--quick', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600127 default=False, help='Do a rough build, with limited warning resolution')
Tom Rini3f6f9b22024-07-05 14:34:07 -0600128 parser.add_argument('-p', '--full-path', action='store_true',
129 default=False, help="Use full toolchain path in CROSS_COMPILE")
Simon Glassa56ac992023-07-19 17:49:04 -0600130 parser.add_argument('-P', '--per-board-out-dir', action='store_true',
Stephen Warren97c96902016-04-11 10:48:44 -0600131 default=False, help="Use an O= (output) directory per board rather than per thread")
Simon Glassa8a0ce72023-07-19 17:49:28 -0600132 parser.add_argument('--print-arch', action='store_true',
133 default=False, help="Print the architecture for a board (ARCH=)")
Simon Glassc229d322024-06-23 11:55:15 -0600134 parser.add_argument('--process-limit', type=int,
135 default=0, help='Limit to number of buildmans running at once')
Simon Glassa56ac992023-07-19 17:49:04 -0600136 parser.add_argument('-r', '--reproducible-builds', action='store_true',
Simon Glass828d70d2023-02-21 12:40:29 -0700137 help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
Simon Glassa56ac992023-07-19 17:49:04 -0600138 parser.add_argument('-R', '--regen-board-list', type=str,
Simon Glass0c477b72022-07-11 19:04:04 -0600139 help='Force regeneration of the list of boards, like the old boards.cfg file')
Simon Glassa56ac992023-07-19 17:49:04 -0600140 parser.add_argument('-s', '--summary', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600141 default=False, help='Show a build summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600142 parser.add_argument('-S', '--show-sizes', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600143 default=False, help='Show image size variation in summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600144 parser.add_argument('--step', type=int,
Simon Glass04bac6b2014-09-05 19:00:10 -0600145 default=1, help='Only build every n commits (0=just first and last)')
Simon Glass69c4dc12023-02-23 18:18:10 -0700146 if HAS_TESTS:
Simon Glassa56ac992023-07-19 17:49:04 -0600147 parser.add_argument('--skip-net-tests', action='store_true', default=False,
Simon Glass69c4dc12023-02-23 18:18:10 -0700148 help='Skip tests which need the network')
Simon Glassa56ac992023-07-19 17:49:04 -0600149 parser.add_argument('-t', '--test', action='store_true', dest='test',
Simon Glass69c4dc12023-02-23 18:18:10 -0700150 default=False, help='run tests')
Simon Glassc8b99b12023-07-19 17:49:31 -0600151 parser.add_argument('--coverage', action='store_true',
152 help='Calculated test coverage')
Simon Glassa56ac992023-07-19 17:49:04 -0600153 parser.add_argument('-T', '--threads', type=int,
Simon Glassc635d892021-01-30 22:17:46 -0700154 default=None,
155 help='Number of builder threads to use (0=single-thread)')
Simon Glassa56ac992023-07-19 17:49:04 -0600156 parser.add_argument('-u', '--show_unknown', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600157 default=False, help='Show boards with unknown build result')
Simon Glassa56ac992023-07-19 17:49:04 -0600158 parser.add_argument('-U', '--show-environment', action='store_true',
Alex Kiernan4059e302018-05-31 04:48:34 +0000159 default=False, help='Show environment changes in summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600160 parser.add_argument('-v', '--verbose', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600161 default=False, help='Show build results while the build progresses')
Simon Glassa56ac992023-07-19 17:49:04 -0600162 parser.add_argument('-V', '--verbose-build', action='store_true',
Simon Glass54e628e2016-03-12 18:50:33 -0700163 default=False, help='Run make with V=1, logging all output')
Simon Glassa56ac992023-07-19 17:49:04 -0600164 parser.add_argument('-w', '--work-in-output', action='store_true',
Simon Glassb6eb8cf2020-03-18 09:42:42 -0600165 default=False, help='Use the output directory as the work directory')
Simon Glassa56ac992023-07-19 17:49:04 -0600166 parser.add_argument('-W', '--ignore-warnings', action='store_true',
Simon Glass35e7d382020-03-18 09:42:44 -0600167 default=False, help='Return success even if there are warnings')
Simon Glassa56ac992023-07-19 17:49:04 -0600168 parser.add_argument('-x', '--exclude', dest='exclude',
169 type=str, action='append',
Simon Glass04bac6b2014-09-05 19:00:10 -0600170 help='Specify a list of boards to exclude, separated by comma')
Simon Glassa56ac992023-07-19 17:49:04 -0600171 parser.add_argument('-y', '--filter-dtb-warnings', action='store_true',
Simon Glass9ea93812020-04-09 15:08:52 -0600172 default=False,
Simon Glassf4ebfba2020-04-09 15:08:53 -0600173 help='Filter out device-tree-compiler warnings from output')
Simon Glassa56ac992023-07-19 17:49:04 -0600174 parser.add_argument('-Y', '--filter-migration-warnings', action='store_true',
Simon Glassf4ebfba2020-04-09 15:08:53 -0600175 default=False,
176 help='Filter out migration warnings from output')
Simon Glass933875e2023-07-19 17:49:07 -0600177
178
179def parse_args():
180 """Parse command line arguments from sys.argv[]
181
182 Returns:
183 tuple containing:
184 options: command line options
185 args: command lin arguments
186 """
187 epilog = """ [list of target/arch/cpu/board/vendor/soc to build]
188
189 Build U-Boot for all commits in a branch. Use -n to do a dry run"""
190
191 parser = argparse.ArgumentParser(epilog=epilog)
192 add_upto_m(parser)
193 add_after_m(parser)
Simon Glassa56ac992023-07-19 17:49:04 -0600194 parser.add_argument('terms', type=str, nargs='*',
195 help='Board / SoC names to build')
Simon Glass04bac6b2014-09-05 19:00:10 -0600196
197 return parser.parse_args()