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 469EFC0015E for ; Thu, 20 Jul 2023 00:03:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE45886908; Thu, 20 Jul 2023 01:53:02 +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="j+4S9DiQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C393867FC; Thu, 20 Jul 2023 01:51:03 +0200 (CEST) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 B92D5867DF for ; Thu, 20 Jul 2023 01:50: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=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-345a8a78bcfso1571935ab.2 for ; Wed, 19 Jul 2023 16:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810655; x=1690415455; 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=IQJ7cOK37+h7kqKYZvGMSMGie1rycuKkwmFkKJWJJG0=; b=j+4S9DiQiksh5v10aZ3lrwr7oDQjk2buXoQhT8y3EKEWgf/MVCUPfGO8zOOruSxMO+ fRQTJU8xaLoWpXrlYyjsvBYGymdakCc0dCBlNW5ztHR+kIXUZlf1j/aqdbhwJUg+LBqf nk8eeMzUAmP0eTqMxxvMkChFGtKmjFN5pBxpc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810655; x=1690415455; 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=IQJ7cOK37+h7kqKYZvGMSMGie1rycuKkwmFkKJWJJG0=; b=iQyK+ZRpJ1zUEzpbap2ebX7ejGLsmLh9k1X8VnomWfv+MteGkQ9JtCNMHANSsJeFsC FlbPg27Y5bLwtb0saemcO7VuqZ/2Rci+IMqdE6ytfpyEYlVK0w1gCQ07Jzms6trWgaHV XaGr4NnVzwBVf4oSyX1aAX/LODZ2bMVC8DLUmCfMCNVfg8V2Yk6qviKpo3miegjNyqEK tN7uYk3A3M3kPulLRDHqSH3y2FcB9jUdu/iWqWNDCHcap5XU0pGM9Ufegl/AW/mWwksB B7vU7THud8zYJLH0gHYaDoKCm2Lnn2+vxCQldRvjQx578dSpvbOPIwcLK/gAk9HYo/Sb CymQ== X-Gm-Message-State: ABy/qLZDsRS/15ydEelAQK69h/+80JVc+TZvxUo1YU1d/To408QzRnzc /C1+qc44GSHtXdP+honQyVJjLUbwoFAwK9QMzzY= X-Google-Smtp-Source: APBJJlFIOIjV3pRKzoc6wvweCg/0gfj/yQkccxxevMz6Uo1XODHR3Fz895AiLIlfH2Zy3pTNIfRecQ== X-Received: by 2002:a05:6e02:1bae:b0:348:1a1d:79a5 with SMTP id n14-20020a056e021bae00b003481a1d79a5mr8236634ili.15.1689810655191; Wed, 19 Jul 2023 16:50:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 75/83] buildman: Create a function to handle config and build Date: Wed, 19 Jul 2023 17:49:23 -0600 Message-ID: <20230719234953.796101-76-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 this code into a _config_and_build() function, so reduce the size of run_commit(). Signed-off-by: Simon Glass --- (no changes since v1) tools/buildman/builderthread.py | 97 +++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 0c73b8646b1c..aa4a9d9919c6 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -345,6 +345,64 @@ class BuilderThread(threading.Thread): commit = 'current' return commit + def _config_and_build(self, commit_upto, brd, work_dir, do_config, + config_only, adjust_cfg, commit, out_dir, out_rel_dir, + result): + """Do the build, configuring first if necessary + + Args: + commit_upto (int): Commit number to build (0...n-1) + brd (Board): Board to create arguments for + work_dir (str): Directory to which the source will be checked out + do_config (bool): True to run a make _defconfig on the source + config_only (bool): Only configure the source, do not build it + adjust_cfg (list of str): See the cfgutil module and run_commit() + commit (Commit): Commit only being built + out_dir (str): Output directory for the build + out_rel_dir (str): Output directory relatie to the current dir + result (CommandResult): Previous result + + Returns: + tuple: + result (CommandResult): Result of the build + do_config (bool): indicates whether 'make config' is needed on + the next incremental build + """ + # Set up the environment and command line + env = self.toolchain.MakeEnvironment(self.builder.full_path) + mkdir(out_dir) + + args, cwd, src_dir = self._build_args(brd, out_dir, out_rel_dir, + work_dir, commit_upto) + config_args = [f'{brd.target}_defconfig'] + config_out = io.StringIO() + + _remove_old_outputs(out_dir) + + # If we need to reconfigure, do that now + cfg_file = os.path.join(out_dir, '.config') + cmd_list = [] + if do_config or adjust_cfg: + result = self._reconfigure( + commit, brd, cwd, args, env, config_args, config_out, cmd_list) + do_config = False # No need to configure next time + if adjust_cfg: + cfgutil.adjust_cfg_file(cfg_file, adjust_cfg) + + # Now do the build, if everything looks OK + if result.return_code == 0: + result = self._build(commit, brd, cwd, args, env, cmd_list, + config_only) + if adjust_cfg: + errs = cfgutil.check_cfg_file(cfg_file, adjust_cfg) + if errs: + result.stderr += errs + result.return_code = 1 + result.stderr = result.stderr.replace(src_dir + '/', '') + if self.builder.verbose_build: + result.stdout = config_out.getvalue() + result.stdout + result.cmd_list = cmd_list + return result, do_config def run_commit(self, commit_upto, brd, work_dir, do_config, config_only, force_build, force_build_failures, work_in_output, @@ -402,42 +460,9 @@ class BuilderThread(threading.Thread): if self.toolchain: commit = self._checkout(commit_upto, work_dir) - - # Set up the environment and command line - env = self.toolchain.MakeEnvironment(self.builder.full_path) - mkdir(out_dir) - - args, cwd, src_dir = self._build_args(brd, out_dir, out_rel_dir, - work_dir, commit_upto) - config_args = [f'{brd.target}_defconfig'] - config_out = io.StringIO() - - _remove_old_outputs(out_dir) - - # If we need to reconfigure, do that now - cfg_file = os.path.join(out_dir, '.config') - cmd_list = [] - if do_config or adjust_cfg: - result = self._reconfigure( - commit, brd, cwd, args, env, config_args, config_out, - cmd_list) - do_config = False # No need to configure next time - if adjust_cfg: - cfgutil.adjust_cfg_file(cfg_file, adjust_cfg) - - # Now do the build, if everything looks OK - if result.return_code == 0: - result = self._build(commit, brd, cwd, args, env, cmd_list, - config_only) - if adjust_cfg: - errs = cfgutil.check_cfg_file(cfg_file, adjust_cfg) - if errs: - result.stderr += errs - result.return_code = 1 - result.stderr = result.stderr.replace(src_dir + '/', '') - if self.builder.verbose_build: - result.stdout = config_out.getvalue() + result.stdout - result.cmd_list = cmd_list + result, do_config = self._config_and_build( + commit_upto, brd, work_dir, do_config, config_only, + adjust_cfg, commit, out_dir, out_rel_dir, result) else: result.return_code = 1 result.stderr = f'No tool chain for {brd.arch}\n' -- 2.41.0.487.g6d72f3e995-goog