Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 249DAC0015E for ; Sun, 16 Jul 2023 00:41:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 17D0386623; Sun, 16 Jul 2023 02:38:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hth+1YsO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 13FFF863F0; Sun, 16 Jul 2023 02:37:51 +0200 (CEST) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D41098623A for ; Sun, 16 Jul 2023 02:37:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-78358268d1bso152853039f.3 for ; Sat, 15 Jul 2023 17:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467860; x=1692059860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BqspsqdT7f6LjihQyDbdqF2w215Asv4yUe2GaogedYI=; b=Hth+1YsOkevxuTVu7FXdu2jgZEaTn55UtFw81YD1Pi/9KK4Q/EUR+DJ8l7ahQnMoh9 gYHB2q1EntAI+ZN9utYLY5TGRhFlNvMjCwxejV2aiOqQlk/WwnofN40S7XJTOoz4ZmGx NA5mWK5gYUFY47MYp1bg5/N69hcGoR+/seR2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467860; x=1692059860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BqspsqdT7f6LjihQyDbdqF2w215Asv4yUe2GaogedYI=; b=JVjfMeiOr8V6g98frPcJIITK12MkaiRgAVa46+CE5fg+oE9p/SRbuhLRM9SsKrG/Cx DhWUQGvmh4oweQSV3/8jk4KWPyNTYu2NbQiSQJTElfC+PvN5Wqk+xm16MUmTw/+eWChH yso4CYexTmdPvFjMrQhAlu8RqCwibdKtAW0FJnL6A8z801eny9xdG8BHPJlK98nXRb1A nf/Y6/X3hkk+WgtbVh07DwSCYQh5EfceboO/GQJb3O3siWoPi5j2Jz64SsZfrhsWhrWF JZJ1JwB+zMsVvCj0DYcZj88HmdFAH5JAoD7PyIu/CvGBSwSXcCEca0jop+TVh2xKemWS DOWQ== X-Gm-Message-State: ABy/qLbv9UC+QKWTqEobljfd3zoK+8/S+fM4LSS6BS9jkga+Gm0zfhcU BW9toWngp2A9GuwiBT5jd4G9g0SMrfAMS6hDeHI= X-Google-Smtp-Source: APBJJlFHVFMAnDjpHd0NRu2fCcwEXcWowon+4xQsaEjsJHpGo+MyUTpg1PfeVyHyYnjjp5bF/lFc0Q== X-Received: by 2002:a05:6602:1c4:b0:780:ce89:ca73 with SMTP id w4-20020a05660201c400b00780ce89ca73mr7581245iot.14.1689467860435; Sat, 15 Jul 2023 17:37:40 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 24/81] buildman: Move fetch-arch code into a separate function Date: Sat, 15 Jul 2023 18:35:52 -0600 Message-ID: <20230716003718.231903-25-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- (no changes since v1) tools/buildman/control.py | 49 +++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index d8fead93e730..5762ec90c0bd 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() -- 2.41.0.455.g037347b96a-goog