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 30A32C0015E for ; Sun, 16 Jul 2023 00:42:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B3CA86398; Sun, 16 Jul 2023 02:38:56 +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="VEQcwqsZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 962BA865D8; Sun, 16 Jul 2023 02:37:55 +0200 (CEST) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 0E905863C1 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-xd33.google.com with SMTP id ca18e2360f4ac-7878e573827so57759139f.1 for ; Sat, 15 Jul 2023 17:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467864; x=1692059864; 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=vlrggqgFHGa7WZpi/GFMOHR9AeIBfcIPdNuxKMfVmTw=; b=VEQcwqsZtg0g6FEyCn83OFZstIeKUcyqOf1E7fxbV4m/i7tCZW04MsZx3Ym0k/zK6k va/bNDZ9S16aqT5x1UgL16KbE8Fx7yhZa9BSUMHw427zbi9ZRwkZ/rfJw/MicNhmo12H LENAHN5sRb7Xk5TUfGS6re7Txb7Be7dTjpr3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467864; x=1692059864; 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=vlrggqgFHGa7WZpi/GFMOHR9AeIBfcIPdNuxKMfVmTw=; b=hDO19ie0tduLKsbX0AcTYq79zanMKILnvei1ybrgQT7YycUfVoEHqJ5vvuJgA5mFYl XUIHKWTjfzk2lQS3nl/9Iu740AIc4nWUxqSyx0Aj0xucPkUGCOstfFav3h/UteKnITgx 6VNe11IR4k/J+LdkurpK6kJXCanof5H7n2Oga8cMhbrJzC7hNCFGg70QdJz1/s+QLt+C mMlYX6/Fg+N1Ypkw5AJdXxbgaIZJg1W5Vq7FyWaAnzLxuYQZ98M5XGDlpjQxfhwB0vCk y7HMKX8Tp7Cik6TWPuXq222W5b/aAwOIRhwFfAtYnoiaPPqnvcMcgXC5naTFyKsxVEtS QN2g== X-Gm-Message-State: ABy/qLZTjOkkhnvn9TdMBTABF+p0GO8N7f9HpVLnSWP37KkHFXh9zZU4 ome38L89bEx9YX5SkJfdityMqscw1mipUyLh2/0= X-Google-Smtp-Source: APBJJlFBWruAjb9TgJX9Wz4VojTjMXibNWN+XTFrl64/JP3Sxf/JdU53++nF6PdofuerFgLNzyMWZQ== X-Received: by 2002:a92:d6c5:0:b0:345:cf9f:abbc with SMTP id z5-20020a92d6c5000000b00345cf9fabbcmr8668392ilp.7.1689467864648; Sat, 15 Jul 2023 17:37:44 -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:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 30/81] bulidman: Move more code to determine_series() Date: Sat, 15 Jul 2023 18:35:58 -0600 Message-ID: <20230716003718.231903-31-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 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.455.g037347b96a-goog