blob: 544a391a4647035b9c962cbfbbdadf78bb2ec082 [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 Glassa56ac992023-07-19 17:49:04 -060049 parser.add_argument('-e', '--show_errors', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060050 default=False, help='Show errors and warnings')
Simon Glassa56ac992023-07-19 17:49:04 -060051 parser.add_argument('-E', '--warnings-as-errors', action='store_true',
Daniel Schwierzeck20e2ea92018-01-26 16:31:05 +010052 default=False, help='Treat all compiler warnings as errors')
Simon Glassa56ac992023-07-19 17:49:04 -060053 parser.add_argument('-f', '--force-build', dest='force_build',
Simon Glass04bac6b2014-09-05 19:00:10 -060054 action='store_true', default=False,
55 help='Force build of boards even if already built')
Simon Glassa56ac992023-07-19 17:49:04 -060056 parser.add_argument('-F', '--force-build-failures', dest='force_build_failures',
Simon Glass04bac6b2014-09-05 19:00:10 -060057 action='store_true', default=False,
58 help='Force build of previously-failed build')
Simon Glassa56ac992023-07-19 17:49:04 -060059 parser.add_argument('--fetch-arch', type=str,
Simon Glass7e803e12014-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 Glass66d4c882023-07-19 17:49:30 -060063 parser.add_argument(
64 '--full-check', action='store_true',
65 help='Check maintainer entries and TARGET configs')
Simon Glassa56ac992023-07-19 17:49:04 -060066 parser.add_argument('-g', '--git', type=str,
Simon Glass04bac6b2014-09-05 19:00:10 -060067 help='Git repo containing branch to build', default='.')
Simon Glassa56ac992023-07-19 17:49:04 -060068 parser.add_argument('-G', '--config-file', type=str,
Simon Glass04bac6b2014-09-05 19:00:10 -060069 help='Path to buildman config file', default='')
Simon Glassa56ac992023-07-19 17:49:04 -060070 parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
Simon Glass04bac6b2014-09-05 19:00:10 -060071 default=False, help='Display the README file')
Simon Glassa56ac992023-07-19 17:49:04 -060072 parser.add_argument('-i', '--in-tree', dest='in_tree',
Simon Glass04bac6b2014-09-05 19:00:10 -060073 action='store_true', default=False,
74 help='Build in the source tree instead of a separate directory')
Simon Glassa56ac992023-07-19 17:49:04 -060075 parser.add_argument('-I', '--ide', action='store_true', default=False,
Simon Glass6c435622022-07-11 19:03:56 -060076 help='Create build output that can be parsed by an IDE')
Simon Glassa56ac992023-07-19 17:49:04 -060077 parser.add_argument('-j', '--jobs', dest='jobs', type=int,
Simon Glass04bac6b2014-09-05 19:00:10 -060078 default=None, help='Number of jobs to run at once (passed to make)')
Simon Glassa56ac992023-07-19 17:49:04 -060079 parser.add_argument('-k', '--keep-outputs', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060080 default=False, help='Keep all build output files (e.g. binaries)')
Simon Glassa56ac992023-07-19 17:49:04 -060081 parser.add_argument('-K', '--show-config', action='store_true',
Simon Glass54b2fe52023-07-19 17:49:02 -060082 default=False,
83 help='Show configuration changes in summary (both board config files and Kconfig)')
Simon Glassa56ac992023-07-19 17:49:04 -060084 parser.add_argument('--preserve-config-y', action='store_true',
Simon Glasscde5c302016-11-13 14:25:53 -070085 default=False, help="Don't convert y to 1 in configs")
Simon Glassa56ac992023-07-19 17:49:04 -060086 parser.add_argument('-l', '--list-error-boards', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -060087 default=False, help='Show a list of boards next to each error/warning')
Simon Glassa56ac992023-07-19 17:49:04 -060088 parser.add_argument('-L', '--no-lto', action='store_true',
Simon Glassf6bfcca2023-02-21 12:40:28 -070089 default=False, help='Disable Link-time Optimisation (LTO) for builds')
Simon Glassa56ac992023-07-19 17:49:04 -060090 parser.add_argument('--list-tool-chains', action='store_true', default=False,
Simon Glass74579fc2018-11-06 16:02:10 -070091 help='List available tool chains (use -v to see probing detail)')
Simon Glassa56ac992023-07-19 17:49:04 -060092 parser.add_argument('-m', '--mrproper', action='store_true',
Simon Glass222825b2024-06-23 11:55:13 -060093 default=False, help="Run 'make mrproper' before reconfiguring")
94 parser.add_argument('--fallback-mrproper', action='store_true',
95 default=False, help="Run 'make mrproper' and retry on build failure")
Simon Glassa56ac992023-07-19 17:49:04 -060096 parser.add_argument(
Tom Rini93ebd462022-11-09 19:14:53 -070097 '-M', '--allow-missing', action='store_true', default=False,
Simon Glass54b2fe52023-07-19 17:49:02 -060098 help='Tell binman to allow missing blobs and generate fake ones as needed')
Simon Glassa56ac992023-07-19 17:49:04 -060099 parser.add_argument(
100 '--maintainer-check', action='store_true',
101 help='Check that maintainer entries exist for each board')
102 parser.add_argument(
Tom Rini93ebd462022-11-09 19:14:53 -0700103 '--no-allow-missing', action='store_true', default=False,
Simon Glass54b2fe52023-07-19 17:49:02 -0600104 help='Disable telling binman to allow missing blobs')
Simon Glassa56ac992023-07-19 17:49:04 -0600105 parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
Masahiro Yamadaf11c6062014-09-05 02:23:27 +0900106 default=False, help="Do a dry run (describe actions, but do nothing)")
Simon Glassa56ac992023-07-19 17:49:04 -0600107 parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
Simon Glass54b2fe52023-07-19 17:49:02 -0600108 default=False,
109 help="Don't create subdirectories when building current source for a single board")
Simon Glass933875e2023-07-19 17:49:07 -0600110
111
112def add_after_m(parser):
113 """Add arguments after 'M'
114
115 Args:
116 parser (ArgumentParser): Parse to add to
117
118 This is split out to avoid having too many statements in one function
119 """
Simon Glassa56ac992023-07-19 17:49:04 -0600120 parser.add_argument('-o', '--output-dir', type=str, dest='output_dir',
Simon Glass04bac6b2014-09-05 19:00:10 -0600121 help='Directory where all builds happen and buildman has its workspace (default is ../)')
Simon Glassa56ac992023-07-19 17:49:04 -0600122 parser.add_argument('-O', '--override-toolchain', type=str,
Simon Glassf77ca5b2019-01-07 16:44:20 -0700123 help="Override host toochain to use for sandbox (e.g. 'clang-7')")
Simon Glassa56ac992023-07-19 17:49:04 -0600124 parser.add_argument('-Q', '--quick', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600125 default=False, help='Do a rough build, with limited warning resolution')
Tom Rini3f6f9b22024-07-05 14:34:07 -0600126 parser.add_argument('-p', '--full-path', action='store_true',
127 default=False, help="Use full toolchain path in CROSS_COMPILE")
Simon Glassa56ac992023-07-19 17:49:04 -0600128 parser.add_argument('-P', '--per-board-out-dir', action='store_true',
Stephen Warren97c96902016-04-11 10:48:44 -0600129 default=False, help="Use an O= (output) directory per board rather than per thread")
Simon Glassa8a0ce72023-07-19 17:49:28 -0600130 parser.add_argument('--print-arch', action='store_true',
131 default=False, help="Print the architecture for a board (ARCH=)")
Simon Glassc229d322024-06-23 11:55:15 -0600132 parser.add_argument('--process-limit', type=int,
133 default=0, help='Limit to number of buildmans running at once')
Simon Glassa56ac992023-07-19 17:49:04 -0600134 parser.add_argument('-r', '--reproducible-builds', action='store_true',
Simon Glass828d70d2023-02-21 12:40:29 -0700135 help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
Simon Glassa56ac992023-07-19 17:49:04 -0600136 parser.add_argument('-R', '--regen-board-list', type=str,
Simon Glass0c477b72022-07-11 19:04:04 -0600137 help='Force regeneration of the list of boards, like the old boards.cfg file')
Simon Glassa56ac992023-07-19 17:49:04 -0600138 parser.add_argument('-s', '--summary', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600139 default=False, help='Show a build summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600140 parser.add_argument('-S', '--show-sizes', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600141 default=False, help='Show image size variation in summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600142 parser.add_argument('--step', type=int,
Simon Glass04bac6b2014-09-05 19:00:10 -0600143 default=1, help='Only build every n commits (0=just first and last)')
Simon Glass69c4dc12023-02-23 18:18:10 -0700144 if HAS_TESTS:
Simon Glassa56ac992023-07-19 17:49:04 -0600145 parser.add_argument('--skip-net-tests', action='store_true', default=False,
Simon Glass69c4dc12023-02-23 18:18:10 -0700146 help='Skip tests which need the network')
Simon Glassa56ac992023-07-19 17:49:04 -0600147 parser.add_argument('-t', '--test', action='store_true', dest='test',
Simon Glass69c4dc12023-02-23 18:18:10 -0700148 default=False, help='run tests')
Simon Glassc8b99b12023-07-19 17:49:31 -0600149 parser.add_argument('--coverage', action='store_true',
150 help='Calculated test coverage')
Simon Glassa56ac992023-07-19 17:49:04 -0600151 parser.add_argument('-T', '--threads', type=int,
Simon Glassc635d892021-01-30 22:17:46 -0700152 default=None,
153 help='Number of builder threads to use (0=single-thread)')
Simon Glassa56ac992023-07-19 17:49:04 -0600154 parser.add_argument('-u', '--show_unknown', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600155 default=False, help='Show boards with unknown build result')
Simon Glassa56ac992023-07-19 17:49:04 -0600156 parser.add_argument('-U', '--show-environment', action='store_true',
Alex Kiernan4059e302018-05-31 04:48:34 +0000157 default=False, help='Show environment changes in summary')
Simon Glassa56ac992023-07-19 17:49:04 -0600158 parser.add_argument('-v', '--verbose', action='store_true',
Simon Glass04bac6b2014-09-05 19:00:10 -0600159 default=False, help='Show build results while the build progresses')
Simon Glassa56ac992023-07-19 17:49:04 -0600160 parser.add_argument('-V', '--verbose-build', action='store_true',
Simon Glass54e628e2016-03-12 18:50:33 -0700161 default=False, help='Run make with V=1, logging all output')
Simon Glassa56ac992023-07-19 17:49:04 -0600162 parser.add_argument('-w', '--work-in-output', action='store_true',
Simon Glassb6eb8cf2020-03-18 09:42:42 -0600163 default=False, help='Use the output directory as the work directory')
Simon Glassa56ac992023-07-19 17:49:04 -0600164 parser.add_argument('-W', '--ignore-warnings', action='store_true',
Simon Glass35e7d382020-03-18 09:42:44 -0600165 default=False, help='Return success even if there are warnings')
Simon Glassa56ac992023-07-19 17:49:04 -0600166 parser.add_argument('-x', '--exclude', dest='exclude',
167 type=str, action='append',
Simon Glass04bac6b2014-09-05 19:00:10 -0600168 help='Specify a list of boards to exclude, separated by comma')
Simon Glassa56ac992023-07-19 17:49:04 -0600169 parser.add_argument('-y', '--filter-dtb-warnings', action='store_true',
Simon Glass9ea93812020-04-09 15:08:52 -0600170 default=False,
Simon Glassf4ebfba2020-04-09 15:08:53 -0600171 help='Filter out device-tree-compiler warnings from output')
Simon Glassa56ac992023-07-19 17:49:04 -0600172 parser.add_argument('-Y', '--filter-migration-warnings', action='store_true',
Simon Glassf4ebfba2020-04-09 15:08:53 -0600173 default=False,
174 help='Filter out migration warnings from output')
Simon Glass933875e2023-07-19 17:49:07 -0600175
176
177def parse_args():
178 """Parse command line arguments from sys.argv[]
179
180 Returns:
181 tuple containing:
182 options: command line options
183 args: command lin arguments
184 """
185 epilog = """ [list of target/arch/cpu/board/vendor/soc to build]
186
187 Build U-Boot for all commits in a branch. Use -n to do a dry run"""
188
189 parser = argparse.ArgumentParser(epilog=epilog)
190 add_upto_m(parser)
191 add_after_m(parser)
Simon Glassa56ac992023-07-19 17:49:04 -0600192 parser.add_argument('terms', type=str, nargs='*',
193 help='Board / SoC names to build')
Simon Glass04bac6b2014-09-05 19:00:10 -0600194
195 return parser.parse_args()