Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 2 | # Copyright (c) 2014 Google, Inc |
| 3 | # |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 4 | |
Simon Glass | 988b916 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 10 | import argparse |
Simon Glass | 5cfb73b | 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 | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 16 | |
Simon Glass | 17a75b9 | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 17 | def add_upto_m(parser): |
| 18 | """Add arguments up to 'M' |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 19 | |
Simon Glass | 17a75b9 | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 20 | Args: |
| 21 | parser (ArgumentParser): Parse to add to |
| 22 | |
| 23 | This is split out to avoid having too many statements in one function |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 24 | """ |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 25 | parser.add_argument('-a', '--adjust-cfg', type=str, action='append', |
Simon Glass | 2b4806e | 2022-01-22 05:07:33 -0700 | [diff] [blame] | 26 | help='Adjust the Kconfig settings in .config before building') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 27 | parser.add_argument('-A', '--print-prefix', action='store_true', |
Simon Glass | 57cb9d5 | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 28 | help='Print the tool-chain prefix for a board (CROSS_COMPILE=)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 29 | parser.add_argument('-b', '--branch', type=str, |
Simon Glass | 843312d | 2015-02-05 22:06:15 -0700 | [diff] [blame] | 30 | help='Branch name to build, or range of commits to build') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 31 | parser.add_argument('-B', '--bloat', dest='show_bloat', |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 34 | parser.add_argument('--boards', type=str, action='append', |
Simon Glass | 0689036 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 35 | help='List of board names to build separated by comma') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 36 | parser.add_argument('-c', '--count', dest='count', type=int, |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 37 | default=-1, help='Run build on the top n commits') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 38 | parser.add_argument('-C', '--force-reconfig', dest='force_reconfig', |
Simon Glass | d3d5c12 | 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 | 39dbcaa | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 44 | parser.add_argument('-d', '--detail', dest='show_detail', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 45 | action='store_true', default=False, |
Simon Glass | f9c094b | 2020-03-18 09:42:43 -0600 | [diff] [blame] | 46 | help='Show detailed size delta for each board in the -S summary') |
Simon Glass | 39dbcaa | 2023-07-19 17:49:29 -0600 | [diff] [blame] | 47 | parser.add_argument('-D', '--debug', action='store_true', |
Simon Glass | 433fa54 | 2022-01-22 05:07:29 -0700 | [diff] [blame] | 48 | help='Enabling debugging (provides a full traceback on error)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 49 | parser.add_argument('-e', '--show_errors', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 50 | default=False, help='Show errors and warnings') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 51 | parser.add_argument('-E', '--warnings-as-errors', action='store_true', |
Daniel Schwierzeck | 2371d1b | 2018-01-26 16:31:05 +0100 | [diff] [blame] | 52 | default=False, help='Treat all compiler warnings as errors') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 53 | parser.add_argument('-f', '--force-build', dest='force_build', |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 56 | parser.add_argument('-F', '--force-build-failures', dest='force_build_failures', |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 59 | parser.add_argument('--fetch-arch', type=str, |
Simon Glass | 827e37b | 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 | ba8d099 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 66 | parser.add_argument('-g', '--git', type=str, |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 67 | help='Git repo containing branch to build', default='.') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 68 | parser.add_argument('-G', '--config-file', type=str, |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 69 | help='Path to buildman config file', default='') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 70 | parser.add_argument('-H', '--full-help', action='store_true', dest='full_help', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 71 | default=False, help='Display the README file') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 72 | parser.add_argument('-i', '--in-tree', dest='in_tree', |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 75 | parser.add_argument('-I', '--ide', action='store_true', default=False, |
Simon Glass | ae1a09f | 2022-07-11 19:03:56 -0600 | [diff] [blame] | 76 | help='Create build output that can be parsed by an IDE') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 77 | parser.add_argument('-j', '--jobs', dest='jobs', type=int, |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 79 | parser.add_argument('-k', '--keep-outputs', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 80 | default=False, help='Keep all build output files (e.g. binaries)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 81 | parser.add_argument('-K', '--show-config', action='store_true', |
Simon Glass | 988b916 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 84 | parser.add_argument('--preserve-config-y', action='store_true', |
Simon Glass | b464f8e | 2016-11-13 14:25:53 -0700 | [diff] [blame] | 85 | default=False, help="Don't convert y to 1 in configs") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 86 | parser.add_argument('-l', '--list-error-boards', action='store_true', |
Simon Glass | d3d5c12 | 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 | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 88 | parser.add_argument('-L', '--no-lto', action='store_true', |
Simon Glass | 93202d7 | 2023-02-21 12:40:28 -0700 | [diff] [blame] | 89 | default=False, help='Disable Link-time Optimisation (LTO) for builds') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 90 | parser.add_argument('--list-tool-chains', action='store_true', default=False, |
Simon Glass | 40232c9 | 2018-11-06 16:02:10 -0700 | [diff] [blame] | 91 | help='List available tool chains (use -v to see probing detail)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 92 | parser.add_argument('-m', '--mrproper', action='store_true', |
Simon Glass | eb70a2c | 2020-04-09 15:08:51 -0600 | [diff] [blame] | 93 | default=False, help="Run 'make mrproper before reconfiguring") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 94 | parser.add_argument( |
Tom Rini | d7713ad | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 95 | '-M', '--allow-missing', action='store_true', default=False, |
Simon Glass | 988b916 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 96 | help='Tell binman to allow missing blobs and generate fake ones as needed') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 97 | parser.add_argument( |
| 98 | '--maintainer-check', action='store_true', |
| 99 | help='Check that maintainer entries exist for each board') |
| 100 | parser.add_argument( |
Tom Rini | d7713ad | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 101 | '--no-allow-missing', action='store_true', default=False, |
Simon Glass | 988b916 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 102 | help='Disable telling binman to allow missing blobs') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 103 | parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', |
Masahiro Yamada | d0ea61d | 2014-09-05 02:23:27 +0900 | [diff] [blame] | 104 | default=False, help="Do a dry run (describe actions, but do nothing)") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 105 | parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs', |
Simon Glass | 988b916 | 2023-07-19 17:49:02 -0600 | [diff] [blame] | 106 | default=False, |
| 107 | help="Don't create subdirectories when building current source for a single board") |
Simon Glass | 17a75b9 | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 108 | |
| 109 | |
| 110 | def 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 Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 118 | parser.add_argument('-o', '--output-dir', type=str, dest='output_dir', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 119 | help='Directory where all builds happen and buildman has its workspace (default is ../)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 120 | parser.add_argument('-O', '--override-toolchain', type=str, |
Simon Glass | 00beb24 | 2019-01-07 16:44:20 -0700 | [diff] [blame] | 121 | help="Override host toochain to use for sandbox (e.g. 'clang-7')") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 122 | parser.add_argument('-Q', '--quick', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 123 | default=False, help='Do a rough build, with limited warning resolution') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 124 | parser.add_argument('-p', '--full-path', action='store_true', |
Simon Glass | bb1501f | 2014-12-01 17:34:00 -0700 | [diff] [blame] | 125 | default=False, help="Use full toolchain path in CROSS_COMPILE") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 126 | parser.add_argument('-P', '--per-board-out-dir', action='store_true', |
Stephen Warren | f79f1e0 | 2016-04-11 10:48:44 -0600 | [diff] [blame] | 127 | default=False, help="Use an O= (output) directory per board rather than per thread") |
Simon Glass | ad03787 | 2023-07-19 17:49:28 -0600 | [diff] [blame] | 128 | parser.add_argument('--print-arch', action='store_true', |
| 129 | default=False, help="Print the architecture for a board (ARCH=)") |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 130 | parser.add_argument('-r', '--reproducible-builds', action='store_true', |
Simon Glass | bfb708a | 2023-02-21 12:40:29 -0700 | [diff] [blame] | 131 | help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 132 | parser.add_argument('-R', '--regen-board-list', type=str, |
Simon Glass | a8a0141 | 2022-07-11 19:04:04 -0600 | [diff] [blame] | 133 | help='Force regeneration of the list of boards, like the old boards.cfg file') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 134 | parser.add_argument('-s', '--summary', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 135 | default=False, help='Show a build summary') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 136 | parser.add_argument('-S', '--show-sizes', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 137 | default=False, help='Show image size variation in summary') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 138 | parser.add_argument('--step', type=int, |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 139 | default=1, help='Only build every n commits (0=just first and last)') |
Simon Glass | 5cfb73b | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 140 | if HAS_TESTS: |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 141 | parser.add_argument('--skip-net-tests', action='store_true', default=False, |
Simon Glass | 5cfb73b | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 142 | help='Skip tests which need the network') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 143 | parser.add_argument('-t', '--test', action='store_true', dest='test', |
Simon Glass | 5cfb73b | 2023-02-23 18:18:10 -0700 | [diff] [blame] | 144 | default=False, help='run tests') |
Simon Glass | 407a141 | 2023-07-19 17:49:31 -0600 | [diff] [blame] | 145 | parser.add_argument('--coverage', action='store_true', |
| 146 | help='Calculated test coverage') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 147 | parser.add_argument('-T', '--threads', type=int, |
Simon Glass | b82492b | 2021-01-30 22:17:46 -0700 | [diff] [blame] | 148 | default=None, |
| 149 | help='Number of builder threads to use (0=single-thread)') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 150 | parser.add_argument('-u', '--show_unknown', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 151 | default=False, help='Show boards with unknown build result') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 152 | parser.add_argument('-U', '--show-environment', action='store_true', |
Alex Kiernan | 48ae412 | 2018-05-31 04:48:34 +0000 | [diff] [blame] | 153 | default=False, help='Show environment changes in summary') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 154 | parser.add_argument('-v', '--verbose', action='store_true', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 155 | default=False, help='Show build results while the build progresses') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 156 | parser.add_argument('-V', '--verbose-build', action='store_true', |
Simon Glass | c81d0d2 | 2016-03-12 18:50:33 -0700 | [diff] [blame] | 157 | default=False, help='Run make with V=1, logging all output') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 158 | parser.add_argument('-w', '--work-in-output', action='store_true', |
Simon Glass | d829f12 | 2020-03-18 09:42:42 -0600 | [diff] [blame] | 159 | default=False, help='Use the output directory as the work directory') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 160 | parser.add_argument('-W', '--ignore-warnings', action='store_true', |
Simon Glass | 7beb43c | 2020-03-18 09:42:44 -0600 | [diff] [blame] | 161 | default=False, help='Return success even if there are warnings') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 162 | parser.add_argument('-x', '--exclude', dest='exclude', |
| 163 | type=str, action='append', |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 164 | help='Specify a list of boards to exclude, separated by comma') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 165 | parser.add_argument('-y', '--filter-dtb-warnings', action='store_true', |
Simon Glass | 174592b | 2020-04-09 15:08:52 -0600 | [diff] [blame] | 166 | default=False, |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 167 | help='Filter out device-tree-compiler warnings from output') |
Simon Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 168 | parser.add_argument('-Y', '--filter-migration-warnings', action='store_true', |
Simon Glass | 113a8a5 | 2020-04-09 15:08:53 -0600 | [diff] [blame] | 169 | default=False, |
| 170 | help='Filter out migration warnings from output') |
Simon Glass | 17a75b9 | 2023-07-19 17:49:07 -0600 | [diff] [blame] | 171 | |
| 172 | |
| 173 | def 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 Glass | 529957c | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 188 | parser.add_argument('terms', type=str, nargs='*', |
| 189 | help='Board / SoC names to build') |
Simon Glass | d3d5c12 | 2014-09-05 19:00:10 -0600 | [diff] [blame] | 190 | |
| 191 | return parser.parse_args() |