|
9 | 9 | import json
|
10 | 10 | import signal
|
11 | 11 | import sys
|
12 |
| -from pathlib import Path |
| 12 | +from pathlib import Path, PosixPath |
13 | 13 |
|
14 | 14 | from .. import mlog
|
15 | 15 | from ..compilers import lang_suffixes
|
@@ -128,6 +128,26 @@ def wrapper(path: Path) -> T.Iterable[T.Coroutine[None, None, int]]:
|
128 | 128 | yield fn(path, *args)
|
129 | 129 | return asyncio.run(_run_workers(all_clike_files(name, srcdir, builddir), wrapper))
|
130 | 130 |
|
| 131 | +def run_clang_tool_on_sources(name: str, srcdir: Path, builddir: Path, fn: T.Callable[..., T.Coroutine[None, None, int]], *args: T.Any) -> int: |
| 132 | + if sys.platform == 'win32': |
| 133 | + asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) |
| 134 | + |
| 135 | + source_files = set() |
| 136 | + with open('meson-info/intro-targets.json', encoding='utf-8') as fp: |
| 137 | + targets = json.load(fp) |
| 138 | + |
| 139 | + for target in targets: |
| 140 | + for target_source in target.get('target_sources') or []: |
| 141 | + for source in target_source.get('sources') or []: |
| 142 | + source_files.add(PosixPath(source)) |
| 143 | + |
| 144 | + clike_files = set(all_clike_files(name, srcdir, builddir)) |
| 145 | + source_files = source_files.intersection(clike_files) |
| 146 | + |
| 147 | + def wrapper(path: Path) -> T.Iterable[T.Coroutine[None, None, int]]: |
| 148 | + yield fn(path, *args) |
| 149 | + return asyncio.run(_run_workers(source_files, wrapper)) |
| 150 | + |
131 | 151 | def run_tool_on_targets(fn: T.Callable[[T.Dict[str, T.Any]],
|
132 | 152 | T.Iterable[T.Coroutine[None, None, int]]]) -> int:
|
133 | 153 | if sys.platform == 'win32':
|
|
0 commit comments