From patchwork Sat Jan 3 20:32:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1255 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=1767472414; bh=e1eyuy3hJpFBdqtLQV0UbPjDt73Av9lvcyMlqX/Gzpk=; 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=pwNYIuthMrBWkGjZqcapUa0tWr04cm74F995HfL61IyDmZo/AL0ckKLHwMj1tY4zG 1w/MudTVfqHpFnTWd/cskdRQk33+ksPEPm27VrlBx4N1IuPsjnN/bGbQqG4pRaR0Y0 TEcIaCzDTF99zY/PKVqK4V6XgrVai772OhTn4kfW2O8tOwz36a4n5IrYuaG+Zhgg6l zmH2cstINDMW/BmMBNGva5rSRugqn2RM/rig9tDAZ8MEl0UFaIrFg9H2Yp1aZhb4KQ 1rpiihASVp95g4raCizqfGRqHbuYggCMM/QBYTb7TDXoYGpbMJSJiX9QNx+bVU/f6P 65SNWENHdLO9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB4C3690C0 for ; Sat, 3 Jan 2026 13:33:34 -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 TfZ9IUlvSI9e for ; Sat, 3 Jan 2026 13:33:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472414; bh=e1eyuy3hJpFBdqtLQV0UbPjDt73Av9lvcyMlqX/Gzpk=; 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=pwNYIuthMrBWkGjZqcapUa0tWr04cm74F995HfL61IyDmZo/AL0ckKLHwMj1tY4zG 1w/MudTVfqHpFnTWd/cskdRQk33+ksPEPm27VrlBx4N1IuPsjnN/bGbQqG4pRaR0Y0 TEcIaCzDTF99zY/PKVqK4V6XgrVai772OhTn4kfW2O8tOwz36a4n5IrYuaG+Zhgg6l zmH2cstINDMW/BmMBNGva5rSRugqn2RM/rig9tDAZ8MEl0UFaIrFg9H2Yp1aZhb4KQ 1rpiihASVp95g4raCizqfGRqHbuYggCMM/QBYTb7TDXoYGpbMJSJiX9QNx+bVU/f6P 65SNWENHdLO9g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91DC5690BD for ; Sat, 3 Jan 2026 13:33:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472412; bh=0ryqwUbyvrnBPErEu6cDeTR2bdjdRyLrc1xCaceL6rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QT3FGMqYewuO6G8ZQ11WmCmtdKtFtJ60TCQoHmmA26aM05UHdb7xcONscddT+w/3g q7a4M2CphtslHM9Cf+cRlP1bg9F5ec8FKR4lHNa64+cM2oKMDk/yIe5jslY1puVeU3 YGroPaDaw8EeZU8h8SkEnXAPm/6tQftDEB5IXoQLHJCSfvdEuXSTYJZ3B5lE+Ts45O NBRKTqOCcpWAAwyb61V7dKmor45kwW//u1SymUOxxgKXXVQAT9otFgfnYYG8BHt2qc 2x8sCyiJqEICvt6t/lcq+neEiPMnhqf7xlaFglrEHpf8bBLE9eTJPQPaFGJj3wULfF cU21khz7xc6fw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B88D668F35; Sat, 3 Jan 2026 13:33:32 -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 Oh9GNuKQj27e; Sat, 3 Jan 2026 13:33:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767472408; bh=1ch7ehAOrTLH9hImp+PuzAfewiT/ygRmDpdqLihcL/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vWnQhfM7b2A6nDZoNT0oe9AYhLbtIVAMOHJVaLrq8CslyTQ4bNguWrDx50kP3gIaO lYMFYvvlAI3tBeckguAJ6QfM3K/ZuUbFmyZnUt8UQeLoC8v36aBxdcQuJ4X1bFR4pT et0a4IKvtv1pm2vuBHo0kx1z3fs9Fn1jf9mZjqemrLL7mk/fHthmd3MBn4XVxeTk9H c/YB2JYQkFu/bRqLglrcO42i0M/NzRuZ8tXGjdw5tCEoRfYlvlNYy8OcUeeAdiwU41 2mjNlcWP5KomazjsjLZ9IFnzbNXCCoRof4aSFc4EJK7lDzNNYt61P/P+LcwuqwXTl+ PHUQ7tjFAtDmA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4363C68FC8; Sat, 3 Jan 2026 13:33:28 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 3 Jan 2026 13:32:34 -0700 Message-ID: <20260103203243.3727493-9-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: 4RSARBUTXXTW3WGMUTFLIN6EO6LH6DGD X-Message-ID-Hash: 4RSARBUTXXTW3WGMUTFLIN6EO6LH6DGD 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 08/12] buildman: Extract F: and N: tag handling in parse_file() into methods 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 handling of F: (file path) and N: (name pattern) tags into separate class methods _handle_f_tag() and _handle_n_tag(), and target database updates into _add_targets() This reduces complexity of parse_file() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/boards.py | 96 ++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py index 74f654c6813..36e9ba1f549 100644 --- a/tools/buildman/boards.py +++ b/tools/buildman/boards.py @@ -421,6 +421,60 @@ class MaintainersDatabase: self.warnings.append(f"WARNING: no maintainers for '{target}'") return '' + def _add_targets(self, targets, status, maintainers): + """Add targets to the database + + Args: + targets (list of str): List of target names + status (str): Board status + maintainers (list of str): List of maintainers + """ + for target in targets: + self.database[target] = (status, maintainers) + + @staticmethod + def _handle_f_tag(srcdir, rest, targets): + """Handle F: tag - expand wildcard and filter by defconfig + + Args: + srcdir (str): Source directory + rest (str): Remainder of line after 'F:' + targets (list of str): List to append targets to + """ + glob_path = os.path.join(srcdir, rest) + for item in glob.glob(glob_path): + front, match, rear = item.partition('configs/') + if front.endswith('/'): + front = front[:-1] + if front == srcdir and match: + front, match, rear = rear.rpartition('_defconfig') + if match and not rear: + targets.append(front) + + @staticmethod + def _handle_n_tag(srcdir, rest, targets): + """Handle N: tag - scan configs dir and match with regex + + Args: + srcdir (str): Source directory + rest (str): Remainder of line after 'N:' + targets (list of str): List to append targets to + """ + walk_path = os.walk(os.path.join(srcdir, 'configs')) + for dirpath, _, fnames in walk_path: + for cfg in fnames: + path = os.path.join(dirpath, cfg)[len(srcdir) + 1:] + front, match, rear = path.partition('configs/') + if front or not match: + continue + front, match, rear = rear.rpartition('_defconfig') + + # Use this entry if it matches the defconfig file + # without the _defconfig suffix. For example + # 'am335x.*' matches am335x_guardian_defconfig + if match and not rear and re.search(rest, front): + targets.append(front) + def parse_file(self, srcdir, fname): """Parse a MAINTAINERS file. @@ -438,16 +492,6 @@ class MaintainersDatabase: srcdir (str): Directory containing source code (Kconfig files) fname (str): MAINTAINERS file to be parsed """ - def add_targets(linenum): - """Add any new targets - - Args: - linenum (int): Current line number - """ - if targets: - for target in targets: - self.database[target] = (status, maintainers) - targets = [] maintainers = [] status = '-' @@ -460,41 +504,17 @@ class MaintainersDatabase: if tag == 'M:': maintainers.append(rest) elif tag == 'F:': - # expand wildcard and filter by 'configs/*_defconfig' - glob_path = os.path.join(srcdir, rest) - for item in glob.glob(glob_path): - front, match, rear = item.partition('configs/') - if front.endswith('/'): - front = front[:-1] - if front == srcdir and match: - front, match, rear = rear.rpartition('_defconfig') - if match and not rear: - targets.append(front) + self._handle_f_tag(srcdir, rest, targets) elif tag == 'S:': status = rest elif tag == 'N:': - # Just scan the configs directory since that's all we care - # about - walk_path = os.walk(os.path.join(srcdir, 'configs')) - for dirpath, _, fnames in walk_path: - for cfg in fnames: - path = os.path.join(dirpath, cfg)[len(srcdir) + 1:] - front, match, rear = path.partition('configs/') - if front or not match: - continue - front, match, rear = rear.rpartition('_defconfig') - - # Use this entry if it matches the defconfig file - # without the _defconfig suffix. For example - # 'am335x.*' matches am335x_guardian_defconfig - if match and not rear and re.search(rest, front): - targets.append(front) + self._handle_n_tag(srcdir, rest, targets) elif line == '\n': - add_targets(linenum) + self._add_targets(targets, status, maintainers) targets = [] maintainers = [] status = '-' - add_targets(linenum) + self._add_targets(targets, status, maintainers) class Boards: