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 AF3B7C001DF for ; Sun, 16 Jul 2023 00:43:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 61F61863E8; Sun, 16 Jul 2023 02:39:23 +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="SK4U57VW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9ED79862B9; Sun, 16 Jul 2023 02:38:00 +0200 (CEST) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 C47368637D for ; Sun, 16 Jul 2023 02:37:50 +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-x12b.google.com with SMTP id e9e14a558f8ab-3457a3ada84so16171225ab.1 for ; Sat, 15 Jul 2023 17:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467869; x=1692059869; 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=HwXzm84L7gX7isfzrjtBm1DF03R4dxGM7lpBQciBBJk=; b=SK4U57VW5Pu7H+v1ew0WMYaYGsInmV9/tgejYt6usdVBqoGmOjW8dlvhNfs7kQL7An QDHL7tGPKlX6X3YEbZrOB0nhi9JlfVAtmh7jNQkyORJ0QEUZVRS+TvJJmCZiu8vujkyk r6Uv4UlVPB+Kw4pxWBrfFnZitYpvXPtWWp+vc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467869; x=1692059869; 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=HwXzm84L7gX7isfzrjtBm1DF03R4dxGM7lpBQciBBJk=; b=ZOt1aCy6dtRjngxTNKQ8XPUZ5Mj5pdf0LKi5uKCigt1KqPQXDkO+UJ0umqk56Dzi5o 52KmWQ5R+Hdo+BTp5uPCs/g1bFKC5XBL6/Iv6z1cdZW8z2OhMET2WZa0hdo49nmjswXS BPu6L+g8vf3fgJlvfJo+s9FCEAdfrgp5f+RMiqWOzmZDbng3vMfeyuE9fCYLCBZVpcqZ Vy6+YElYdrZXDJm8AuE39DBW+8MabVlJTYPvZ/NYCZhYVJAH+ajW/OBCJ4+T2yk2j4DY Bl8welyEjpC4pn69LkhlvSF+i4MTAuKw6zDDLiGyhAu4bfSp5QT4xF0ttgAnCNuPLJnC oJ9w== X-Gm-Message-State: ABy/qLY2vhERDHv8OnAHxTkhtCiFfTIOgCTE3kqiIlr1k+WrZcnBFlJ/ FHvWiFrys64G/J5vAgbk1iYmGIf+fDTWUYHcUuw= X-Google-Smtp-Source: APBJJlGqiMKXI0oYt2mKjtyJMTe7kyUQZikkSmlD2kMDU5TCGxdlHht73BT1XDHXvJtYnAYpytWoZQ== X-Received: by 2002:a92:c94b:0:b0:346:b5d:c0ee with SMTP id i11-20020a92c94b000000b003460b5dc0eemr7402702ilq.0.1689467869266; Sat, 15 Jul 2023 17:37:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 37/81] buildman: Build option-adjusting into a function Date: Sat, 15 Jul 2023 18:36:05 -0600 Message-ID: <20230716003718.231903-38-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 Create a separate function to adjust options. Also move show_actions() up as far as we can in the function. Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/control.py | 53 ++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 5350fcc14a09..85c0c7b3a40d 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -389,6 +389,32 @@ def determine_boards(brds, args, col, opt_boards, exclude_list): return selected, why_selected, board_warnings +def adjust_options(options, series, selected): + """Adjust options according to various constraints + + Updates verbose, show_errors, threads, jobs and step + + Args: + options (Options): Options object to adjust + series (Series): Series being built / summarised + selected (list of Board): List of Board objects that are marked + """ + 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. + if options.threads is None: + options.threads = min(multiprocessing.cpu_count(), len(selected)) + if not options.jobs: + options.jobs = max(1, (multiprocessing.cpu_count() + + len(selected) - 1) // len(selected)) + + if not options.step: + options.step = len(series.commits) - 1 + 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 @@ -453,21 +479,15 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, 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: - 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. - if options.threads is None: - options.threads = min(multiprocessing.cpu_count(), len(selected)) - if not options.jobs: - options.jobs = max(1, (multiprocessing.cpu_count() + - len(selected) - 1) // len(selected)) + adjust_options(options, series, selected) - if not options.step: - options.step = len(series.commits) - 1 + # For a dry run, just show our actions as a sanity check + if options.dry_run: + show_actions(series, why_selected, selected, output_dir, board_warnings, + options.step, options.threads, options.jobs, + options.verbose) + return 0 gnu_make = command.output(os.path.join(options.git, 'scripts/show-gnu-make'), raise_on_error=False).rstrip() @@ -480,13 +500,6 @@ def do_buildman(options, args, toolchains=None, make_func=None, brds=None, # Create a new builder with the selected options. - # For a dry run, just show our actions as a sanity check - if options.dry_run: - show_actions(series, why_selected, selected, output_dir, board_warnings, - options.step, options.threads, options.jobs, - options.verbose) - return 0 - adjust_cfg = cfgutil.convert_list_to_dict(options.adjust_cfg) # Drop LOCALVERSION_AUTO since it changes the version string on every commit -- 2.41.0.455.g037347b96a-goog