summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/run_tool.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-18 11:20:56 +0100
committerDylan Baker <dylan@pnwbakers.com>2024-12-19 09:25:20 -0800
commit27c567de5d1807ac72708ea48018a21f0c6b8dd2 (patch)
tree180bc008df788970020b66ae677ea0f4e4a2d0e5 /mesonbuild/scripts/run_tool.py
parent5dc537afd051e60ff00731f73e02d98138d9198b (diff)
downloadmeson-27c567de5d1807ac72708ea48018a21f0c6b8dd2.tar.gz
scripts: add "clippy" internal tool
Similar to the "ninja scan-build" target for C, add a clippy internal tool that runs clippy-driver on all crates in the project. The approach used is more efficient than with "ninja scan-build", and does not require rerunning Meson in a separate build directory; it uses the introspection data to find the compiler arguments for the target and invokes clippy-driver with a slightly modified command line. This could actually be applied to scan-build as well, reusing the run_tool_on_targets() function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild/scripts/run_tool.py')
-rw-r--r--mesonbuild/scripts/run_tool.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/scripts/run_tool.py b/mesonbuild/scripts/run_tool.py
index bccc4cb83..e206ff7fe 100644
--- a/mesonbuild/scripts/run_tool.py
+++ b/mesonbuild/scripts/run_tool.py
@@ -6,6 +6,7 @@ from __future__ import annotations
import asyncio.subprocess
import fnmatch
import itertools
+import json
import signal
import sys
from pathlib import Path
@@ -126,3 +127,12 @@ def run_clang_tool(name: str, srcdir: Path, builddir: Path, fn: T.Callable[...,
def wrapper(path: Path) -> T.Iterable[T.Coroutine[None, None, int]]:
yield fn(path, *args)
return asyncio.run(_run_workers(all_clike_files(name, srcdir, builddir), wrapper))
+
+def run_tool_on_targets(fn: T.Callable[[T.Dict[str, T.Any]],
+ T.Iterable[T.Coroutine[None, None, int]]]) -> int:
+ if sys.platform == 'win32':
+ asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
+
+ with open('meson-info/intro-targets.json', encoding='utf-8') as fp:
+ targets = json.load(fp)
+ return asyncio.run(_run_workers(targets, fn))