diff options
author | Simon Glass <sjg@chromium.org> | 2023-07-05 13:18:38 +0100 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-07-12 07:57:20 -0600 |
commit | 075c6a5eb53f8fb8d375373293c92396f3b4a448 (patch) | |
tree | a2ac2d8888c9149e191c4d5dcfb54cb1a5ca3302 | |
parent | e7012efaf37bb9b195d610dd40fa39c42c620f70 (diff) | |
download | u-boot-075c6a5eb53f8fb8d375373293c92396f3b4a448.zip u-boot-075c6a5eb53f8fb8d375373293c92396f3b4a448.tar.gz u-boot-075c6a5eb53f8fb8d375373293c92396f3b4a448.tar.bz2 |
buildman: Move board-selection code into a function
Create a new determine_boards() function to hold the code which selects
which boards to build.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | tools/buildman/control.py | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c45a28c..b94e066 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -222,6 +222,47 @@ def do_fetch_arch(toolchains, col, fetch_arch): return 0 +def determine_boards(brds, args, col, opt_boards, exclude): + """Determine which boards to build + + Each element of args and exclude can refer to a board name, arch or SoC + + Args: + brds (Boards): Boards object + args (list of str): Arguments describing boards to build + col (Terminal.Color): Color object + opt_boards (list of str): Specific boards to build, or None for all + exclude (list of str): Arguments describing boards to exclude + + Returns: + tuple: + list of Board: List of Board objects that are marked selected + why_selected: Dictionary where each key is a buildman argument + provided by the user, and the value is the list of boards + brought in by that argument. For example, 'arm' might bring + in 400 boards, so in this case the key would be 'arm' and + the value would be a list of board names. + board_warnings: List of warnings obtained from board selected + """ + exclude = [] + if exclude: + for arg in exclude: + exclude += arg.split(',') + + if opt_boards: + requested_boards = [] + for brd in opt_boards: + requested_boards += brd.split(',') + else: + requested_boards = None + why_selected, board_warnings = brds.select_boards(args, exclude, + requested_boards) + selected = brds.get_selected() + if not selected: + sys.exit(col.build(col.RED, 'No matching boards found')) + return selected, why_selected, board_warnings + + def do_buildman(options, args, toolchains=None, make_func=None, brds=None, clean_dir=False, test_thread_exceptions=False): """The main control code for buildman @@ -289,22 +330,8 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, return 0 if okay else 2 brds.read_boards(board_file) - exclude = [] - if options.exclude: - for arg in options.exclude: - exclude += arg.split(',') - - if options.boards: - requested_boards = [] - for brd in options.boards: - requested_boards += brd.split(',') - else: - requested_boards = None - why_selected, board_warnings = brds.select_boards(args, exclude, - requested_boards) - selected = brds.get_selected() - if not selected: - sys.exit(col.build(col.RED, 'No matching boards found')) + selected, why_selected, board_warnings = determine_boards( + brds, args, col, options.boards, options.exclude) if options.print_prefix: err = show_toolchain_prefix(brds, toolchains) |