diff options
| author | Jonathon Anderson <anderson.jonathonm@gmail.com> | 2024-08-20 08:59:37 -0500 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2024-09-24 14:55:45 -0700 |
| commit | 8eaeff5b1f3057f827dfc95ac3987903c9bcb828 (patch) | |
| tree | f1ec6db6e77396b3f7b6cf142ee264a96122892b /mesonbuild/environment.py | |
| parent | f3daf6265aa412c2d54784100c8618e9008a2f9d (diff) | |
| download | meson-8eaeff5b1f3057f827dfc95ac3987903c9bcb828.tar.gz | |
clang-tidy: Avoid spawning too many threads
The clang-tidy-fix target uses run-clang-tidy to do the fixing, however
this script itself spawns `os.cpu_count()` threads as part of its
internal parallelism. When combined with Meson's parallelism this
results in the creation of potentially thousands of unecessary threads.
This commit rewrites the clang-tidy-fix to perform the same task
run-clang-tidy does but exclusively on Meson's thread pool. "Fix-it"
snippets are saved to `meson-private/clang-tidy-fix/` by a parallel
clang-tidy phase, afterwards (to avoid races) all collected fixes are
applied with a single call to clang-apply-replacements.
Diffstat (limited to 'mesonbuild/environment.py')
| -rw-r--r-- | mesonbuild/environment.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 90c9bb911..71a2f3afc 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -275,6 +275,32 @@ def detect_clangformat() -> T.List[str]: return [path] return [] +def detect_clangtidy() -> T.List[str]: + """ Look for clang-tidy binary on build platform + + Return: a single-element list of the found clang-tidy binary ready to be + passed to Popen() + """ + tools = get_llvm_tool_names('clang-tidy') + for tool in tools: + path = shutil.which(tool) + if path is not None: + return [path] + return [] + +def detect_clangapply() -> T.List[str]: + """ Look for clang-apply-replacements binary on build platform + + Return: a single-element list of the found clang-apply-replacements binary + ready to be passed to Popen() + """ + tools = get_llvm_tool_names('clang-apply-replacements') + for tool in tools: + path = shutil.which(tool) + if path is not None: + return [path] + return [] + def detect_windows_arch(compilers: CompilersDict) -> str: """ Detecting the 'native' architecture of Windows is not a trivial task. We |
