From patchwork Mon Feb 2 11:25:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26073 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F28E1C328F for ; Mon, 2 Feb 2026 11:25:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7793361FF5; Mon, 2 Feb 2026 12:25:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HuUSu8A7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8681061FE2 for ; Mon, 2 Feb 2026 12:25:28 +0100 (CET) Received: from pb-laptop.local (185.221.142.123.nat.pool.zt.hu [185.221.142.123]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C39B01AAE for ; Mon, 2 Feb 2026 12:24:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1770031487; bh=PETqY9QSHav8oRqZUgoSWAzbKDOOp7zkBjJIBZKsHUU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HuUSu8A7ygx48IoFGH9ND9cO2neQOQbrqagIsFa4mhknRj5RZllkPZAkHgc8awq4H 3QN72EVDqXQEehnFH6toXhZxE1FsGEEWI1/+hszeEqg10jOTSr+dmGjcEzZC/ryEws 8hkmrTWTGdd8hgzx1RfEi6cj4xqL6nKqAsPUH7B8= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 3/3] utils: checkstyle.py: Add `MesonFormatter` Date: Mon, 2 Feb 2026 12:25:11 +0100 Message-ID: <20260202112511.640320-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260202112511.640320-1-barnabas.pocze@ideasonboard.com> References: <20260202112511.640320-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for diagnosing meson file style issues using `meson format`. Signed-off-by: Barnabás Pőcze --- This probably makes `MesonChecker` unnecessary. --- utils/checkstyle.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.52.0 diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 06b9f199a..2dfff0473 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -919,6 +919,36 @@ class StripTrailingSpaceFormatter(Formatter): lines[i] = lines[i].rstrip() + '\n' return ''.join(lines) +class MesonFormatter(Formatter): + @staticmethod + def _check_meson_version(): + # 1.5.0 for `meson format` + # 1.7.0 for stdin input + # 1.9.0 for `--source-file-path` + VERSION_REQ = (1, 9, 0) + + ret = subprocess.run(['meson', '--version'], + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + ver = tuple(map(int, ret.stdout.decode('utf-8').split('.'))) + if ver < VERSION_REQ: + return [ + CommitIssue(f'Missing meson {".".join(map(str, VERSION_REQ))} to run `meson format`') + ] + + + dependencies = (('meson', _check_meson_version), ) + patterns = ('meson.build', ) + + @classmethod + def format(cls, filename, data): + ret = subprocess.run(['meson', 'format', '-', + '--source-file-path', filename], + input=data.encode('utf-8'), stdout=subprocess.PIPE) + return ret.stdout.decode('utf-8') + # ------------------------------------------------------------------------------ # Style checking