| Message ID | 20260202112511.640320-4-barnabas.pocze@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
On Mon, Feb 02, 2026 at 12:25:11PM +0100, Barnabás Pőcze wrote: > Add support for diagnosing meson file style issues using `meson format`. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > --- > This probably makes `MesonChecker` unnecessary. Ack. > --- > utils/checkstyle.py | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > 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`') > + ] 1.9.0 is very recent. Won't this cause failures in CI ? > + > + > + 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
2026. 02. 06. 0:39 keltezéssel, Laurent Pinchart írta: > On Mon, Feb 02, 2026 at 12:25:11PM +0100, Barnabás Pőcze wrote: >> Add support for diagnosing meson file style issues using `meson format`. >> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> >> --- >> This probably makes `MesonChecker` unnecessary. > > Ack. > >> --- >> utils/checkstyle.py | 30 ++++++++++++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >> >> 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`') >> + ] > > 1.9.0 is very recent. Won't this cause failures in CI ? Yes indeed, debian 13 has 1.7.0. So this is very much a "very rfc". I suppose `pip` could be used to get a newer version. > >> + >> + >> + 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 >
On Fri, Feb 06, 2026 at 09:55:20AM +0100, Barnabás Pőcze wrote: > 2026. 02. 06. 0:39 keltezéssel, Laurent Pinchart írta: > > On Mon, Feb 02, 2026 at 12:25:11PM +0100, Barnabás Pőcze wrote: > >> Add support for diagnosing meson file style issues using `meson format`. > >> > >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > >> --- > >> This probably makes `MesonChecker` unnecessary. > > > > Ack. > > > >> --- > >> utils/checkstyle.py | 30 ++++++++++++++++++++++++++++++ > >> 1 file changed, 30 insertions(+) > >> > >> 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`') > >> + ] > > > > 1.9.0 is very recent. Won't this cause failures in CI ? > > Yes indeed, debian 13 has 1.7.0. So this is very much a "very rfc". > I suppose `pip` could be used to get a newer version. Possibly, but I'm also a bit worried about the impact on developers. Experience has shown that people who were forced to install a newer meson version through pip because their distribution was lagging often also kept the meson system package, resulting in problems and bug reports. We're not forcing users to support meson format, as far as I understand this flags an issue but doesn't prevent checkstyle from running, so I suppose this could be OK, but I wonder if we shouldn't start by silently ignoring meson format if meson is too old, and only later flag an issue once meson 1.9.0 will be more widely available ? > >> + > >> + > >> + 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
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
Add support for diagnosing meson file style issues using `meson format`. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- This probably makes `MesonChecker` unnecessary. --- utils/checkstyle.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.52.0