diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-02-23 01:28:03 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-02-23 01:31:51 -0500 |
commit | 023a0db04ca92a825704f3f1a8382554996efb53 (patch) | |
tree | cd632fafbe2486b1708534419fcf336bfe19ab4c | |
parent | c0db0b73dac284fe0144929b6aca9c386399c004 (diff) | |
download | meson-023a0db04ca92a825704f3f1a8382554996efb53.zip meson-023a0db04ca92a825704f3f1a8382554996efb53.tar.gz meson-023a0db04ca92a825704f3f1a8382554996efb53.tar.bz2 |
clangformat: don't noisily print status messages for every checked file
The version lookup should be silent. While we're at it, the version
lookup should not be happening more than once, which printing multiple
messages indicated we were doing. Pass the version into the per-file
function rather than looking it up fresh each time.
Fixes https://github.com/mesonbuild/meson/pull/11054#issuecomment-1430169280
-rw-r--r-- | mesonbuild/scripts/clangformat.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index a706b76..c66df16 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -23,10 +23,9 @@ from ..mesonlib import version_compare from ..programs import ExternalProgram import typing as T -def run_clang_format(fname: Path, exelist: T.List[str], check: bool) -> subprocess.CompletedProcess: +def run_clang_format(fname: Path, exelist: T.List[str], check: bool, cformat_ver: T.Optional[str]) -> subprocess.CompletedProcess: clangformat_10 = False - if check: - cformat_ver = ExternalProgram('clang-format', exelist).get_version() + if check and cformat_ver: if version_compare(cformat_ver, '>=10'): clangformat_10 = True exelist = exelist + ['--dry-run', '--Werror'] @@ -58,4 +57,9 @@ def run(args: T.List[str]) -> int: print('Could not execute clang-format "%s"' % ' '.join(exelist)) return 1 - return run_tool('clang-format', srcdir, builddir, run_clang_format, exelist, options.check) + if options.check: + cformat_ver = ExternalProgram('clang-format', exelist, silent=True).get_version() + else: + cformat_ver = None + + return run_tool('clang-format', srcdir, builddir, run_clang_format, exelist, options.check, cformat_ver) |