Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 2 | # Copyright (c) 2014 Google, Inc |
| 3 | # |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 4 | |
Simon Glass | 54b2fe5 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 5 | """Handles parsing of buildman arguments |
| 6 | |
| 7 | This creates the argument parser and uses it to parse the arguments passed in |
| 8 | """ |
| 9 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 10 | import argparse |
Simon Glass | 69c4dc1 | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 11 | import os |
| 12 | import pathlib |
| 13 | |
| 14 | BUILDMAN_DIR = pathlib.Path(__file__).parent |
| 15 | HAS_TESTS = os.path.exists(BUILDMAN_DIR / "test.py") |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 16 | |
Simon Glass | 933875e | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 17 | def add_upto_m(parser): |
| 18 | """Add arguments up to 'M' |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 19 | |
Simon Glass | 933875e | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 20 | Args: |
| 21 | parser (ArgumentParser): Parse to add to |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 22 | |
Simon Glass | 933875e | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 23 | This is split out to avoid having too many statements in one function |
| 24 | """ |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 25 | parser.add_argument('-a', '--adjust-cfg', type=str, action='append', |
Simon Glass | e5650a8 | 2022-01-22 05:07:33 -0700 | [diff] [blame] | 26 | help='Adjust the Kconfig settings in .config before building') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 27 | parser.add_argument('-A', '--print-prefix', action='store_true', |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 28 | help='Print the tool-chain prefix for a board (CROSS_COMPILE=)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 29 | parser.add_argument('-b', '--branch', type=str, |
Simon Glass | db17fb8 | 2015-02-05 22:06:15 -0700 | [diff] [blame] | 30 | help='Branch name to build, or range of commits to build') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 31 | parser.add_argument('-B', '--bloat', dest='show_bloat', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 32 | action='store_true', default=False, |
| 33 | help='Show changes in function code size for each board') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 34 | parser.add_argument('--boards', type=str, action='append', |
Simon Glass | d9eb9f0 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 35 | help='List of board names to build separated by comma') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 36 | parser.add_argument('-c', '--count', dest='count', type=int, |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 37 | default=-1, help='Run build on the top n commits') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 38 | parser.add_argument('-C', '--force-reconfig', dest='force_reconfig', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 39 | action='store_true', default=False, |
| 40 | help='Reconfigure for every commit (disable incremental build)') |
Simon Glass | e67e021 | 2023-07-19 17:49:29 -0600 | [diff] [blame] | 41 | parser.add_argument('--config-only', action='store_true', |
| 42 | default=False, |
| 43 | help="Don't build, just configure each commit") |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 44 | parser.add_argument('-d', '--detail', dest='show_detail', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 45 | action='store_true', default=False, |
Simon Glass | b400246 | 2020-03-18 09:42:43 -0600 | [diff] [blame] | 46 | help='Show detailed size delta for each board in the -S summary') |
Simon Glass | e67e021 | 2023-07-19 17:49:29 -0600 | [diff] [blame] | 47 | parser.add_argument('-D', '--debug', action='store_true', |
Simon Glass | 838ddf3 | 2022-01-22 05:07:29 -0700 | [diff] [blame] | 48 | help='Enabling debugging (provides a full traceback on error)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 49 | parser.add_argument('-e', '--show_errors', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 50 | default=False, help='Show errors and warnings') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 51 | parser.add_argument('-E', '--warnings-as-errors', action='store_true', |
Daniel Schwierzeck | 20e2ea9 | 2018-01-26 16:31:05 +0100 | [diff] [blame] | 52 | default=False, help='Treat all compiler warnings as errors') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 53 | parser.add_argument('-f', '--force-build', dest='force_build', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 54 | action='store_true', default=False, |
| 55 | help='Force build of boards even if already built') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 56 | parser.add_argument('-F', '--force-build-failures', dest='force_build_failures', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 57 | action='store_true', default=False, |
| 58 | help='Force build of previously-failed build') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 59 | parser.add_argument('--fetch-arch', type=str, |
Simon Glass | 7e803e1 | 2014-12-01 17:34:06 -0700 | [diff] [blame] | 60 | 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 Glass | 66d4c88 | 2023-07-19 17:49:30 -0600 | [diff] [blame] | 63 | parser.add_argument( |
| 64 | '--full-check', action='store_true', |
| 65 | help='Check maintainer entries and TARGET configs') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 66 | parser.add_argument('-g', '--git', type=str, |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 67 | help='Git repo containing branch to build', default='.') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 68 | parser.add_argument('-G', '--config-file', type=str, |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 69 | help='Path to buildman config file', default='') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 70 | parser.add_argument('-H', '--full-help', action='store_true', dest='full_help', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 71 | default=False, help='Display the README file') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 72 | parser.add_argument('-i', '--in-tree', dest='in_tree', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 73 | action='store_true', default=False, |
| 74 | help='Build in the source tree instead of a separate directory') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 75 | parser.add_argument('-I', '--ide', action='store_true', default=False, |
Simon Glass | 6c43562 | 2022-07-11 19:03:56 -0600 | [diff] [blame] | 76 | help='Create build output that can be parsed by an IDE') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 77 | parser.add_argument('-j', '--jobs', dest='jobs', type=int, |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 78 | default=None, help='Number of jobs to run at once (passed to make)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 79 | parser.add_argument('-k', '--keep-outputs', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 80 | default=False, help='Keep all build output files (e.g. binaries)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 81 | parser.add_argument('-K', '--show-config', action='store_true', |
Simon Glass | 54b2fe5 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 82 | default=False, |
| 83 | help='Show configuration changes in summary (both board config files and Kconfig)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 84 | parser.add_argument('--preserve-config-y', action='store_true', |
Simon Glass | cde5c30 | 2016-11-13 14:25:53 -0700 | [diff] [blame] | 85 | default=False, help="Don't convert y to 1 in configs") |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 86 | parser.add_argument('-l', '--list-error-boards', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 87 | default=False, help='Show a list of boards next to each error/warning') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 88 | parser.add_argument('-L', '--no-lto', action='store_true', |
Simon Glass | f6bfcca | 2023-02-21 12:40:28 -0700 | [diff] [blame] | 89 | default=False, help='Disable Link-time Optimisation (LTO) for builds') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 90 | parser.add_argument('--list-tool-chains', action='store_true', default=False, |
Simon Glass | 74579fc | 2018-11-06 16:02:10 -0700 | [diff] [blame] | 91 | help='List available tool chains (use -v to see probing detail)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 92 | parser.add_argument('-m', '--mrproper', action='store_true', |
Simon Glass | 222825b | 2024-06-23 11:55:13 -0600 | [diff] [blame] | 93 | 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 Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 96 | parser.add_argument( |
Tom Rini | 93ebd46 | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 97 | '-M', '--allow-missing', action='store_true', default=False, |
Simon Glass | 54b2fe5 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 98 | help='Tell binman to allow missing blobs and generate fake ones as needed') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 99 | parser.add_argument( |
| 100 | '--maintainer-check', action='store_true', |
| 101 | help='Check that maintainer entries exist for each board') |
| 102 | parser.add_argument( |
Tom Rini | 93ebd46 | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 103 | '--no-allow-missing', action='store_true', default=False, |
Simon Glass | 54b2fe5 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 104 | help='Disable telling binman to allow missing blobs') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 105 | parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', |
Masahiro Yamada | f11c606 | 2014-09-05 02:23:27 +0900 | [diff] [blame] | 106 | default=False, help="Do a dry run (describe actions, but do nothing)") |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 107 | parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs', |
Simon Glass | 54b2fe5 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 108 | default=False, |
| 109 | help="Don't create subdirectories when building current source for a single board") |
Simon Glass | 933875e | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 110 | |
| 111 | |
| 112 | def 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 Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 120 | parser.add_argument('-o', '--output-dir', type=str, dest='output_dir', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 121 | help='Directory where all builds happen and buildman has its workspace (default is ../)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 122 | parser.add_argument('-O', '--override-toolchain', type=str, |
Simon Glass | f77ca5b | 2019-01-07 16:44:20 -0700 | [diff] [blame] | 123 | help="Override host toochain to use for sandbox (e.g. 'clang-7')") |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 124 | parser.add_argument('-Q', '--quick', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 125 | default=False, help='Do a rough build, with limited warning resolution') |
Tom Rini | 3f6f9b2 | 2024-07-05 14:34:07 -0600 | [diff] [blame] | 126 | parser.add_argument('-p', '--full-path', action='store_true', |
| 127 | default=False, help="Use full toolchain path in CROSS_COMPILE") |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 128 | parser.add_argument('-P', '--per-board-out-dir', action='store_true', |
Stephen Warren | 97c9690 | 2016-04-11 10:48:44 -0600 | [diff] [blame] | 129 | default=False, help="Use an O= (output) directory per board rather than per thread") |
Simon Glass | a8a0ce7 | 2023-07-19 17:49:28 -0600 | [diff] [blame] | 130 | parser.add_argument('--print-arch', action='store_true', |
| 131 | default=False, help="Print the architecture for a board (ARCH=)") |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 132 | parser.add_argument('--process-limit', type=int, |
| 133 | default=0, help='Limit to number of buildmans running at once') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 134 | parser.add_argument('-r', '--reproducible-builds', action='store_true', |
Simon Glass | 828d70d | 2023-02-21 12:40:29 -0700 | [diff] [blame] | 135 | help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 136 | parser.add_argument('-R', '--regen-board-list', type=str, |
Simon Glass | 0c477b7 | 2022-07-11 19:04:04 -0600 | [diff] [blame] | 137 | help='Force regeneration of the list of boards, like the old boards.cfg file') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 138 | parser.add_argument('-s', '--summary', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 139 | default=False, help='Show a build summary') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 140 | parser.add_argument('-S', '--show-sizes', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 141 | default=False, help='Show image size variation in summary') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 142 | parser.add_argument('--step', type=int, |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 143 | default=1, help='Only build every n commits (0=just first and last)') |
Simon Glass | 69c4dc1 | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 144 | if HAS_TESTS: |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 145 | parser.add_argument('--skip-net-tests', action='store_true', default=False, |
Simon Glass | 69c4dc1 | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 146 | help='Skip tests which need the network') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 147 | parser.add_argument('-t', '--test', action='store_true', dest='test', |
Simon Glass | 69c4dc1 | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 148 | default=False, help='run tests') |
Simon Glass | c8b99b1 | 2023-07-19 17:49:31 -0600 | [diff] [blame] | 149 | parser.add_argument('--coverage', action='store_true', |
| 150 | help='Calculated test coverage') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 151 | parser.add_argument('-T', '--threads', type=int, |
Simon Glass | c635d89 | 2021-01-30 22:17:46 -0700 | [diff] [blame] | 152 | default=None, |
| 153 | help='Number of builder threads to use (0=single-thread)') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 154 | parser.add_argument('-u', '--show_unknown', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 155 | default=False, help='Show boards with unknown build result') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 156 | parser.add_argument('-U', '--show-environment', action='store_true', |
Alex Kiernan | 4059e30 | 2018-05-31 04:48:34 +0000 | [diff] [blame] | 157 | default=False, help='Show environment changes in summary') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 158 | parser.add_argument('-v', '--verbose', action='store_true', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 159 | default=False, help='Show build results while the build progresses') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 160 | parser.add_argument('-V', '--verbose-build', action='store_true', |
Simon Glass | 54e628e | 2016-03-12 18:50:33 -0700 | [diff] [blame] | 161 | default=False, help='Run make with V=1, logging all output') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 162 | parser.add_argument('-w', '--work-in-output', action='store_true', |
Simon Glass | b6eb8cf | 2020-03-18 09:42:42 -0600 | [diff] [blame] | 163 | default=False, help='Use the output directory as the work directory') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 164 | parser.add_argument('-W', '--ignore-warnings', action='store_true', |
Simon Glass | 35e7d38 | 2020-03-18 09:42:44 -0600 | [diff] [blame] | 165 | default=False, help='Return success even if there are warnings') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 166 | parser.add_argument('-x', '--exclude', dest='exclude', |
| 167 | type=str, action='append', |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 168 | help='Specify a list of boards to exclude, separated by comma') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 169 | parser.add_argument('-y', '--filter-dtb-warnings', action='store_true', |
Simon Glass | 9ea9381 | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 170 | default=False, |
Simon Glass | f4ebfba | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 171 | help='Filter out device-tree-compiler warnings from output') |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 172 | parser.add_argument('-Y', '--filter-migration-warnings', action='store_true', |
Simon Glass | f4ebfba | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 173 | default=False, |
| 174 | help='Filter out migration warnings from output') |
Simon Glass | 933875e | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 175 | |
| 176 | |
| 177 | def 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 Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 192 | parser.add_argument('terms', type=str, nargs='*', |
| 193 | help='Board / SoC names to build') |
Simon Glass | 04bac6b | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 194 | |
| 195 | return parser.parse_args() |