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 55DEAC001B0 for ; Wed, 19 Jul 2023 23:56:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A91D8683F; Thu, 20 Jul 2023 01:51:31 +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="EESuVWwl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 777F0867E6; Thu, 20 Jul 2023 01:50:32 +0200 (CEST) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (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 5D41A867BF for ; Thu, 20 Jul 2023 01:50:25 +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-x134.google.com with SMTP id e9e14a558f8ab-3458a08310aso1567765ab.3 for ; Wed, 19 Jul 2023 16:50:25 -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=3o6JVXor6uVpRm7lhhwhCDw74cgYSV0ITxbmxuVUNs4=; b=EESuVWwllB75z7E7/Qq20Fk1ZEi+xNzFReFfyqua+1MJcdfnIgM1poZo1UqorVHAOi aF1aAxTxlLDJkV8JoWIQlbmWRrbiKYr/74rYxaH/rkecG+rumVP3yhM4l6VzuiyP8V2H O95V3K0SP44T5w13FxCB19e9c6y4HHi4ZwiO8= 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=3o6JVXor6uVpRm7lhhwhCDw74cgYSV0ITxbmxuVUNs4=; b=Ggjj0JopV0nI0YvEZ1AXwsK6aha42p55YKDWCXLGhTDu9vskZY2gDo+wJaISMlGEy9 HcBMzJdFrL2Io7OESypoX9JfElyDxbzsfxPoNht9If7o5QkfEkT/bKsNUKBw0eWvlTl/ 8b3AvbVoriC3BhQyLfk8e4/QafU6+XTn/+dL8YJPVIAJ5/DMK9pEupSI7bUYsry3GT7q /QfMK5TApueVIqStlVHjPQSPd5TzzSHBwY7yDom/MNE9Tya0ensefPBKYjooKV0DIyRx huUbMuCVurntymsT5OfPqFTXnmf+CjXlBcV+7pvGVyrQ7wPpXqpJTFsHUlvYH6ZJbf4h k/jA== X-Gm-Message-State: ABy/qLZkeW9peLPDfTZMNDnpEsHNrBw04zrLkhMtLYjpaYE39WQC4Ine B2jJuWXkCQ5Wb6HTrepJqg65PMaNsvyDl27UksA= X-Google-Smtp-Source: APBJJlHcWB82rNnxLvIeZ6Vc452fWT3oxNIGSBKKWLsIDC/a1csri6H80vg10zE6t+XXebnNVXMLHg== X-Received: by 2002:a92:6c10:0:b0:345:cdbe:833c with SMTP id h16-20020a926c10000000b00345cdbe833cmr3383521ilc.28.1689810623985; Wed, 19 Jul 2023 16:50:23 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 33/83] buildman: Move Boards-object code into a function Date: Wed, 19 Jul 2023 17:48:41 -0600 Message-ID: <20230719234953.796101-34-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 which obtains a Boards object 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 | 74 +++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index facbef380eff..ef797777ed08 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -259,6 +259,49 @@ def do_fetch_arch(toolchains, col, fetch_arch): return 0 +def get_boards_obj(output_dir, regen_board_list, maintainer_check, threads, + verbose): + """Object the Boards object to use + + Creates the output directory and ensures there is a boards.cfg file, then + read it in. + + Args: + output_dir (str): Output directory to use + regen_board_list (bool): True to just regenerate the board list + maintainer_check (bool): True to just run a maintainer check + threads (int or None): Number of threads to use to create boards file + verbose (bool): False to suppress output from boards-file generation + + Returns: + Either: + int: Operation completed and buildman should exit with exit code + Boards: Boards object to use + """ + brds = boards.Boards() + nr_cpus = threads or multiprocessing.cpu_count() + if maintainer_check: + warnings = brds.build_board_list(jobs=nr_cpus)[1] + if warnings: + for warn in warnings: + print(warn, file=sys.stderr) + return 2 + return 0 + + if not os.path.exists(output_dir): + os.makedirs(output_dir) + board_file = os.path.join(output_dir, 'boards.cfg') + if regen_board_list and regen_board_list != '-': + board_file = regen_board_list + + okay = brds.ensure_board_list(board_file, nr_cpus, force=regen_board_list, + quiet=not verbose) + if regen_board_list: + return 0 if okay else 2 + brds.read_boards(board_file) + return brds + + def determine_boards(brds, args, col, opt_boards, exclude_list): """Determine which boards to build @@ -349,34 +392,13 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, sys.exit(col.build(col.RED, '-w requires that you specify -o')) options.output_dir = '..' - nr_cups = options.threads or multiprocessing.cpu_count() - # Work out what subset of the boards we are building if not brds: - if not os.path.exists(options.output_dir): - os.makedirs(options.output_dir) - board_file = os.path.join(options.output_dir, 'boards.cfg') - if options.regen_board_list and options.regen_board_list != '-': - board_file = options.regen_board_list - - brds = boards.Boards() - - if options.maintainer_check: - warnings = brds.build_board_list(jobs=nr_cups)[1] - if warnings: - for warn in warnings: - print(warn, file=sys.stderr) - return 2 - return 0 - - okay = brds.ensure_board_list( - board_file, - options.threads or multiprocessing.cpu_count(), - force=options.regen_board_list, - quiet=not options.verbose) - if options.regen_board_list: - return 0 if okay else 2 - brds.read_boards(board_file) + brds = get_boards_obj(options.output_dir, options.regen_board_list, + options.maintainer_check, options.threads, + options.verbose) + if isinstance(brds, int): + return brds selected, why_selected, board_warnings = determine_boards( brds, args, col, options.boards, options.exclude) -- 2.41.0.487.g6d72f3e995-goog