summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-20 02:48:34 +0300
committerSimon Glass <sjg@chromium.org>2023-07-24 18:34:10 +0300
commitf7a36d54bab8173833acb862c049928a85745d97 (patch)
tree94b6d806381b6495df7cfc2e5a187b23c50f81de
parentd230c0143f1dfac13ce680b21ccbdfb99c8fe5c9 (diff)
downloadu-boot-f7a36d54bab8173833acb862c049928a85745d97.tar.xz
buildman: Move fetch-arch code into a separate function
Reduce the size of the do_buildman() function a little by moving the code that handles --fetch-arch into a separate function. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/buildman/control.py49
1 files changed, 31 insertions, 18 deletions
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index d8fead93e7..5762ec90c0 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -192,6 +192,36 @@ def determine_series(count, has_range, branch, git_dir):
return series
+def do_fetch_arch(toolchains, col, fetch_arch):
+ """Handle the --fetch-arch option
+
+ Args:
+ toolchains (Toolchains): Tool chains to use
+ col (terminal.Color): Color object to build
+ fetch_arch (str): Argument passed to the --fetch-arch option
+
+ Returns:
+ int: Return code for buildman
+ """
+ if fetch_arch == 'list':
+ sorted_list = toolchains.ListArchs()
+ print(col.build(
+ col.BLUE,
+ f"Available architectures: {' '.join(sorted_list)}\n"))
+ return 0
+
+ if fetch_arch == 'all':
+ fetch_arch = ','.join(toolchains.ListArchs())
+ print(col.build(col.CYAN,
+ f'\nDownloading toolchains: {fetch_arch}'))
+ for arch in fetch_arch.split(','):
+ print()
+ ret = toolchains.FetchAndInstall(arch)
+ if ret:
+ return ret
+ return 0
+
+
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
@@ -226,24 +256,7 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None,
toolchains = toolchain.Toolchains(options.override_toolchain)
if options.fetch_arch:
- if options.fetch_arch == 'list':
- sorted_list = toolchains.ListArchs()
- print(col.build(
- col.BLUE,
- f"Available architectures: {' '.join(sorted_list)}\n"))
- return 0
-
- fetch_arch = options.fetch_arch
- if fetch_arch == 'all':
- fetch_arch = ','.join(toolchains.ListArchs())
- print(col.build(col.CYAN,
- f'\nDownloading toolchains: {fetch_arch}'))
- for arch in fetch_arch.split(','):
- print()
- ret = toolchains.FetchAndInstall(arch)
- if ret:
- return ret
- return 0
+ return do_fetch_arch(toolchains, col, options.fetch_arch)
if no_toolchains:
toolchains.GetSettings()