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 81B17C001DF for ; Sun, 16 Jul 2023 00:49:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E89038672D; Sun, 16 Jul 2023 02:40: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=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="CsvYj8ZW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F5978627C; Sun, 16 Jul 2023 02:38:40 +0200 (CEST) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 3515B865FA for ; Sun, 16 Jul 2023 02:38:16 +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-x133.google.com with SMTP id e9e14a558f8ab-3465bd756afso19180025ab.3 for ; Sat, 15 Jul 2023 17:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467895; x=1692059895; 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=Wx7skYqjpTg/E47ZN9hIuQUEwAURO/3wlWHccJBXpfc=; b=CsvYj8ZWR0L8/wONC0kluofbxa8WvWFkttHR0vw4RfVyR1YMmfL8Or63CDeYJbsKkA JeIFGhAOiIkFZjoyaLR5KG9XAvVLPVKD4WkbHDX8SJAIv5IcVP6Yx7uECyrJ0j/muwBC tdizYJo+kKuBuRogpIjg6ph7jBl6P/rInCViM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467895; x=1692059895; 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=Wx7skYqjpTg/E47ZN9hIuQUEwAURO/3wlWHccJBXpfc=; b=gXoHXoN3YzJ/gPcp4mP6Lt4GzwxLglsNfyShSKurRKAXzKqHsRViIwgcu6AbYXdOxt yzW/X2MIhRNQ199Jn3LqsUWidCvaCtE1yxxT1zJekj7rksuBZcpgnxiQLX4VkHiDpz06 VYMjPoUd9RcXK4/VYp3oyE2NzV6ERmKTA3VnEReBjgMX/6KVH3YKgRKYR9egIq1/m3XA J7JwNn9teNUpblZF/N6rbRLw5vphAtjBR9zO6Q+hjWTBvvW71mV0Llb2i7hglxe8yNhi DAHkxzLBPu52Y/wNNA6kn7NXStQgpfsGPCsiKpTd2AzLDxkHgX0txE5dBsfn9Cq1cfbh GP+g== X-Gm-Message-State: ABy/qLY4DE3WAMQH27Q45xQulq/A2cV2B20ZrQzr5PE6HCC4PdUU7wz7 4s47jl31cZrc/G4UsC120R7J449kw3Xv1c/v+uI= X-Google-Smtp-Source: APBJJlH1TO9nYHyPZUpcKox65edG0AxGp5cNdRIq12e3yczTV6h/AoK68kAnb1d75EU98OSGXZsZdg== X-Received: by 2002:a92:d385:0:b0:346:7a41:6c62 with SMTP id o5-20020a92d385000000b003467a416c62mr8050899ilo.15.1689467894679; Sat, 15 Jul 2023 17:38:14 -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.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:38:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 73/81] buildman: Create a function to handle config and build Date: Sat, 15 Jul 2023 18:36:41 -0600 Message-ID: <20230716003718.231903-74-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 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.455.g037347b96a-goog