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 5ABE6C001B0 for ; Wed, 19 Jul 2023 23:56:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D2B8086836; Thu, 20 Jul 2023 01:51:29 +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="ClJNHbnU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1967F867D4; Thu, 20 Jul 2023 01:50:32 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 1FD0F867C5 for ; Thu, 20 Jul 2023 01:50:26 +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-il1-x130.google.com with SMTP id e9e14a558f8ab-3461053677eso800135ab.0 for ; Wed, 19 Jul 2023 16:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810624; x=1690415424; 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=z8jVbUeFuasDIZSOyDBHr61lIA8plCmNe77/qmmiJ8Y=; b=ClJNHbnUYFw6J5PjO/HqRov0Xn3QYnQ7VRKNVnZMf+Z5P66X6KVeWZBzFd+BcLkZUV ZuZghELps24LngOrG7rqaaflUd/JPGQUXx7RI5SCQPENmteGIlQtV6M3YIDq9mFgCvEw zCpT16vp0n8mR87NM9edS8CZoMZ8F4QwK3fEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810624; x=1690415424; 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=z8jVbUeFuasDIZSOyDBHr61lIA8plCmNe77/qmmiJ8Y=; b=CcPi6ncAAY3a+yLN0eD88kkoOwnAL5CkCk/CaMdJkEL3/4GRbEJn13siYwkbhdthqI xy0iHpRM27fbsYVXjpkfTz7dAYKsfWYPPavlm1OlV0uXenmuNnYk6HlRuTCyxSWnDrgD 2pWH4qc89oKawIQvUxXI5mWJX9T4GWHbikpH065bcEsk5MVHr8qGvxGlQr7qZDeuwEil 70p4xXkh9rVfyLCdUFIeFhI3sO1wMxX8iFD0kW4y+roaJLF1v7DB158dcw1ZRhWePVpN 2hBWLtympI4ulkvQmmN2Zhcm3c+zlhS75iCf9DSXG0wRhxTO+kNBZeJAEAM4MmXGvPJP 7yWw== X-Gm-Message-State: ABy/qLZqOJVAJLQxmieKtqqmYxWvUjR+e/PDRvhLv9/xIyuj97e5I0yz oS9PNU2TxT3xhT5pCywT/D2zRyUTKD5Dg1FGFWY= X-Google-Smtp-Source: APBJJlFeWQL6er2hGEApXTDBVQHb8GefABPhHno0WmnPgJWcf1zp6WBIB7v8eKpmV8Bk2NIOQcyX5A== X-Received: by 2002:a05:6e02:1245:b0:348:7e6a:a1a5 with SMTP id j5-20020a056e02124500b003487e6aa1a5mr2735078ilq.6.1689810624662; Wed, 19 Jul 2023 16:50:24 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:24 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 34/83] bulidman: Move toolchain handling to a function Date: Wed, 19 Jul 2023 17:48:42 -0600 Message-ID: <20230719234953.796101-35-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 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.487.g6d72f3e995-goog