From patchwork Tue Jan 6 22:03:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1317 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=1767737125; bh=sbAfajm7kgKScdymp2dyIiNBiqXMWWbJxMOza0LrYy0=; 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=cBlqAg8UVy0DbMSlRuC/RdDBAFqA80OOBoyu5c/jpclHzi8uAugyfr5pEpSc6s30v JGxatzjUzFFxAvnLYKOQjY79ksNF1CcwZMNfJ8MnokReqoKFicdOyWIac9VdCegJFD /psUEW2dVt8Xkks7SBRxB4+gVhbCaPRZWIWqJIBWKKbsrKSYdc5FduUXa3in/VGHzS bo3JAFvEKtFkFnwzxvjcY5QY0QtMOvYcNwfro0btPlhH65yHnUiLhpIuEc55xu8oNf N49W1yKQBwvyiH3Er2DQexcSrLOcJ6YXkFFQAeKKDz9up0ILic/gJSaIkWmtNgHO72 TAlhpfZG3Q5NA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F3B935FF82 for ; Tue, 6 Jan 2026 15:05:25 -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 RaLD_X4n5QgQ for ; Tue, 6 Jan 2026 15:05:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737125; bh=sbAfajm7kgKScdymp2dyIiNBiqXMWWbJxMOza0LrYy0=; 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=cBlqAg8UVy0DbMSlRuC/RdDBAFqA80OOBoyu5c/jpclHzi8uAugyfr5pEpSc6s30v JGxatzjUzFFxAvnLYKOQjY79ksNF1CcwZMNfJ8MnokReqoKFicdOyWIac9VdCegJFD /psUEW2dVt8Xkks7SBRxB4+gVhbCaPRZWIWqJIBWKKbsrKSYdc5FduUXa3in/VGHzS bo3JAFvEKtFkFnwzxvjcY5QY0QtMOvYcNwfro0btPlhH65yHnUiLhpIuEc55xu8oNf N49W1yKQBwvyiH3Er2DQexcSrLOcJ6YXkFFQAeKKDz9up0ILic/gJSaIkWmtNgHO72 TAlhpfZG3Q5NA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E424569146 for ; Tue, 6 Jan 2026 15:05:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737124; bh=R8JY9L72dZ7yFnq+FWBqW1+L4LMflFtDgFei4uL9Q/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s/+g824JEkExmMiANlqMUDl850qw2Ve6iVrbY6cW3v01A4jL98fnRxtbvvgrWhQsK f+lqsEPobkmDC1o738zjuP8ZomymsfR2jqQbKx9rt83QrONj81hU4NSxKo5nXcBJ3E vdA7BosbMEOSZhfCxllfwPLOaKcWZJ1ZuIWrZCms0iuhIPbd7Cu4yf+aD7CJKbh/91 1HPMOqU8kcDczp/Nitai9Jckny5y877wfYutNOm5fZ9E9gHyrlp/WqJpD4gU8nTMsL wQMaZ2EpgLPYbbMYPOQ+o9wRwyANdFo78JATBHctmKXEcd8fbzopvi6MnU6BlH29Bh 7mCBDNZXPHM8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 143E95FF82; Tue, 6 Jan 2026 15:05:24 -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 NoWJy0bugRgV; Tue, 6 Jan 2026 15:05:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767737119; bh=EN/Pg1LLb+7yIqcmGoytXWjTQTvkddb19MBOczz0Ncc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/snhKLT9kbL8oxH+m6dJHQ196soxwcYpn8qvdKiLh95qszUdJm7We+JkOvdviljc Me+h5vSIc1LuSiRrs8VxtNaOoCS5WbdNDPwSVvKXwfTcSFTxiJ5a8XJ3Mtd2i1H/Ts 3bBSLLYHEYD8di472YtWSE29zcBuLhLt6LRianb2CsCtCxudp0OovZaFKOhdfpNS4a fICxs3J7g//dGyXb1FtY2a1MWmcYkhUZ6dENiyzfe88Yab4M5kzXwpzu2PH9QAJllj ZK3s5Gd7Qbt6xga8nMl10+2PvalrPF2XsrL6b7K6IsMnyItLMrPWYTeTqBH7Z10o9c rsHROO54+npmQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 89726690CB; Tue, 6 Jan 2026 15:05:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 6 Jan 2026 15:03:32 -0700 Message-ID: <20260106220403.2915630-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260106220403.2915630-1-sjg@u-boot.org> References: <20260106220403.2915630-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EPLY6PLRUSE7RUSNJOLMTI7TJB6735BJ X-Message-ID-Hash: EPLY6PLRUSE7RUSNJOLMTI7TJB6735BJ 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/29] buildman: Refactor get_build_outcome() in builder.py 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 Move the 'with open' block into a separate _read_done_file() function to improve readability and reduce local variables in get_build_outcome(). Co-developed-by: Claude Signed-off-by: Simon Glass --- tools/buildman/builder.py | 97 +++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 39 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 4526c476a97..38b076138b0 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -858,6 +858,62 @@ class Builder: pass return environment + def _read_done_file(self, commit_upto, target, done_file, sizes_file): + """Read the done file and collect build results + + Args: + commit_upto (int): Commit number to check (0..n-1) + target (str): Target board to check + done_file (str): Filename of done file + sizes_file (str): Filename of sizes file + + Returns: + tuple: (rc, err_lines, sizes) where: + rc: OUTCOME_OK, OUTCOME_WARNING or OUTCOME_ERROR + err_lines: list of error lines + sizes: dict of sizes + """ + with open(done_file, 'r', encoding='utf-8') as fd: + try: + return_code = int(fd.readline()) + except ValueError: + # The file may be empty due to running out of disk space. + # Try a rebuild + return_code = 1 + err_lines = [] + err_file = self.get_err_file(commit_upto, target) + if os.path.exists(err_file): + with open(err_file, 'r', encoding='utf-8') as fd: + err_lines = self.filter_errors(fd.readlines()) + + # Decide whether the build was ok, failed or created warnings + if return_code: + rc = OUTCOME_ERROR + elif err_lines: + rc = OUTCOME_WARNING + else: + rc = OUTCOME_OK + + # Convert size information to our simple format + sizes = {} + if os.path.exists(sizes_file): + with open(sizes_file, 'r', encoding='utf-8') as fd: + for line in fd.readlines(): + values = line.split() + rodata = 0 + if len(values) > 6: + rodata = int(values[6], 16) + size_dict = { + 'all' : int(values[0]) + int(values[1]) + + int(values[2]), + 'text' : int(values[0]) - rodata, + 'data' : int(values[1]), + 'bss' : int(values[2]), + 'rodata' : rodata, + } + sizes[values[5]] = size_dict + return rc, err_lines, sizes + def get_build_outcome(self, commit_upto, target, read_func_sizes, read_config, read_environment): """Work out the outcome of a build. @@ -874,49 +930,12 @@ class Builder: """ done_file = self.get_done_file(commit_upto, target) sizes_file = self.get_sizes_file(commit_upto, target) - sizes = {} func_sizes = {} config = {} environment = {} if os.path.exists(done_file): - with open(done_file, 'r', encoding='utf-8') as fd: - try: - return_code = int(fd.readline()) - except ValueError: - # The file may be empty due to running out of disk space. - # Try a rebuild - return_code = 1 - err_lines = [] - err_file = self.get_err_file(commit_upto, target) - if os.path.exists(err_file): - with open(err_file, 'r', encoding='utf-8') as fd: - err_lines = self.filter_errors(fd.readlines()) - - # Decide whether the build was ok, failed or created warnings - if return_code: - rc = OUTCOME_ERROR - elif err_lines: - rc = OUTCOME_WARNING - else: - rc = OUTCOME_OK - - # Convert size information to our simple format - if os.path.exists(sizes_file): - with open(sizes_file, 'r', encoding='utf-8') as fd: - for line in fd.readlines(): - values = line.split() - rodata = 0 - if len(values) > 6: - rodata = int(values[6], 16) - size_dict = { - 'all' : int(values[0]) + int(values[1]) + - int(values[2]), - 'text' : int(values[0]) - rodata, - 'data' : int(values[1]), - 'bss' : int(values[2]), - 'rodata' : rodata, - } - sizes[values[5]] = size_dict + rc, err_lines, sizes = self._read_done_file( + commit_upto, target, done_file, sizes_file) if read_func_sizes: pattern = self.get_func_sizes_file(commit_upto, target, '*')