From patchwork Mon Jan 5 18:30:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1276 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637877; bh=6ah2k7nA7xtVmbINuyBh+rLp5LgDyrM04KmRauFOp+s=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XG7cmdbTdeSAyf8deWt7bRwwfaVF0YOEwEE9zQVIEaOhRZRaB1LuKyMoUlGgQ9val 23StY9oLkSKQW5PP3xGZyKg5Jsa3Ames/0ZAO4W0zBPy/s/CgOLGQg0nC/uCobA+ui vKEuZ61C9gEtYkU3b6N4mOqueD/Mp2aZKX9Ka+9JovnRKqsOccEfHuw5mNqmPEdJl7 uAhdUbsb52fmF7Aj9Jj0DBJh4mw5d2p0rLOnOYtPG20ZclbL1HCUlWT2OsNGLXrjDy 2ozJrSaFf2nFyA+Eh4Q+7x9yNCXjHRTh2d1Iv83M0EpERKNfh9bx6yz2nc0xR+d+wE EjhOK+GPhjuDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E88169116 for ; Mon, 5 Jan 2026 11:31:17 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id mLLoC7lOmDLY for ; Mon, 5 Jan 2026 11:31:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637877; bh=6ah2k7nA7xtVmbINuyBh+rLp5LgDyrM04KmRauFOp+s=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XG7cmdbTdeSAyf8deWt7bRwwfaVF0YOEwEE9zQVIEaOhRZRaB1LuKyMoUlGgQ9val 23StY9oLkSKQW5PP3xGZyKg5Jsa3Ames/0ZAO4W0zBPy/s/CgOLGQg0nC/uCobA+ui vKEuZ61C9gEtYkU3b6N4mOqueD/Mp2aZKX9Ka+9JovnRKqsOccEfHuw5mNqmPEdJl7 uAhdUbsb52fmF7Aj9Jj0DBJh4mw5d2p0rLOnOYtPG20ZclbL1HCUlWT2OsNGLXrjDy 2ozJrSaFf2nFyA+Eh4Q+7x9yNCXjHRTh2d1Iv83M0EpERKNfh9bx6yz2nc0xR+d+wE EjhOK+GPhjuDg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 13DF069103 for ; Mon, 5 Jan 2026 11:31:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637875; bh=p/uFdMHiZST5CyulHlNjtBn2n2aXSHplf20JQhIdAYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jg7qtgVffQ/hseExHNG3/mNLULjIM4ihZ0n6JjDNoifrYzKSt6740rF/jQpg88A2H tjoy/mDnFNxaE1jl7Zzs7MXMPQHgo3I207tVXURQueYCUk/yrGnTaqm20VDcV7DckL H079ZpnB8HkXC9FofRerfmrCn7rVCdPwwieiRV1D2qgXCJ0b09aZ4dEg6W1pfpCiwG NoIPZdE+ZUnAfWhvUepxaRyG6h0FF2B6iR5g7j9XbI8vw95HKJW9Cf9Ue+pLwQyYN1 KVv18BJJL4cC2yuSdy4VQyn2gDwErztJfvtxQ24QPeRUpb4eeyPKQIk+NSn+5GgRxq qbAkdwKYqnF5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 397CD69103; Mon, 5 Jan 2026 11:31:15 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id uk9KQreB6EJI; Mon, 5 Jan 2026 11:31:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637871; bh=BwAGae10sGiR8uvhF5IVHYKXQ2je2hAip4X7TI3EWPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eOJsmJXAvOlXDV8lCdjEZ/SAxfQvBkan9I06GTQMR38GYURucQJewcCJUCuaAoS7f qIyb9MnZVmraCb8Es4PnEl2X0lhEm3D9BQKWJtvyvsn6VZr9Zi2Za6ZTV91+RsFgIG 6sAXDaB5DNP4KUCtHBVKVfjbkcb5CP8Fu8/sCnsPHN9b8kdpcSiqK94DVxtVTb6ali mLx+RRZ/pyufJ5DxvaMlEnJF2WhSLeLMh1RantbQIAegwcC6nvgRNxu8spqOSs/64o goKRONdSSjI6VtYjGJtULv32GSJadL3cxYTIvA0zrfglYL+b+UZNRJLtGRiz9Yt7ei earMfsu8/z9Ng== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 02CA969045; Mon, 5 Jan 2026 11:31:10 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 5 Jan 2026 11:30:21 -0700 Message-ID: <20260105183030.1487468-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260105183030.1487468-1-sjg@u-boot.org> References: <20260105183030.1487468-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4LLWOAEIUBYCFP2GZIFJSEROJTHMGPAN X-Message-ID-Hash: 4LLWOAEIUBYCFP2GZIFJSEROJTHMGPAN X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/11] buildman: Add BuildSetup named tuple for _setup_build() return value List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Introduce a BuildSetup named tuple to hold the return value from _setup_build(). This groups the build environment setup values: - env: Environment variables for the build - args: Arguments to pass to make - config_args: Arguments for configuration - cwd: Current working directory for the build - src_dir: Source directory path Update _reconfig_if_needed() and _build_and_get_result() to accept the setup tuple instead of individual parameters, simplifying their signatures and the calls from _config_and_build() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/builderthread.py | 67 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 67a0b486b47..e0164b30a4e 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -38,6 +38,17 @@ from u_boot_pylib import tools RunRequest = namedtuple('RunRequest', ['brd', 'work_dir', 'work_in_output', 'adjust_cfg', 'fragments']) +# Named tuple for _setup_build() return value +# +# Members: +# env (dict): Environment variables for the build +# args (list of str): Arguments to pass to make +# config_args (list of str): Arguments for configuration +# cwd (str): Current working directory for the build +# src_dir (str): Source directory path +BuildSetup = namedtuple('BuildSetup', ['env', 'args', 'config_args', 'cwd', + 'src_dir']) + RETURN_CODE_RETRY = -1 BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl'] @@ -454,12 +465,7 @@ class BuilderThread(threading.Thread): out_rel_dir (str): Output directory relative to the current dir Returns: - tuple: - env (dict): Environment variables for the build - args (list of str): Arguments to pass to make - config_args (list of str): Arguments for configuration - cwd (str): Current working directory for the build - src_dir (str): Source directory path + BuildSetup: Build setup (see BuildSetup for details) """ env = self.builder.make_environment(self.toolchain) if out_dir and not os.path.exists(out_dir): @@ -479,20 +485,16 @@ class BuilderThread(threading.Thread): _remove_old_outputs(out_dir) - return env, args, config_args, cwd, src_dir + return BuildSetup(env, args, config_args, cwd, src_dir) - def _reconfig_if_needed(self, req, commit, cwd, args, env, config_args, - config_out, cmd_list, out_dir, do_config, mrproper, - result): + def _reconfig_if_needed(self, req, setup, commit, config_out, cmd_list, + out_dir, do_config, mrproper, result): """Reconfigure the build if needed Args: req (RunRequest): Run request (see RunRequest for details) + setup (BuildSetup): Build setup (see BuildSetup for details) commit (Commit): Commit being built - cwd (str): Current working directory - args (list of str): Arguments to pass to make - env (dict): Environment strings - config_args (list of str): Arguments for configuration config_out (StringIO): Buffer for configuration output cmd_list (list of str): List to add the commands to, for logging out_dir (str): Output directory for the build @@ -509,28 +511,24 @@ class BuilderThread(threading.Thread): cfg_file = os.path.join(out_dir or '', '.config') if do_config or req.adjust_cfg: result = self._reconfigure( - commit, req.brd, cwd, args, env, config_args, config_out, - cmd_list, mrproper) + commit, req.brd, setup.cwd, setup.args, setup.env, + setup.config_args, config_out, cmd_list, mrproper) do_config = False # No need to configure next time if req.adjust_cfg: cfgutil.adjust_cfg_file(cfg_file, req.adjust_cfg) return result, do_config, cfg_file - def _build_and_get_result(self, req, commit, cwd, args, env, cmd_list, - config_out, cfg_file, src_dir, config_only, - result): + def _build_and_get_result(self, req, setup, commit, cmd_list, config_out, + cfg_file, config_only, result): """Perform the build and finalise the result Args: req (RunRequest): Run request (see RunRequest for details) + setup (BuildSetup): Build setup (see BuildSetup for details) commit (Commit): Commit being built - cwd (str): Current working directory - args (list of str): Arguments to pass to make - env (dict): Environment strings cmd_list (list of str): List to add the commands to, for logging config_out (StringIO): Buffer for configuration output cfg_file (str): Path to the .config file - src_dir (str): Source directory path config_only (bool): Only configure the source, do not build it result (CommandResult): Previous result @@ -539,19 +537,19 @@ class BuilderThread(threading.Thread): """ if result.return_code == 0: if req.adjust_cfg: - oldc_args = list(args) + ['oldconfig'] - oldc_result = self.make(commit, req.brd, 'oldconfig', cwd, - *oldc_args, env=env) + oldc_args = list(setup.args) + ['oldconfig'] + oldc_result = self.make(commit, req.brd, 'oldconfig', setup.cwd, + *oldc_args, env=setup.env) if oldc_result.return_code: return oldc_result - result = self._build(commit, req.brd, cwd, args, env, cmd_list, - config_only) + result = self._build(commit, req.brd, setup.cwd, setup.args, + setup.env, cmd_list, config_only) if req.adjust_cfg: errs = cfgutil.check_cfg_file(cfg_file, req.adjust_cfg) if errs: result.stderr += errs result.return_code = 1 - result.stderr = result.stderr.replace(src_dir + '/', '') + result.stderr = result.stderr.replace(setup.src_dir + '/', '') if self.builder.verbose_build: result.stdout = config_out.getvalue() + result.stdout result.cmd_list = cmd_list @@ -579,19 +577,18 @@ class BuilderThread(threading.Thread): do_config (bool): indicates whether 'make config' is needed on the next incremental build """ - env, args, config_args, cwd, src_dir = self._setup_build( - req, commit_upto, out_dir, out_rel_dir) + setup = self._setup_build(req, commit_upto, out_dir, out_rel_dir) config_out = io.StringIO() cmd_list = [] result, do_config, cfg_file = self._reconfig_if_needed( - req, commit, cwd, args, env, config_args, config_out, cmd_list, - out_dir, do_config, mrproper, result) + req, setup, commit, config_out, cmd_list, out_dir, do_config, + mrproper, result) result = self._build_and_get_result( - req, commit, cwd, args, env, cmd_list, config_out, cfg_file, - src_dir, config_only, result) + req, setup, commit, cmd_list, config_out, cfg_file, config_only, + result) return result, do_config