diff options
| author | Sahnvour <sahnvour@pm.me> | 2025-06-22 11:58:22 +0200 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-07-21 09:09:10 -0700 |
| commit | 6b217e690f2e475363985bc0d074d4e644300d32 (patch) | |
| tree | 116b9bac57cdcf64955071a9e4550c2f62169bf6 /mesonbuild/scripts/run_tool.py | |
| parent | 6e379f0090b606786d540001b4a2de52f57e5e47 (diff) | |
| download | meson-6b217e690f2e475363985bc0d074d4e644300d32.tar.gz | |
clang-tidy: run tool only on source files participating in targets
clang-tidy can't be ran as is on every source file and header
Diffstat (limited to 'mesonbuild/scripts/run_tool.py')
| -rw-r--r-- | mesonbuild/scripts/run_tool.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mesonbuild/scripts/run_tool.py b/mesonbuild/scripts/run_tool.py index e206ff7fe..6181c6d3c 100644 --- a/mesonbuild/scripts/run_tool.py +++ b/mesonbuild/scripts/run_tool.py @@ -128,6 +128,26 @@ def run_clang_tool(name: str, srcdir: Path, builddir: Path, fn: T.Callable[..., yield fn(path, *args) return asyncio.run(_run_workers(all_clike_files(name, srcdir, builddir), wrapper)) +def run_clang_tool_on_sources(name: str, srcdir: Path, builddir: Path, fn: T.Callable[..., T.Coroutine[None, None, int]], *args: T.Any) -> int: + if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) + + source_files = set() + with open('meson-info/intro-targets.json', encoding='utf-8') as fp: + targets = json.load(fp) + + for target in targets: + for target_source in target.get('target_sources') or []: + for source in target_source.get('sources') or []: + source_files.add(Path(source)) + + clike_files = set(all_clike_files(name, srcdir, builddir)) + source_files = source_files.intersection(clike_files) + + def wrapper(path: Path) -> T.Iterable[T.Coroutine[None, None, int]]: + yield fn(path, *args) + return asyncio.run(_run_workers(source_files, 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': |
