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 E1ECDC001B0 for ; Wed, 19 Jul 2023 23:54:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D46758681D; Thu, 20 Jul 2023 01:51:16 +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="k3VhYXXs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B2A748606E; Thu, 20 Jul 2023 01:50:26 +0200 (CEST) Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 6C406867C7 for ; Thu, 20 Jul 2023 01:50:20 +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-xd2d.google.com with SMTP id ca18e2360f4ac-78372b895d6so8079939f.2 for ; Wed, 19 Jul 2023 16:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810619; x=1690415419; 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=BUUZ/Tq5xDS7lNJqNFwYt+UMLqm1oRehZExEk+dT7Wk=; b=k3VhYXXsAfkkDrJW1oKQt2NoviaS3WSo0RP0vYmuDlXnisFohJj5BjDKK5lYNj2Sw+ UMiH0xBGCBxqlFm2oxs9tN/UEOZ/K7bS8DJnBbaRiu53DjMwSBLFVCwkXq+Wb2aFTCmM GJmaR/pxT08N9+L1pdWCdv8sO0Ok6a5XlXW7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810619; x=1690415419; 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=BUUZ/Tq5xDS7lNJqNFwYt+UMLqm1oRehZExEk+dT7Wk=; b=MZKLqOzeoPDSlYx/0jgYBGc+YEk7cYpGJXf0CrWDGVhxU7BB1izSPR8edPLjOBcIis joV4cQig0JksxPodacfH4W4ET612iobM9ECAC2lfWxq6y81hGHtKTf4QHj/pK4cw8gRN MJqDFlxLWS4zvaDsCgEas+neMIs6JJor2J6beBLphMwc55KmZIq0nRt8mymfGOftgQi3 9gadzJtv1RjAGDccDmkrq99X7Pa92F8Kri4OfwRdFIU6vXZh5lanDsNmBvWUWku3ntDW T5yuGVfaomnTImy761AWcVJAl9bBvhTapnNt224iSIPHqJWwS1tPS90nisZZ6kC/SOXf MYnA== X-Gm-Message-State: ABy/qLYH6bDscdESItTuMnOSSsqMnnSrjxv0gxYNNBcqbjaqCcqSvO/V DWI8m/IsiejDsBVaTTzWAUeM9SHsA3vZssBwIIs= X-Google-Smtp-Source: APBJJlG3LdOv6UaNEzP91qTCpXywHkZFmQwDiWidWK8+NC5F+MywWx7F++AECutGFC6Yn37f2gjohg== X-Received: by 2002:a5d:91d3:0:b0:783:572c:9caa with SMTP id k19-20020a5d91d3000000b00783572c9caamr977921ior.0.1689810619063; Wed, 19 Jul 2023 16:50:19 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 26/83] buildman: Move fetch-arch code into a separate function Date: Wed, 19 Jul 2023 17:48:34 -0600 Message-ID: <20230719234953.796101-27-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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.487.g6d72f3e995-goog