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 11FCFC001B0 for ; Wed, 19 Jul 2023 23:55:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2B1386840; Thu, 20 Jul 2023 01:51: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=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="AmZnDrlm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBD40867E5; Thu, 20 Jul 2023 01:50:30 +0200 (CEST) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 A3DC88679B for ; Thu, 20 Jul 2023 01:50:24 +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-xd31.google.com with SMTP id ca18e2360f4ac-78372625badso8528739f.3 for ; Wed, 19 Jul 2023 16:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810623; x=1690415423; 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=cRRiHqHa+RxHDXutMjtXuHuwv9EIYAKxbqBFjDcOk9s=; b=AmZnDrlmJO651FxcR6pyvOr3ex4WT8DVW8ZOGME+K86YxapmLQ6KG/01v+gVTJfi1S x8/P9JYk4vfOz5FtWOqsQ1AVjv7PPp3YogfBqExOm/Ryl5uF+7rBR7ONzGVfPEQWaBFi LSq9Fg3V3G37UtNEJiz+SgEYfhGY2nEhhRLJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810623; x=1690415423; 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=cRRiHqHa+RxHDXutMjtXuHuwv9EIYAKxbqBFjDcOk9s=; b=QZwh4vsYF4OaIDIJDxAWnFyPMzcCuIVWLIE+BnofGzn8j88Gx74DI1GRCDWGE2rmHk 4jtdQavKTvjhUT6XR2UtZkhs2DKpqgU8RuwpP6TvzjrSH6ZB6mQtkRI0LvcfDjuBeKbz cq68x53YaNYbeukTAwWxZMcMCU/Zdq733KnmD9YAkgVZbYFvTgleeD1c3Igke4kb8yDe 4zBb6owR6jSln/p+wu9UlB5LWoVyreSoXfzPiRbIpvIcqyPdSqA9jC/U0RFCPoPC+fz0 pGeT7GCQFRyOrBaHB5+jI0WoMUQKlxPXEAr/I+MxhYdX7RnwLe7ylIVcJoHKVyoq5wVc CTcg== X-Gm-Message-State: ABy/qLaXYJZzXKd/XKfKl3aTJeoy8GAMSC3+dUUx8uu2vAOGwP2t0Ovt UFlDT330xMSVD5hZDTeaLaYTd8p9TSqeVU8C+U8= X-Google-Smtp-Source: APBJJlH+Wjq6h/uWfR8JVpKohe0eHB/I1G4Gbme2ox0mcftititpVEeOUBu5eP3Q9US2Uxhu4kujQw== X-Received: by 2002:a5d:9b01:0:b0:783:6361:17ea with SMTP id y1-20020a5d9b01000000b00783636117eamr4234359ion.8.1689810623279; 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.22 (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 32/83] bulidman: Move more code to determine_series() Date: Wed, 19 Jul 2023 17:48:40 -0600 Message-ID: <20230719234953.796101-33-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 some more series-related code here, to reduce the size of the main function. Signed-off-by: Simon Glass --- (no changes since v2) Changes in v2: - Correct operation of -A tools/buildman/control.py | 82 ++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 8f1edf9dbb95..facbef380eff 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -148,14 +148,17 @@ def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): return allow_missing -def determine_series(count, has_range, branch, git_dir): +def determine_series(selected, col, git_dir, count, branch, work_in_output): """Determine the series which is to be built, if any Args: + selected (list of Board(: List of Board objects that are marked + selected + col (Terminal.Color): Color object to use + git_dir (str): Git directory to use, e.g. './.git' count (int): Number of commits in branch - has_range (bool): True if a range of commits ('xx..yy') is being built branch (str): Name of branch to build, or None if none - git_dir (str): Git directory to use, e.g. './.git' + work_in_output (bool): True to work in the output directory Returns: Series: Series to build, or None for none @@ -171,6 +174,40 @@ def determine_series(count, has_range, branch, git_dir): other hand conflicting tags will cause an error. So allow later tags to overwrite earlier ones by setting allow_overwrite=True """ + + # Work out how many commits to build. We want to build everything on the + # branch. We also build the upstream commit as a control so we can see + # problems introduced by the first commit on the branch. + has_range = branch and '..' in branch + if count == -1: + if not branch: + count = 1 + else: + if has_range: + count, msg = gitutil.count_commits_in_range(git_dir, branch) + else: + count, msg = gitutil.count_commits_in_branch(git_dir, branch) + if count is None: + sys.exit(col.build(col.RED, msg)) + elif count == 0: + sys.exit(col.build(col.RED, + f"Range '{branch}' has no commits")) + if msg: + print(col.build(col.YELLOW, msg)) + count += 1 # Build upstream commit also + + if not count: + msg = (f"No commits found to process in branch '{branch}': " + "set branch's upstream or use -c flag") + sys.exit(col.build(col.RED, msg)) + if work_in_output: + if len(selected) != 1: + sys.exit(col.build(col.RED, + '-w can only be used with a single board')) + if count != 1: + sys.exit(col.build(col.RED, + '-w can only be used with a single commit')) + if branch: if count == -1: if has_range: @@ -350,43 +387,8 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, sys.exit(col.build(col.RED, err)) return 0 - # Work out how many commits to build. We want to build everything on the - # branch. We also build the upstream commit as a control so we can see - # problems introduced by the first commit on the branch. - count = options.count - has_range = options.branch and '..' in options.branch - if count == -1: - if not options.branch: - count = 1 - else: - if has_range: - count, msg = gitutil.count_commits_in_range(git_dir, - options.branch) - else: - count, msg = gitutil.count_commits_in_branch(git_dir, - options.branch) - if count is None: - sys.exit(col.build(col.RED, msg)) - elif count == 0: - sys.exit(col.build(col.RED, - f"Range '{options.branch}' has no commits")) - if msg: - print(col.build(col.YELLOW, msg)) - count += 1 # Build upstream commit also - - if not count: - msg = (f"No commits found to process in branch '{options.branch}': " - "set branch's upstream or use -c flag") - sys.exit(col.build(col.RED, msg)) - if options.work_in_output: - if len(selected) != 1: - sys.exit(col.build(col.RED, - '-w can only be used with a single board')) - if count != 1: - sys.exit(col.build(col.RED, - '-w can only be used with a single commit')) - - series = determine_series(count, has_range, options.branch, git_dir) + series = determine_series(selected, col, git_dir, options.count, + options.branch, options.work_in_output) if not series and not options.dry_run: options.verbose = True if not options.summary: -- 2.41.0.487.g6d72f3e995-goog