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 9EE04C0015E for ; Sun, 16 Jul 2023 00:42:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 71687863E9; Sun, 16 Jul 2023 02:38:58 +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="mORUiyz4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35FCC865DF; Sun, 16 Jul 2023 02:37:56 +0200 (CEST) Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 6B7D58634D for ; Sun, 16 Jul 2023 02:37:47 +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-xd30.google.com with SMTP id ca18e2360f4ac-7835971026fso129565639f.3 for ; Sat, 15 Jul 2023 17:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467866; x=1692059866; 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=WrSYqDo9Ty90CQnhL2qemanztHjtSUQCv2Iqd4/9Y4Y=; b=mORUiyz43XXNqAGLvJiVPCJG6OGx5107ZF7WLg9RG7sHDFOS8v5zoBEvDIOhgrNo42 f4kyhtXfvL+q6SyTLJbPdCI9B0+54D+ZlKsaiemRSWTxVTKBxFGS5qhainIjg0vJ5WWD G/11lFFbee9dRIjGb+ElZiZ770Scpx/OaAILk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467866; x=1692059866; 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=WrSYqDo9Ty90CQnhL2qemanztHjtSUQCv2Iqd4/9Y4Y=; b=VpLKKxrH+B3yN7n8ZkdlTOtcnBLNct2EKNw0Y8NZxFK1uj2LN5TUcBVsyiYZ7a+CUB fWyO6wkYEBJIElfvkWbNLSnQOjSy21CLJIkB1Bd/4B8WIu3l/mbuZbHNDR/UpZVKQLtK jf9Ic89dN7XxCU830ZwU4kizG0I0/yy1jkDKUkHiNaFh+dQWfOSTz3Oe6oP05B2mumFf pNi2xHxrtuRoL0ygO3nGpYDlnqtabXwzwUcf8wK5PSOciDlemBLbA06HeBUUdtSwKfTK 245deGScMR235h/axnFDvvT4KC2LxaWh6oLkB+al4itklcrgjDTxdSW7jw2f+ia5UN4O 2Crg== X-Gm-Message-State: ABy/qLYY8Q3Qpmi8wel6RHbkd9JIRzsvJZZ8xV2qTYRXMb04m1GuCaY5 m8zru5XLVgWj/eIzENTrofjLR+F17k0zB1iz7h8= X-Google-Smtp-Source: APBJJlFvq1Llv2g4pVsPZu+VfkwNcb5K49ywt0gYDRJdBSKiSDayOJUrAy7e0Klpqam9++NWvVBkdg== X-Received: by 2002:a92:d687:0:b0:33e:7552:3fd5 with SMTP id p7-20020a92d687000000b0033e75523fd5mr7167306iln.4.1689467865945; Sat, 15 Jul 2023 17:37:45 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:45 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 32/81] bulidman: Move toolchain handling to a function Date: Sat, 15 Jul 2023 18:36:00 -0600 Message-ID: <20230716003718.231903-33-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 Move the code for dealing with toolchains out into its own function, to reduce the size of the main function. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 53 ++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index ef797777ed08..2bc235e130a2 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -259,6 +259,41 @@ def do_fetch_arch(toolchains, col, fetch_arch): return 0 +def get_toolchains(toolchains, col, override_toolchain, fetch_arch, + list_tool_chains, verbose): + """Get toolchains object to use + + Args: + toolchains (Toolchains or None): Toolchains to use. If None, then a + Toolchains object will be created and scanned + col (Terminal.Color): Color object + override_toolchain (str or None): Override value for toolchain, or None + fetch_arch (bool): True to fetch the toolchain for the architectures + list_tool_chains (bool): True to list all tool chains + verbose (bool): True for verbose output when listing toolchains + + Returns: + Either: + int: Operation completed and buildman should exit with exit code + Toolchains: Toolchains object to use + """ + no_toolchains = toolchains is None + if no_toolchains: + toolchains = toolchain.Toolchains(override_toolchain) + + if fetch_arch: + return do_fetch_arch(toolchains, col, fetch_arch) + + if no_toolchains: + toolchains.GetSettings() + toolchains.Scan(list_tool_chains and verbose) + if list_tool_chains: + toolchains.List() + print() + return 0 + return toolchains + + def get_boards_obj(output_dir, regen_board_list, maintainer_check, threads, verbose): """Object the Boards object to use @@ -372,21 +407,9 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, git_dir = os.path.join(options.git, '.git') - no_toolchains = toolchains is None - if no_toolchains: - toolchains = toolchain.Toolchains(options.override_toolchain) - - if options.fetch_arch: - return do_fetch_arch(toolchains, col, options.fetch_arch) - - if no_toolchains: - toolchains.GetSettings() - toolchains.Scan(options.list_tool_chains and options.verbose) - if options.list_tool_chains: - toolchains.List() - print() - return 0 - + toolchains = get_toolchains(toolchains, col, options.override_toolchain, + options.fetch_arch, options.list_tool_chains, + options.verbose) if not options.output_dir: if options.work_in_output: sys.exit(col.build(col.RED, '-w requires that you specify -o')) -- 2.41.0.455.g037347b96a-goog