From 27c567de5d1807ac72708ea48018a21f0c6b8dd2 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 18 Nov 2024 11:20:56 +0100 Subject: 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 --- mesonbuild/scripts/run_tool.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mesonbuild/scripts/run_tool.py') 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)) -- cgit v1.2.3