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 BA6E7C0015E for ; Sun, 16 Jul 2023 00:41:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C9D6986626; Sun, 16 Jul 2023 02:38:35 +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="SCCWeS43"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCC3B862B9; Sun, 16 Jul 2023 02:37:47 +0200 (CEST) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 2998F8631F for ; Sun, 16 Jul 2023 02:37:41 +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-xd2a.google.com with SMTP id ca18e2360f4ac-7836164a08aso162908539f.1 for ; Sat, 15 Jul 2023 17:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467859; x=1692059859; 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=5MQa3tJwcm8b9NOC+/sLXdjGat6WSEBysiLLVXpKQKQ=; b=SCCWeS43VQw+ZzbasvTV2fnBiAg7hZiFF5ZkpsOcFOqSVVeGOcTuM8WCgn+Q+0H0Li YIt4m20WeT28z1ov8zSPNHqKhRSzgl7OOep2vK8b/4f/MZsUP1dCTB71505A96xf7EGy x5n90GnzhVp7sqqrrwpBQ0v6emHbBN15j10DA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467859; x=1692059859; 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=5MQa3tJwcm8b9NOC+/sLXdjGat6WSEBysiLLVXpKQKQ=; b=G3WR1P5g1W262HLHBCRVfVZeOB4FfVAULB+htPa5S992Nt6aU1p+XHoxdRpGLSycFI esuuGOtzwRriHiu/ri853bSovG47YmsTdZkhPNMsezxLYL2uq8Nxm6b3Z8bRpaZHUXg2 KHPDbUjQetA0Xo6yzG4pgf2181w9NOkFf8pPFiZRl/oek9iEAmy2j8o4gTs2GfgtVv5V lxg+sVIMH5jPpmBrUD4E42cWwiaEqyu5lOg+DXvNwVWmOnsy+dy+v4zNjM8M38oc2FcQ dRitxNRiXRXphdfT+Zg22cCFLW9egSuqibFClZiGzvzkYy9KwAbSrgFJPKobmrOguSD3 Ji0w== X-Gm-Message-State: ABy/qLbwC0uNKHu3wq0AXalkTmx9dFz8TI18nKeiLbrpOF40I2TwGXOV kGjS4Fkrka7d9S0lYlZkAVe+PHgB7q4rJbtY2Yc= X-Google-Smtp-Source: APBJJlGYTUrkrYIJvSWUiZzWYZGiwyjqJ0GH7DrgAvyN2eKWp17E1WUzZuIwnAwyxu2vl97b6nn1SA== X-Received: by 2002:a92:b110:0:b0:346:5e80:bf67 with SMTP id t16-20020a92b110000000b003465e80bf67mr8515928ilh.21.1689467859782; Sat, 15 Jul 2023 17:37:39 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:39 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 23/81] buildman: Move series calculations into a separate function Date: Sat, 15 Jul 2023 18:35:51 -0600 Message-ID: <20230716003718.231903-24-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 Reduce the size of the do_buildman() function a little by moving the code that figures out the series into a separate function. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 95 +++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 2e4ba0b21785..d8fead93e730 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -147,6 +147,51 @@ def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): allow_missing = False return allow_missing + +def determine_series(count, has_range, branch, git_dir): + """Determine the series which is to be built, if any + + Args: + 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' + + Returns: + Series: Series to build, or None for none + + Read the metadata from the commits. First look at the upstream commit, + then the ones in the branch. We would like to do something like + upstream/master~..branch but that isn't possible if upstream/master is + a merge commit (it will list all the commits that form part of the + merge) + + Conflicting tags are not a problem for buildman, since it does not use + them. For example, Series-version is not useful for buildman. On the + other hand conflicting tags will cause an error. So allow later tags + to overwrite earlier ones by setting allow_overwrite=True + """ + if branch: + if count == -1: + if has_range: + range_expr = branch + else: + range_expr = gitutil.get_range_in_branch(git_dir, branch) + upstream_commit = gitutil.get_upstream(git_dir, branch) + series = patchstream.get_metadata_for_list(upstream_commit, + git_dir, 1, series=None, allow_overwrite=True) + + series = patchstream.get_metadata_for_list(range_expr, + git_dir, None, series, allow_overwrite=True) + else: + # Honour the count + series = patchstream.get_metadata_for_list(branch, + git_dir, count, series=None, allow_overwrite=True) + else: + series = None + return series + + def do_buildman(options, args, toolchains=None, make_func=None, brds=None, clean_dir=False, test_thread_exceptions=False): """The main control code for buildman @@ -174,7 +219,7 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, gitutil.setup() col = terminal.Color() - options.git_dir = os.path.join(options.git, '.git') + git_dir = os.path.join(options.git, '.git') no_toolchains = toolchains is None if no_toolchains: @@ -275,11 +320,11 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, count = 1 else: if has_range: - count, msg = gitutil.count_commits_in_range(options.git_dir, - options.branch) + count, msg = gitutil.count_commits_in_range(git_dir, + options.branch) else: - count, msg = gitutil.count_commits_in_branch(options.git_dir, - options.branch) + 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: @@ -301,39 +346,11 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, sys.exit(col.build(col.RED, '-w can only be used with a single commit')) - # Read the metadata from the commits. First look at the upstream commit, - # then the ones in the branch. We would like to do something like - # upstream/master~..branch but that isn't possible if upstream/master is - # a merge commit (it will list all the commits that form part of the - # merge) - # Conflicting tags are not a problem for buildman, since it does not use - # them. For example, Series-version is not useful for buildman. On the - # other hand conflicting tags will cause an error. So allow later tags - # to overwrite earlier ones by setting allow_overwrite=True - if options.branch: - if count == -1: - if has_range: - range_expr = options.branch - else: - range_expr = gitutil.get_range_in_branch(options.git_dir, - options.branch) - upstream_commit = gitutil.get_upstream(options.git_dir, - options.branch) - series = patchstream.get_metadata_for_list(upstream_commit, - options.git_dir, 1, series=None, allow_overwrite=True) - - series = patchstream.get_metadata_for_list(range_expr, - options.git_dir, None, series, allow_overwrite=True) - else: - # Honour the count - series = patchstream.get_metadata_for_list(options.branch, - options.git_dir, count, series=None, allow_overwrite=True) - else: - series = None - if not options.dry_run: - options.verbose = True - if not options.summary: - options.show_errors = True + series = determine_series(count, has_range, options.branch, git_dir) + if not series and not options.dry_run: + options.verbose = True + if not options.summary: + options.show_errors = True # By default we have one thread per CPU. But if there are not enough jobs # we can have fewer threads and use a high '-j' value for make. @@ -375,7 +392,7 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, else: adjust_cfg['LOCALVERSION_AUTO'] = '~' - builder = Builder(toolchains, output_dir, options.git_dir, + builder = Builder(toolchains, output_dir, git_dir, options.threads, options.jobs, gnu_make=gnu_make, checkout=True, show_unknown=options.show_unknown, step=options.step, no_subdirs=options.no_subdirs, full_path=options.full_path, -- 2.41.0.455.g037347b96a-goog