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 7F139C0015E for ; Sun, 16 Jul 2023 00:43:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0DF918662B; Sun, 16 Jul 2023 02:39: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="QMVEhZkk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEA08865D8; Sun, 16 Jul 2023 02:37:56 +0200 (CEST) Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) (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 9FAA6863EE for ; Sun, 16 Jul 2023 02:37:46 +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-xd29.google.com with SMTP id ca18e2360f4ac-77acb04309dso173060739f.2 for ; Sat, 15 Jul 2023 17:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467865; x=1692059865; 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=W3acisHZvzJJVnUabVzycUQVUZeN+8sm/sJXOdysgU0=; b=QMVEhZkkOA+qnbuaD6AYte1jC5bwT9hWnT5rgw/2vz/0q9nQHHqT11klAQkaMIw4CY Y2S87ROrU+g/h71GKkNKMvzlbTIW2REHwbwUAtrFu62mRyGUWq6t8EVvHgEHJcFSfBMX 0Wv3LL9yIYuPXswAvicCVZn0H/ZGe64mnjs2c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467865; x=1692059865; 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=W3acisHZvzJJVnUabVzycUQVUZeN+8sm/sJXOdysgU0=; b=A7UP2MQHA0vicDxcIl52HHn4PgNRYxZ2SkgUJAxZ1c2YXen0fXRlA7TS0AqiNorp2N 3Q36GfYdm0JZPaKnjpVsmDTiMfyu0oJVdlwujFbJ26368ObDTeot6HxlQ7vnwrwCUXNZ RdbP3/AeZaHlDvQCOzAbQOzbQbN3oqrMC0Xu7wCtZWX45wxOl4QhuHgrwbTIzCUkqMXy 2+q/RzbyKHuUkT6RsG0OHYjmO1X0NH67jhyWEOIJwSVw+OeL1evzj0BVCPUlUe+ct24A AAj1VvffHY6cnFyDiKB9ZO4qV0vIpTcPwxHBC2QcvPyYNMnZ3hDHQ2Q22RnleEvUy2sm wFLQ== X-Gm-Message-State: ABy/qLbuGLs7mj0VlmjmRcDexNSeuVaG+AdPVdqnrvVkhYlJjqkrJ+F1 u3auLz2yFo3pqFG+rkCPt1aFyujULSL2wDs3/2E= X-Google-Smtp-Source: APBJJlFjiM/1m0lS8405MNkSD3TgY0wH4zA0RXdKIhcYfnhrBj2M7nu3/TJPQMDhfeyLBI9Hu7JyPg== X-Received: by 2002:a6b:fd17:0:b0:786:ff72:8da8 with SMTP id c23-20020a6bfd17000000b00786ff728da8mr9356680ioi.17.1689467865308; 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.44 (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 31/81] buildman: Move Boards-object code into a function Date: Sat, 15 Jul 2023 18:35:59 -0600 Message-ID: <20230716003718.231903-32-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 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.455.g037347b96a-goog