Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 2 | # Copyright (c) 2013 The Chromium OS Authors. |
| 3 | # |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 4 | |
Simon Glass | c1e1e1d | 2023-07-19 17:48:30 -0600 | [diff] [blame] | 5 | """Control module for buildman |
| 6 | |
| 7 | This holds the main control logic for buildman, when not running tests. |
| 8 | """ |
| 9 | |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 10 | import getpass |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 11 | import multiprocessing |
| 12 | import os |
Simon Glass | a10ebe1 | 2014-09-05 19:00:18 -0600 | [diff] [blame] | 13 | import shutil |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 14 | import sys |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 15 | import tempfile |
| 16 | import time |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 17 | |
Simon Glass | 20751d6 | 2022-07-11 19:04:03 -0600 | [diff] [blame] | 18 | from buildman import boards |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 19 | from buildman import bsettings |
Simon Glass | e5650a8 | 2022-01-22 05:07:33 -0700 | [diff] [blame] | 20 | from buildman import cfgutil |
Simon Glass | f0d9c10 | 2020-04-17 18:09:02 -0600 | [diff] [blame] | 21 | from buildman import toolchain |
| 22 | from buildman.builder import Builder |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 23 | from patman import gitutil |
| 24 | from patman import patchstream |
Simon Glass | 131444f | 2023-02-23 18:18:04 -0700 | [diff] [blame] | 25 | from u_boot_pylib import command |
| 26 | from u_boot_pylib import terminal |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 27 | from u_boot_pylib import tools |
| 28 | from u_boot_pylib.terminal import print_clear, tprint |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 29 | |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 30 | TEST_BUILDER = None |
| 31 | |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 32 | # Space-separated list of buildman process IDs currently running jobs |
| 33 | RUNNING_FNAME = f'buildmanq.{getpass.getuser()}' |
| 34 | |
| 35 | # Lock file for access to RUNNING_FILE |
| 36 | LOCK_FNAME = f'{RUNNING_FNAME}.lock' |
| 37 | |
| 38 | # Wait time for access to lock (seconds) |
| 39 | LOCK_WAIT_S = 10 |
| 40 | |
| 41 | # Wait time to start running |
| 42 | RUN_WAIT_S = 300 |
| 43 | |
Simon Glass | c1e1e1d | 2023-07-19 17:48:30 -0600 | [diff] [blame] | 44 | def get_plural(count): |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 45 | """Returns a plural 's' if count is not 1""" |
| 46 | return 's' if count != 1 else '' |
| 47 | |
Simon Glass | 14905d3 | 2023-07-19 17:49:00 -0600 | [diff] [blame] | 48 | |
| 49 | def count_build_commits(commits, step): |
| 50 | """Calculate the number of commits to be built |
| 51 | |
| 52 | Args: |
| 53 | commits (list of Commit): Commits to build or None |
| 54 | step (int): Step value for commits, typically 1 |
| 55 | |
| 56 | Returns: |
| 57 | Number of commits that will be built |
| 58 | """ |
| 59 | if commits: |
| 60 | count = len(commits) |
| 61 | return (count + step - 1) // step |
| 62 | return 0 |
| 63 | |
| 64 | |
| 65 | def get_action_summary(is_summary, commit_count, selected, threads, jobs): |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 66 | """Return a string summarising the intended action. |
| 67 | |
Simon Glass | f50a728 | 2023-07-19 17:48:45 -0600 | [diff] [blame] | 68 | Args: |
| 69 | is_summary (bool): True if this is a summary (otherwise it is building) |
| 70 | commits (list): List of commits being built |
| 71 | selected (list of Board): List of Board objects that are marked |
| 72 | step (int): Step increment through commits |
| 73 | threads (int): Number of processor threads being used |
| 74 | jobs (int): Number of jobs to build at once |
| 75 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 76 | Returns: |
| 77 | Summary string. |
| 78 | """ |
Simon Glass | 14905d3 | 2023-07-19 17:49:00 -0600 | [diff] [blame] | 79 | if commit_count: |
| 80 | commit_str = f'{commit_count} commit{get_plural(commit_count)}' |
Simon Glass | d326ad7 | 2014-08-09 15:32:59 -0600 | [diff] [blame] | 81 | else: |
| 82 | commit_str = 'current source' |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 83 | msg = (f"{'Summary of' if is_summary else 'Building'} " |
| 84 | f'{commit_str} for {len(selected)} boards') |
Simon Glass | f50a728 | 2023-07-19 17:48:45 -0600 | [diff] [blame] | 85 | msg += (f' ({threads} thread{get_plural(threads)}, ' |
| 86 | f'{jobs} job{get_plural(jobs)} per thread)') |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 87 | return msg |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 88 | |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 89 | # pylint: disable=R0913 |
Simon Glass | 01c671d | 2023-07-19 17:48:46 -0600 | [diff] [blame] | 90 | def show_actions(series, why_selected, boards_selected, output_dir, |
| 91 | board_warnings, step, threads, jobs, verbose): |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 92 | """Display a list of actions that we would take, if not a dry run. |
| 93 | |
| 94 | Args: |
| 95 | series: Series object |
| 96 | why_selected: Dictionary where each key is a buildman argument |
Simon Glass | 6af145f | 2017-01-23 05:38:56 -0700 | [diff] [blame] | 97 | provided by the user, and the value is the list of boards |
| 98 | brought in by that argument. For example, 'arm' might bring |
| 99 | in 400 boards, so in this case the key would be 'arm' and |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 100 | the value would be a list of board names. |
| 101 | boards_selected: Dict of selected boards, key is target name, |
| 102 | value is Board object |
Simon Glass | f83559c | 2023-07-19 17:48:36 -0600 | [diff] [blame] | 103 | output_dir (str): Output directory for builder |
Simon Glass | d9eb9f0 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 104 | board_warnings: List of warnings obtained from board selected |
Simon Glass | 01c671d | 2023-07-19 17:48:46 -0600 | [diff] [blame] | 105 | step (int): Step increment through commits |
| 106 | threads (int): Number of processor threads being used |
| 107 | jobs (int): Number of jobs to build at once |
| 108 | verbose (bool): True to indicate why each board was selected |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 109 | """ |
| 110 | col = terminal.Color() |
Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 111 | print('Dry run, so not doing much. But I would do this:') |
| 112 | print() |
Simon Glass | d326ad7 | 2014-08-09 15:32:59 -0600 | [diff] [blame] | 113 | if series: |
| 114 | commits = series.commits |
| 115 | else: |
| 116 | commits = None |
Simon Glass | 14905d3 | 2023-07-19 17:49:00 -0600 | [diff] [blame] | 117 | print(get_action_summary(False, count_build_commits(commits, step), |
| 118 | boards_selected, threads, jobs)) |
Simon Glass | f83559c | 2023-07-19 17:48:36 -0600 | [diff] [blame] | 119 | print(f'Build directory: {output_dir}') |
Simon Glass | d326ad7 | 2014-08-09 15:32:59 -0600 | [diff] [blame] | 120 | if commits: |
Simon Glass | 01c671d | 2023-07-19 17:48:46 -0600 | [diff] [blame] | 121 | for upto in range(0, len(series.commits), step): |
Simon Glass | d326ad7 | 2014-08-09 15:32:59 -0600 | [diff] [blame] | 122 | commit = series.commits[upto] |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 123 | print(' ', col.build(col.YELLOW, commit.hash[:8], bright=False), end=' ') |
Simon Glass | c78ed66 | 2019-10-31 07:42:53 -0600 | [diff] [blame] | 124 | print(commit.subject) |
| 125 | print() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 126 | for arg in why_selected: |
| 127 | if arg != 'all': |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 128 | print(arg, f': {len(why_selected[arg])} boards') |
Simon Glass | 01c671d | 2023-07-19 17:48:46 -0600 | [diff] [blame] | 129 | if verbose: |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 130 | print(f" {' '.join(why_selected[arg])}") |
| 131 | print('Total boards to build for each ' |
| 132 | f"commit: {len(why_selected['all'])}\n") |
Simon Glass | d9eb9f0 | 2018-06-11 23:26:46 -0600 | [diff] [blame] | 133 | if board_warnings: |
| 134 | for warning in board_warnings: |
Simon Glass | f45d374 | 2022-01-29 14:14:17 -0700 | [diff] [blame] | 135 | print(col.build(col.YELLOW, warning)) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 136 | |
Simon Glass | c1e1e1d | 2023-07-19 17:48:30 -0600 | [diff] [blame] | 137 | def show_toolchain_prefix(brds, toolchains): |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 138 | """Show information about a the tool chain used by one or more boards |
| 139 | |
Simon Glass | 2df44be | 2020-03-18 09:42:47 -0600 | [diff] [blame] | 140 | The function checks that all boards use the same toolchain, then prints |
| 141 | the correct value for CROSS_COMPILE. |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 142 | |
| 143 | Args: |
| 144 | boards: Boards object containing selected boards |
| 145 | toolchains: Toolchains object containing available toolchains |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 146 | |
| 147 | Return: |
| 148 | None on success, string error message otherwise |
| 149 | """ |
Simon Glass | 127a239 | 2022-07-11 19:04:02 -0600 | [diff] [blame] | 150 | board_selected = brds.get_selected_dict() |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 151 | tc_set = set() |
Simon Glass | 5df4522 | 2022-07-11 19:04:00 -0600 | [diff] [blame] | 152 | for brd in board_selected.values(): |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 153 | tc_set.add(toolchains.Select(brd.arch)) |
| 154 | if len(tc_set) != 1: |
Simon Glass | eaf1be2 | 2023-07-19 17:48:56 -0600 | [diff] [blame] | 155 | sys.exit('Supplied boards must share one toolchain') |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 156 | tchain = tc_set.pop() |
| 157 | print(tchain.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 158 | |
Simon Glass | a8a0ce7 | 2023-07-19 17:49:28 -0600 | [diff] [blame] | 159 | def show_arch(brds): |
| 160 | """Show information about a the architecture used by one or more boards |
| 161 | |
| 162 | The function checks that all boards use the same architecture, then prints |
| 163 | the correct value for ARCH. |
| 164 | |
| 165 | Args: |
| 166 | boards: Boards object containing selected boards |
| 167 | |
| 168 | Return: |
| 169 | None on success, string error message otherwise |
| 170 | """ |
| 171 | board_selected = brds.get_selected_dict() |
| 172 | arch_set = set() |
| 173 | for brd in board_selected.values(): |
| 174 | arch_set.add(brd.arch) |
| 175 | if len(arch_set) != 1: |
| 176 | sys.exit('Supplied boards must share one arch') |
| 177 | print(arch_set.pop()) |
| 178 | |
Tom Rini | 93ebd46 | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 179 | def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 180 | """Figure out whether to allow external blobs |
| 181 | |
| 182 | Uses the allow-missing setting and the provided arguments to decide whether |
| 183 | missing external blobs should be allowed |
| 184 | |
| 185 | Args: |
| 186 | opt_allow (bool): True if --allow-missing flag is set |
| 187 | opt_no_allow (bool): True if --no-allow-missing flag is set |
| 188 | num_selected (int): Number of selected board |
| 189 | has_branch (bool): True if a git branch (to build) has been provided |
| 190 | |
| 191 | Returns: |
| 192 | bool: True to allow missing external blobs, False to produce an error if |
| 193 | external blobs are used |
| 194 | """ |
Tom Rini | 93ebd46 | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 195 | allow_missing = False |
Simon Glass | 06b83a5 | 2023-07-19 17:49:05 -0600 | [diff] [blame] | 196 | am_setting = bsettings.get_global_item_value('allow-missing') |
Tom Rini | 93ebd46 | 2022-11-09 19:14:53 -0700 | [diff] [blame] | 197 | if am_setting: |
| 198 | if am_setting == 'always': |
| 199 | allow_missing = True |
| 200 | if 'multiple' in am_setting and num_selected > 1: |
| 201 | allow_missing = True |
| 202 | if 'branch' in am_setting and has_branch: |
| 203 | allow_missing = True |
| 204 | |
| 205 | if opt_allow: |
| 206 | allow_missing = True |
| 207 | if opt_no_allow: |
| 208 | allow_missing = False |
| 209 | return allow_missing |
| 210 | |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 211 | |
Simon Glass | fdbff80 | 2023-07-19 17:48:48 -0600 | [diff] [blame] | 212 | def count_commits(branch, count, col, git_dir): |
| 213 | """Could the number of commits in the branch/ranch being built |
| 214 | |
| 215 | Args: |
| 216 | branch (str): Name of branch to build, or None if none |
| 217 | count (int): Number of commits to build, or -1 for all |
| 218 | col (Terminal.Color): Color object to use |
| 219 | git_dir (str): Git directory to use, e.g. './.git' |
| 220 | |
| 221 | Returns: |
| 222 | tuple: |
| 223 | Number of commits being built |
| 224 | True if the 'branch' string contains a range rather than a simple |
| 225 | name |
| 226 | """ |
| 227 | has_range = branch and '..' in branch |
| 228 | if count == -1: |
| 229 | if not branch: |
| 230 | count = 1 |
| 231 | else: |
| 232 | if has_range: |
| 233 | count, msg = gitutil.count_commits_in_range(git_dir, branch) |
| 234 | else: |
| 235 | count, msg = gitutil.count_commits_in_branch(git_dir, branch) |
| 236 | if count is None: |
| 237 | sys.exit(col.build(col.RED, msg)) |
| 238 | elif count == 0: |
| 239 | sys.exit(col.build(col.RED, |
| 240 | f"Range '{branch}' has no commits")) |
| 241 | if msg: |
| 242 | print(col.build(col.YELLOW, msg)) |
| 243 | count += 1 # Build upstream commit also |
| 244 | |
| 245 | if not count: |
| 246 | msg = (f"No commits found to process in branch '{branch}': " |
| 247 | "set branch's upstream or use -c flag") |
| 248 | sys.exit(col.build(col.RED, msg)) |
| 249 | return count, has_range |
| 250 | |
| 251 | |
Simon Glass | 100196e | 2023-07-19 17:48:40 -0600 | [diff] [blame] | 252 | def determine_series(selected, col, git_dir, count, branch, work_in_output): |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 253 | """Determine the series which is to be built, if any |
| 254 | |
Simon Glass | 1b14049 | 2023-07-19 17:48:50 -0600 | [diff] [blame] | 255 | If there is a series, the commits in that series are numbered by setting |
| 256 | their sequence value (starting from 0). This is used by tests. |
| 257 | |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 258 | Args: |
Simon Glass | f50a728 | 2023-07-19 17:48:45 -0600 | [diff] [blame] | 259 | selected (list of Board): List of Board objects that are marked |
Simon Glass | 100196e | 2023-07-19 17:48:40 -0600 | [diff] [blame] | 260 | selected |
| 261 | col (Terminal.Color): Color object to use |
| 262 | git_dir (str): Git directory to use, e.g. './.git' |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 263 | count (int): Number of commits in branch |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 264 | branch (str): Name of branch to build, or None if none |
Simon Glass | 100196e | 2023-07-19 17:48:40 -0600 | [diff] [blame] | 265 | work_in_output (bool): True to work in the output directory |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 266 | |
| 267 | Returns: |
| 268 | Series: Series to build, or None for none |
| 269 | |
| 270 | Read the metadata from the commits. First look at the upstream commit, |
| 271 | then the ones in the branch. We would like to do something like |
| 272 | upstream/master~..branch but that isn't possible if upstream/master is |
| 273 | a merge commit (it will list all the commits that form part of the |
| 274 | merge) |
| 275 | |
| 276 | Conflicting tags are not a problem for buildman, since it does not use |
| 277 | them. For example, Series-version is not useful for buildman. On the |
| 278 | other hand conflicting tags will cause an error. So allow later tags |
| 279 | to overwrite earlier ones by setting allow_overwrite=True |
| 280 | """ |
Simon Glass | 100196e | 2023-07-19 17:48:40 -0600 | [diff] [blame] | 281 | |
| 282 | # Work out how many commits to build. We want to build everything on the |
| 283 | # branch. We also build the upstream commit as a control so we can see |
| 284 | # problems introduced by the first commit on the branch. |
Simon Glass | fdbff80 | 2023-07-19 17:48:48 -0600 | [diff] [blame] | 285 | count, has_range = count_commits(branch, count, col, git_dir) |
Simon Glass | 100196e | 2023-07-19 17:48:40 -0600 | [diff] [blame] | 286 | if work_in_output: |
| 287 | if len(selected) != 1: |
| 288 | sys.exit(col.build(col.RED, |
| 289 | '-w can only be used with a single board')) |
| 290 | if count != 1: |
| 291 | sys.exit(col.build(col.RED, |
| 292 | '-w can only be used with a single commit')) |
| 293 | |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 294 | if branch: |
| 295 | if count == -1: |
| 296 | if has_range: |
| 297 | range_expr = branch |
| 298 | else: |
| 299 | range_expr = gitutil.get_range_in_branch(git_dir, branch) |
| 300 | upstream_commit = gitutil.get_upstream(git_dir, branch) |
| 301 | series = patchstream.get_metadata_for_list(upstream_commit, |
| 302 | git_dir, 1, series=None, allow_overwrite=True) |
| 303 | |
| 304 | series = patchstream.get_metadata_for_list(range_expr, |
| 305 | git_dir, None, series, allow_overwrite=True) |
| 306 | else: |
| 307 | # Honour the count |
| 308 | series = patchstream.get_metadata_for_list(branch, |
| 309 | git_dir, count, series=None, allow_overwrite=True) |
Simon Glass | 1b14049 | 2023-07-19 17:48:50 -0600 | [diff] [blame] | 310 | |
| 311 | # Number the commits for test purposes |
| 312 | for i, commit in enumerate(series.commits): |
| 313 | commit.sequence = i |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 314 | else: |
| 315 | series = None |
| 316 | return series |
| 317 | |
| 318 | |
Simon Glass | 6c4beca | 2023-07-19 17:48:34 -0600 | [diff] [blame] | 319 | def do_fetch_arch(toolchains, col, fetch_arch): |
| 320 | """Handle the --fetch-arch option |
| 321 | |
| 322 | Args: |
| 323 | toolchains (Toolchains): Tool chains to use |
| 324 | col (terminal.Color): Color object to build |
| 325 | fetch_arch (str): Argument passed to the --fetch-arch option |
| 326 | |
| 327 | Returns: |
| 328 | int: Return code for buildman |
| 329 | """ |
| 330 | if fetch_arch == 'list': |
| 331 | sorted_list = toolchains.ListArchs() |
| 332 | print(col.build( |
| 333 | col.BLUE, |
| 334 | f"Available architectures: {' '.join(sorted_list)}\n")) |
| 335 | return 0 |
| 336 | |
| 337 | if fetch_arch == 'all': |
| 338 | fetch_arch = ','.join(toolchains.ListArchs()) |
| 339 | print(col.build(col.CYAN, |
| 340 | f'\nDownloading toolchains: {fetch_arch}')) |
| 341 | for arch in fetch_arch.split(','): |
| 342 | print() |
| 343 | ret = toolchains.FetchAndInstall(arch) |
| 344 | if ret: |
| 345 | return ret |
| 346 | return 0 |
| 347 | |
| 348 | |
Simon Glass | 3bd8e30 | 2023-07-19 17:48:42 -0600 | [diff] [blame] | 349 | def get_toolchains(toolchains, col, override_toolchain, fetch_arch, |
| 350 | list_tool_chains, verbose): |
| 351 | """Get toolchains object to use |
| 352 | |
| 353 | Args: |
| 354 | toolchains (Toolchains or None): Toolchains to use. If None, then a |
| 355 | Toolchains object will be created and scanned |
| 356 | col (Terminal.Color): Color object |
| 357 | override_toolchain (str or None): Override value for toolchain, or None |
| 358 | fetch_arch (bool): True to fetch the toolchain for the architectures |
| 359 | list_tool_chains (bool): True to list all tool chains |
| 360 | verbose (bool): True for verbose output when listing toolchains |
| 361 | |
| 362 | Returns: |
| 363 | Either: |
| 364 | int: Operation completed and buildman should exit with exit code |
| 365 | Toolchains: Toolchains object to use |
| 366 | """ |
| 367 | no_toolchains = toolchains is None |
| 368 | if no_toolchains: |
| 369 | toolchains = toolchain.Toolchains(override_toolchain) |
| 370 | |
| 371 | if fetch_arch: |
| 372 | return do_fetch_arch(toolchains, col, fetch_arch) |
| 373 | |
| 374 | if no_toolchains: |
| 375 | toolchains.GetSettings() |
| 376 | toolchains.Scan(list_tool_chains and verbose) |
| 377 | if list_tool_chains: |
| 378 | toolchains.List() |
| 379 | print() |
| 380 | return 0 |
| 381 | return toolchains |
| 382 | |
| 383 | |
Simon Glass | 66d4c88 | 2023-07-19 17:49:30 -0600 | [diff] [blame] | 384 | def get_boards_obj(output_dir, regen_board_list, maintainer_check, full_check, |
| 385 | threads, verbose): |
Simon Glass | abcc11d | 2023-07-19 17:48:41 -0600 | [diff] [blame] | 386 | """Object the Boards object to use |
| 387 | |
| 388 | Creates the output directory and ensures there is a boards.cfg file, then |
| 389 | read it in. |
| 390 | |
| 391 | Args: |
| 392 | output_dir (str): Output directory to use |
| 393 | regen_board_list (bool): True to just regenerate the board list |
| 394 | maintainer_check (bool): True to just run a maintainer check |
Simon Glass | 66d4c88 | 2023-07-19 17:49:30 -0600 | [diff] [blame] | 395 | full_check (bool): True to just run a full check of Kconfig and |
| 396 | maintainers |
Simon Glass | abcc11d | 2023-07-19 17:48:41 -0600 | [diff] [blame] | 397 | threads (int or None): Number of threads to use to create boards file |
| 398 | verbose (bool): False to suppress output from boards-file generation |
| 399 | |
| 400 | Returns: |
| 401 | Either: |
| 402 | int: Operation completed and buildman should exit with exit code |
| 403 | Boards: Boards object to use |
| 404 | """ |
| 405 | brds = boards.Boards() |
| 406 | nr_cpus = threads or multiprocessing.cpu_count() |
Simon Glass | 66d4c88 | 2023-07-19 17:49:30 -0600 | [diff] [blame] | 407 | if maintainer_check or full_check: |
| 408 | warnings = brds.build_board_list(jobs=nr_cpus, |
| 409 | warn_targets=full_check)[1] |
Simon Glass | abcc11d | 2023-07-19 17:48:41 -0600 | [diff] [blame] | 410 | if warnings: |
| 411 | for warn in warnings: |
| 412 | print(warn, file=sys.stderr) |
| 413 | return 2 |
| 414 | return 0 |
| 415 | |
| 416 | if not os.path.exists(output_dir): |
| 417 | os.makedirs(output_dir) |
| 418 | board_file = os.path.join(output_dir, 'boards.cfg') |
| 419 | if regen_board_list and regen_board_list != '-': |
| 420 | board_file = regen_board_list |
| 421 | |
| 422 | okay = brds.ensure_board_list(board_file, nr_cpus, force=regen_board_list, |
| 423 | quiet=not verbose) |
| 424 | if regen_board_list: |
| 425 | return 0 if okay else 2 |
| 426 | brds.read_boards(board_file) |
| 427 | return brds |
| 428 | |
| 429 | |
Simon Glass | 72f8bff | 2023-07-19 17:48:39 -0600 | [diff] [blame] | 430 | def determine_boards(brds, args, col, opt_boards, exclude_list): |
| 431 | """Determine which boards to build |
| 432 | |
| 433 | Each element of args and exclude can refer to a board name, arch or SoC |
| 434 | |
| 435 | Args: |
| 436 | brds (Boards): Boards object |
| 437 | args (list of str): Arguments describing boards to build |
| 438 | col (Terminal.Color): Color object |
| 439 | opt_boards (list of str): Specific boards to build, or None for all |
| 440 | exclude_list (list of str): Arguments describing boards to exclude |
| 441 | |
| 442 | Returns: |
| 443 | tuple: |
| 444 | list of Board: List of Board objects that are marked selected |
| 445 | why_selected: Dictionary where each key is a buildman argument |
| 446 | provided by the user, and the value is the list of boards |
| 447 | brought in by that argument. For example, 'arm' might bring |
| 448 | in 400 boards, so in this case the key would be 'arm' and |
| 449 | the value would be a list of board names. |
| 450 | board_warnings: List of warnings obtained from board selected |
| 451 | """ |
| 452 | exclude = [] |
| 453 | if exclude_list: |
| 454 | for arg in exclude_list: |
| 455 | exclude += arg.split(',') |
| 456 | |
| 457 | if opt_boards: |
| 458 | requested_boards = [] |
| 459 | for brd in opt_boards: |
| 460 | requested_boards += brd.split(',') |
| 461 | else: |
| 462 | requested_boards = None |
| 463 | why_selected, board_warnings = brds.select_boards(args, exclude, |
| 464 | requested_boards) |
| 465 | selected = brds.get_selected() |
| 466 | if not selected: |
| 467 | sys.exit(col.build(col.RED, 'No matching boards found')) |
| 468 | return selected, why_selected, board_warnings |
| 469 | |
| 470 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 471 | def adjust_args(args, series, selected): |
| 472 | """Adjust arguments according to various constraints |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 473 | |
| 474 | Updates verbose, show_errors, threads, jobs and step |
| 475 | |
| 476 | Args: |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 477 | args (Namespace): Namespace object to adjust |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 478 | series (Series): Series being built / summarised |
| 479 | selected (list of Board): List of Board objects that are marked |
| 480 | """ |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 481 | if not series and not args.dry_run: |
| 482 | args.verbose = True |
| 483 | if not args.summary: |
| 484 | args.show_errors = True |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 485 | |
| 486 | # By default we have one thread per CPU. But if there are not enough jobs |
| 487 | # we can have fewer threads and use a high '-j' value for make. |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 488 | if args.threads is None: |
| 489 | args.threads = min(multiprocessing.cpu_count(), len(selected)) |
| 490 | if not args.jobs: |
| 491 | args.jobs = max(1, (multiprocessing.cpu_count() + |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 492 | len(selected) - 1) // len(selected)) |
| 493 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 494 | if not args.step: |
| 495 | args.step = len(series.commits) - 1 |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 496 | |
Simon Glass | 31353f2 | 2023-07-19 17:48:53 -0600 | [diff] [blame] | 497 | # We can't show function sizes without board details at present |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 498 | if args.show_bloat: |
| 499 | args.show_detail = True |
Simon Glass | 31353f2 | 2023-07-19 17:48:53 -0600 | [diff] [blame] | 500 | |
Simon Glass | 3b300c5 | 2023-07-19 17:48:49 -0600 | [diff] [blame] | 501 | |
| 502 | def setup_output_dir(output_dir, work_in_output, branch, no_subdirs, col, |
| 503 | clean_dir): |
| 504 | """Set up the output directory |
| 505 | |
| 506 | Args: |
| 507 | output_dir (str): Output directory provided by the user, or None if none |
| 508 | work_in_output (bool): True to work in the output directory |
| 509 | branch (str): Name of branch to build, or None if none |
| 510 | no_subdirs (bool): True to put the output in the top-level output dir |
| 511 | clean_dir: Used for tests only, indicates that the existing output_dir |
| 512 | should be removed before starting the build |
| 513 | |
| 514 | Returns: |
| 515 | str: Updated output directory pathname |
| 516 | """ |
| 517 | if not output_dir: |
| 518 | if work_in_output: |
| 519 | sys.exit(col.build(col.RED, '-w requires that you specify -o')) |
| 520 | output_dir = '..' |
| 521 | if branch and not no_subdirs: |
| 522 | # As a special case allow the board directory to be placed in the |
| 523 | # output directory itself rather than any subdirectory. |
| 524 | dirname = branch.replace('/', '_') |
| 525 | output_dir = os.path.join(output_dir, dirname) |
| 526 | if clean_dir and os.path.exists(output_dir): |
| 527 | shutil.rmtree(output_dir) |
| 528 | return output_dir |
| 529 | |
Simon Glass | fdd750b | 2023-07-19 17:48:57 -0600 | [diff] [blame] | 530 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 531 | def run_builder(builder, commits, board_selected, args): |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 532 | """Run the builder or show the summary |
| 533 | |
| 534 | Args: |
| 535 | commits (list of Commit): List of commits being built, None if no branch |
| 536 | boards_selected (dict): Dict of selected boards: |
| 537 | key: target name |
| 538 | value: Board object |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 539 | args (Namespace): Namespace to use |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 540 | |
| 541 | Returns: |
| 542 | int: Return code for buildman |
| 543 | """ |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 544 | gnu_make = command.output(os.path.join(args.git, |
Simon Glass | fdd750b | 2023-07-19 17:48:57 -0600 | [diff] [blame] | 545 | 'scripts/show-gnu-make'), raise_on_error=False).rstrip() |
| 546 | if not gnu_make: |
| 547 | sys.exit('GNU Make not found') |
| 548 | builder.gnu_make = gnu_make |
| 549 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 550 | if not args.ide: |
| 551 | commit_count = count_build_commits(commits, args.step) |
| 552 | tprint(get_action_summary(args.summary, commit_count, board_selected, |
| 553 | args.threads, args.jobs)) |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 554 | |
Simon Glass | bc74d94 | 2023-07-19 17:49:06 -0600 | [diff] [blame] | 555 | builder.set_display_options( |
| 556 | args.show_errors, args.show_sizes, args.show_detail, args.show_bloat, |
| 557 | args.list_error_boards, args.show_config, args.show_environment, |
| 558 | args.filter_dtb_warnings, args.filter_migration_warnings, args.ide) |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 559 | if args.summary: |
Simon Glass | bc74d94 | 2023-07-19 17:49:06 -0600 | [diff] [blame] | 560 | builder.show_summary(commits, board_selected) |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 561 | else: |
Simon Glass | bc74d94 | 2023-07-19 17:49:06 -0600 | [diff] [blame] | 562 | fail, warned, excs = builder.build_boards( |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 563 | commits, board_selected, args.keep_outputs, args.verbose) |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 564 | if excs: |
| 565 | return 102 |
| 566 | if fail: |
| 567 | return 100 |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 568 | if warned and not args.ignore_warnings: |
Simon Glass | 927c827 | 2023-07-19 17:48:54 -0600 | [diff] [blame] | 569 | return 101 |
| 570 | return 0 |
Simon Glass | 3b300c5 | 2023-07-19 17:48:49 -0600 | [diff] [blame] | 571 | |
Simon Glass | f7524f3 | 2023-07-19 17:48:58 -0600 | [diff] [blame] | 572 | |
| 573 | def calc_adjust_cfg(adjust_cfg, reproducible_builds): |
| 574 | """Calculate the value to use for adjust_cfg |
| 575 | |
| 576 | Args: |
| 577 | adjust_cfg (list of str): List of configuration changes. See cfgutil for |
| 578 | details |
| 579 | reproducible_builds (bool): True to adjust the configuration to get |
| 580 | reproduceable builds |
| 581 | |
| 582 | Returns: |
| 583 | adjust_cfg (list of str): List of configuration changes |
| 584 | """ |
| 585 | adjust_cfg = cfgutil.convert_list_to_dict(adjust_cfg) |
| 586 | |
| 587 | # Drop LOCALVERSION_AUTO since it changes the version string on every commit |
| 588 | if reproducible_builds: |
| 589 | # If these are mentioned, leave the local version alone |
| 590 | if 'LOCALVERSION' in adjust_cfg or 'LOCALVERSION_AUTO' in adjust_cfg: |
| 591 | print('Not dropping LOCALVERSION_AUTO for reproducible build') |
| 592 | else: |
| 593 | adjust_cfg['LOCALVERSION_AUTO'] = '~' |
| 594 | return adjust_cfg |
| 595 | |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 596 | |
| 597 | def read_procs(tmpdir=tempfile.gettempdir()): |
| 598 | """Read the list of running buildman processes |
| 599 | |
| 600 | If the list is corrupted, returns an empty list |
| 601 | |
| 602 | Args: |
| 603 | tmpdir (str): Temporary directory to use (for testing only) |
| 604 | """ |
| 605 | running_fname = os.path.join(tmpdir, RUNNING_FNAME) |
| 606 | procs = [] |
| 607 | if os.path.exists(running_fname): |
| 608 | items = tools.read_file(running_fname, binary=False).split() |
| 609 | try: |
| 610 | procs = [int(x) for x in items] |
| 611 | except ValueError: # Handle invalid format |
| 612 | pass |
| 613 | return procs |
| 614 | |
| 615 | |
| 616 | def check_pid(pid): |
| 617 | """Check for existence of a unix PID |
| 618 | |
| 619 | https://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid-in-python |
| 620 | |
| 621 | Args: |
| 622 | pid (int): PID to check |
| 623 | |
| 624 | Returns: |
| 625 | True if it exists, else False |
| 626 | """ |
| 627 | try: |
| 628 | os.kill(pid, 0) |
| 629 | except OSError: |
| 630 | return False |
| 631 | else: |
| 632 | return True |
| 633 | |
| 634 | |
| 635 | def write_procs(procs, tmpdir=tempfile.gettempdir()): |
| 636 | """Write the list of running buildman processes |
| 637 | |
| 638 | Args: |
| 639 | tmpdir (str): Temporary directory to use (for testing only) |
| 640 | """ |
| 641 | running_fname = os.path.join(tmpdir, RUNNING_FNAME) |
| 642 | tools.write_file(running_fname, ' '.join([str(p) for p in procs]), |
| 643 | binary=False) |
| 644 | |
| 645 | # Allow another user to access the file |
| 646 | os.chmod(running_fname, 0o666) |
| 647 | |
| 648 | def wait_for_process_limit(limit, tmpdir=tempfile.gettempdir(), |
| 649 | pid=os.getpid()): |
| 650 | """Wait until the number of buildman processes drops to the limit |
| 651 | |
| 652 | This uses FileLock to protect a 'running' file, which contains a list of |
| 653 | PIDs of running buildman processes. The number of PIDs in the file indicates |
| 654 | the number of running processes. |
| 655 | |
| 656 | When buildman starts up, it calls this function to wait until it is OK to |
| 657 | start the build. |
| 658 | |
| 659 | On exit, no attempt is made to remove the PID from the file, since other |
| 660 | buildman processes will notice that the PID is no-longer valid, and ignore |
| 661 | it. |
| 662 | |
| 663 | Two timeouts are provided: |
| 664 | LOCK_WAIT_S: length of time to wait for the lock; if this occurs, the |
| 665 | lock is busted / removed before trying again |
| 666 | RUN_WAIT_S: length of time to wait to be allowed to run; if this occurs, |
| 667 | the build starts, with the PID being added to the file. |
| 668 | |
| 669 | Args: |
| 670 | limit (int): Maximum number of buildman processes, including this one; |
| 671 | must be > 0 |
| 672 | tmpdir (str): Temporary directory to use (for testing only) |
| 673 | pid (int): Current process ID (for testing only) |
| 674 | """ |
| 675 | from filelock import Timeout, FileLock |
| 676 | |
| 677 | running_fname = os.path.join(tmpdir, RUNNING_FNAME) |
| 678 | lock_fname = os.path.join(tmpdir, LOCK_FNAME) |
| 679 | lock = FileLock(lock_fname) |
| 680 | |
| 681 | # Allow another user to access the file |
| 682 | col = terminal.Color() |
| 683 | tprint('Waiting for other buildman processes...', newline=False, |
| 684 | colour=col.RED) |
| 685 | |
| 686 | claimed = False |
| 687 | deadline = time.time() + RUN_WAIT_S |
| 688 | while True: |
| 689 | try: |
| 690 | with lock.acquire(timeout=LOCK_WAIT_S): |
| 691 | os.chmod(lock_fname, 0o666) |
| 692 | procs = read_procs(tmpdir) |
| 693 | |
| 694 | # Drop PIDs which are not running |
| 695 | procs = list(filter(check_pid, procs)) |
| 696 | |
| 697 | # If we haven't hit the limit, add ourself |
| 698 | if len(procs) < limit: |
| 699 | tprint('done...', newline=False) |
| 700 | claimed = True |
| 701 | if time.time() >= deadline: |
| 702 | tprint('timeout...', newline=False) |
| 703 | claimed = True |
| 704 | if claimed: |
| 705 | write_procs(procs + [pid], tmpdir) |
| 706 | break |
| 707 | |
| 708 | except Timeout: |
| 709 | tprint('failed to get lock: busting...', newline=False) |
| 710 | os.remove(lock_fname) |
| 711 | |
| 712 | time.sleep(1) |
| 713 | tprint('starting build', newline=False) |
| 714 | print_clear() |
Simon Glass | f7524f3 | 2023-07-19 17:48:58 -0600 | [diff] [blame] | 715 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 716 | def do_buildman(args, toolchains=None, make_func=None, brds=None, |
Simon Glass | c1e1e1d | 2023-07-19 17:48:30 -0600 | [diff] [blame] | 717 | clean_dir=False, test_thread_exceptions=False): |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 718 | """The main control code for buildman |
| 719 | |
| 720 | Args: |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 721 | args: ArgumentParser object |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 722 | args: Command line arguments (list of strings) |
Simon Glass | ed098bb | 2014-09-05 19:00:13 -0600 | [diff] [blame] | 723 | toolchains: Toolchains to use - this should be a Toolchains() |
| 724 | object. If None, then it will be created and scanned |
| 725 | make_func: Make function to use for the builder. This is called |
| 726 | to execute 'make'. If this is None, the normal function |
| 727 | will be used, which calls the 'make' tool with suitable |
| 728 | arguments. This setting is useful for tests. |
Simon Glass | 5df4522 | 2022-07-11 19:04:00 -0600 | [diff] [blame] | 729 | brds: Boards() object to use, containing a list of available |
Simon Glass | cbd3658 | 2014-09-05 19:00:16 -0600 | [diff] [blame] | 730 | boards. If this is None it will be created and scanned. |
Simon Glass | a29b3ea | 2021-04-11 16:27:25 +1200 | [diff] [blame] | 731 | clean_dir: Used for tests only, indicates that the existing output_dir |
| 732 | should be removed before starting the build |
Simon Glass | 9bf9a72 | 2021-04-11 16:27:27 +1200 | [diff] [blame] | 733 | test_thread_exceptions: Uses for tests only, True to make the threads |
| 734 | raise an exception instead of reporting their result. This simulates |
| 735 | a failure in the code somewhere |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 736 | """ |
Simon Glass | af0e29f | 2023-07-19 17:48:31 -0600 | [diff] [blame] | 737 | # Used so testing can obtain the builder: pylint: disable=W0603 |
| 738 | global TEST_BUILDER |
Simon Glass | a10ebe1 | 2014-09-05 19:00:18 -0600 | [diff] [blame] | 739 | |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 740 | gitutil.setup() |
Simon Glass | 9f1ba0f | 2016-07-27 20:33:02 -0600 | [diff] [blame] | 741 | col = terminal.Color() |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 742 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 743 | git_dir = os.path.join(args.git, '.git') |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 744 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 745 | toolchains = get_toolchains(toolchains, col, args.override_toolchain, |
| 746 | args.fetch_arch, args.list_tool_chains, |
| 747 | args.verbose) |
Simon Glass | 18a0725 | 2023-08-03 12:51:36 -0600 | [diff] [blame] | 748 | if isinstance(toolchains, int): |
| 749 | return toolchains |
| 750 | |
Simon Glass | 3b300c5 | 2023-07-19 17:48:49 -0600 | [diff] [blame] | 751 | output_dir = setup_output_dir( |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 752 | args.output_dir, args.work_in_output, args.branch, |
| 753 | args.no_subdirs, col, clean_dir) |
Simon Glass | 6029af1 | 2020-04-09 15:08:51 -0600 | [diff] [blame] | 754 | |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 755 | # Work out what subset of the boards we are building |
Simon Glass | 5df4522 | 2022-07-11 19:04:00 -0600 | [diff] [blame] | 756 | if not brds: |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 757 | brds = get_boards_obj(output_dir, args.regen_board_list, |
Simon Glass | 66d4c88 | 2023-07-19 17:49:30 -0600 | [diff] [blame] | 758 | args.maintainer_check, args.full_check, |
Simon Glass | 89592fc | 2023-09-07 10:00:18 -0600 | [diff] [blame] | 759 | args.threads, args.verbose and |
| 760 | not args.print_arch and not args.print_prefix) |
Simon Glass | abcc11d | 2023-07-19 17:48:41 -0600 | [diff] [blame] | 761 | if isinstance(brds, int): |
| 762 | return brds |
Simon Glass | 924c73a | 2014-08-28 09:43:41 -0600 | [diff] [blame] | 763 | |
Simon Glass | 72f8bff | 2023-07-19 17:48:39 -0600 | [diff] [blame] | 764 | selected, why_selected, board_warnings = determine_boards( |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 765 | brds, args.terms, col, args.boards, args.exclude) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 766 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 767 | if args.print_prefix: |
Simon Glass | eaf1be2 | 2023-07-19 17:48:56 -0600 | [diff] [blame] | 768 | show_toolchain_prefix(brds, toolchains) |
Simon Glass | 48ac42e | 2019-12-05 15:59:14 -0700 | [diff] [blame] | 769 | return 0 |
| 770 | |
Simon Glass | a8a0ce7 | 2023-07-19 17:49:28 -0600 | [diff] [blame] | 771 | if args.print_arch: |
| 772 | show_arch(brds) |
| 773 | return 0 |
| 774 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 775 | series = determine_series(selected, col, git_dir, args.count, |
| 776 | args.branch, args.work_in_output) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 777 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 778 | adjust_args(args, series, selected) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 779 | |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 780 | # For a dry run, just show our actions as a sanity check |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 781 | if args.dry_run: |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 782 | show_actions(series, why_selected, selected, output_dir, board_warnings, |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 783 | args.step, args.threads, args.jobs, |
| 784 | args.verbose) |
Simon Glass | 7027487 | 2023-07-19 17:48:47 -0600 | [diff] [blame] | 785 | return 0 |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 786 | |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 787 | # Create a new builder with the selected args |
Simon Glass | 2183b84 | 2023-07-19 17:48:33 -0600 | [diff] [blame] | 788 | builder = Builder(toolchains, output_dir, git_dir, |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 789 | args.threads, args.jobs, checkout=True, |
| 790 | show_unknown=args.show_unknown, step=args.step, |
Tom Rini | 3f6f9b2 | 2024-07-05 14:34:07 -0600 | [diff] [blame] | 791 | no_subdirs=args.no_subdirs, full_path=args.full_path, |
| 792 | verbose_build=args.verbose_build, |
| 793 | mrproper=args.mrproper, |
| 794 | fallback_mrproper=args.fallback_mrproper, |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 795 | per_board_out_dir=args.per_board_out_dir, |
| 796 | config_only=args.config_only, |
| 797 | squash_config_y=not args.preserve_config_y, |
| 798 | warnings_as_errors=args.warnings_as_errors, |
| 799 | work_in_output=args.work_in_output, |
Simon Glass | e5650a8 | 2022-01-22 05:07:33 -0700 | [diff] [blame] | 800 | test_thread_exceptions=test_thread_exceptions, |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 801 | adjust_cfg=calc_adjust_cfg(args.adjust_cfg, |
| 802 | args.reproducible_builds), |
| 803 | allow_missing=get_allow_missing(args.allow_missing, |
| 804 | args.no_allow_missing, |
| 805 | len(selected), args.branch), |
| 806 | no_lto=args.no_lto, |
| 807 | reproducible_builds=args.reproducible_builds, |
| 808 | force_build = args.force_build, |
| 809 | force_build_failures = args.force_build_failures, |
| 810 | force_reconfig = args.force_reconfig, in_tree = args.in_tree, |
| 811 | force_config_on_failure=not args.quick, make_func=make_func) |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 812 | |
Simon Glass | cf91d31 | 2023-07-19 17:48:52 -0600 | [diff] [blame] | 813 | TEST_BUILDER = builder |
Simon Glass | c05694f | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 814 | |
Simon Glass | c229d32 | 2024-06-23 11:55:15 -0600 | [diff] [blame] | 815 | if args.process_limit: |
| 816 | wait_for_process_limit(args.process_limit) |
| 817 | |
Simon Glass | 00401d9 | 2023-07-19 17:48:55 -0600 | [diff] [blame] | 818 | return run_builder(builder, series.commits if series else None, |
Simon Glass | a56ac99 | 2023-07-19 17:49:04 -0600 | [diff] [blame] | 819 | brds.get_selected_dict(), args) |