From patchwork Sat Jan 3 20:32:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1257 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=1767472424; bh=Y39LUJe2AGUqhruNLU7hkoCJFQOHQjeaBBFJHz3REf8=; 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=O9Yuf50PQGBnc885U1uO+eVgYvtOYF1jJcjrAc50Up3RieQ1X9EhjZOw4zq1U7ItJ EW+hr8/e0TsMbhGZX+layVBHueXoxBCTdYqd6TWuwf3dm200aUPCXcmtAOV+VEbdhE 46p7XZ5qDkzKt9t45RWyKJ5b6V59+tEbV0kmdBBUHcYLu1xuKTWjhFmHp/EizQwAwz CBLHVC+Blk87x+CVw6aQUImgOQe2IM5kn5Kf8qgZCmV6RJsDPoy7QBX2SR9Ka2yl8r qGdVAfbyT+cIAYUml8cBbWiaV904raFoScX51bpRRiQphao8AOk9tCHgOUKBPvK+4M RJv9qWg6MAs6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0F3AC690C1 for ; Sat, 3 Jan 2026 13:33:44 -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 ofSRFzDOqYZL for ; Sat, 3 Jan 2026 13:33:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472423; bh=Y39LUJe2AGUqhruNLU7hkoCJFQOHQjeaBBFJHz3REf8=; 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=DLcs2Q4PX5UCHKpuyKcijwpBck1rV0nfR1a3J72mmNl77UhUosLmg5pDi3XF87+Fv INrLtvR5wJwPCI1p5t4h+sTLv51m8chsCn/5vlodw81sT8kDqsK2XbFj1g1uA6b5q6 pGDGEHF/r0HJOe2o6qNyZR3JuqlY9UQvfKgffBW/OPa42bGvReQX9xJ1b8ZexnJHBS VI3FFKbovxqDZ5egjXgymAmOTZvmcNIYR8ULSqa6pjvakkQ6jYK8fs3bY+IxLBwcj6 qMh1jKT4TLr9+M/4cxiiWhRXA6XLbAQXfRBazSNN9WiTVHGJ6SCneP8gt8cnOh63mP w67C4s+k2C6pA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F01A0690B2 for ; Sat, 3 Jan 2026 13:33:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472422; bh=bouNbEsfPec5UGqa5Kp9F+w+8b2nBiIAuGfNTFDKVMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKvXRe4V93PTPseUu6No71Ruf5jF+hGypEIu79m/Jw2/SRU+Zt9brn7NiiljVWl3s tursAxDyCNnpWp2RtGB3yQs/sF8AQNblYbTWkIceOq9k7ZMFM6IdYAhgvw1KePDOr+ kuJLtXKyQHkX7rULkHEINlzX/eaVUSepk72tYLq1SzmK/LQoyRuCan2AKc0YCctd/b 1ZakaCq944jcaQeTVUWZZzDivRu57Yuuz/xooB781JRIhImX7zB1UoAwzsO95nxIVc 8/ZaGnNDxof4Bdad/2ogQMT9GN+XGQqozT4kmYxkrck4vAr5W7lhSz3/fRbtuRWnMI XLlEb9lIkXKqg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5861668F35; Sat, 3 Jan 2026 13:33:42 -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 Y6qburAnNoTk; Sat, 3 Jan 2026 13:33:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472418; bh=4ZiXucmnypHSh8dNpMKmY3paeaGD9N7Uq2qlVRzNPP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZTZTqlVy7EtnTzFo0ojUoaQrfog8nUcKLQjVcf1AIk9rm4VtvfsezYCSqKizBlyv nm2wOz+GFAzYMZk1tS61kJOBrjn7bdFJx8W/KTvlhNWI0AtHVhviCPLuSBf/KUQKm1 Asu+Xyw7ZlRHsqYEJAum8ILvfL5Nw+FmGwuE2RQZFD1y6ftNFnDsupz1Bo7u6QddQn fOwvZ2rmSFsIda0jGB8q5qVnJr0/ei+09W67YqXDdBCXJNCixEsdH3EbNf0ZLJW3Zs zhxIMhOjSoLMU710WG6zZZSuOlxH4DbYFbxWtD2jPVLjSeDpkJAcYcckWilr/RotXj WLDJnBsNqsgJQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DC4B068FC8; Sat, 3 Jan 2026 13:33:37 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:32:36 -0700 Message-ID: <20260103203243.3727493-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103203243.3727493-1-sjg@u-boot.org> References: <20260103203243.3727493-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OPTHGGSVINECGMW5WHDDBRR7WLHETBD3 X-Message-ID-Hash: OPTHGGSVINECGMW5WHDDBRR7WLHETBD3 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 10/12] buildman: Extract helper functions from output_is_new() 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 srcdir walk and output file scanning into module-level functions _check_srcdir_is_current() and _check_output_is_current() to reduce complexity. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/boards.py | 69 ++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 46e78b55809..0aea4bc826c 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -56,6 +56,50 @@ def try_remove(fname): raise +def _check_srcdir_is_current(ctime, srcdir): + """Check if any Kconfig or MAINTAINERS files are newer than ctime + + Args: + ctime (float): Reference time to compare against + srcdir (str): Directory containing Kconfig and MAINTAINERS files + + Returns: + bool: True if all files are older than ctime + """ + for (dirpath, _, filenames) in os.walk(srcdir): + for filename in filenames: + if (fnmatch.fnmatch(filename, '*~') or + not fnmatch.fnmatch(filename, 'Kconfig*') and + not filename == 'MAINTAINERS'): + continue + filepath = os.path.join(dirpath, filename) + if ctime < os.path.getctime(filepath): + return False + return True + + +def _check_output_is_current(output, config_dir): + """Check if output references any removed boards + + Args: + output (str): Path to the output file + config_dir (str): Directory containing defconfig files + + Returns: + bool: True if all referenced boards still exist + """ + with open(output, encoding="utf-8") as inf: + for line in inf: + if 'Options,' in line: + return False + if line[0] == '#' or line == '\n': + continue + defconfig = line.split()[6] + '_defconfig' + if not os.path.exists(os.path.join(config_dir, defconfig)): + return False + return True + + def output_is_new(output, config_dir, srcdir): """Check if the output file is up to date. @@ -75,7 +119,6 @@ def output_is_new(output, config_dir, srcdir): Raises: OSError: output file exists but could not be opened """ - # pylint: disable=too-many-branches try: ctime = os.path.getctime(output) except OSError as exception: @@ -92,27 +135,11 @@ def output_is_new(output, config_dir, srcdir): if ctime < os.path.getctime(filepath): return False - for (dirpath, _, filenames) in os.walk(srcdir): - for filename in filenames: - if (fnmatch.fnmatch(filename, '*~') or - not fnmatch.fnmatch(filename, 'Kconfig*') and - not filename == 'MAINTAINERS'): - continue - filepath = os.path.join(dirpath, filename) - if ctime < os.path.getctime(filepath): - return False + if not _check_srcdir_is_current(ctime, srcdir): + return False - # Detect a board that has been removed since the current board database - # was generated - with open(output, encoding="utf-8") as inf: - for line in inf: - if 'Options,' in line: - return False - if line[0] == '#' or line == '\n': - continue - defconfig = line.split()[6] + '_defconfig' - if not os.path.exists(os.path.join(config_dir, defconfig)): - return False + if not _check_output_is_current(output, config_dir): + return False return True