diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-30 15:00:14 -0500 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-12-20 01:21:48 -0500 |
| commit | 651fe54d12f07dd98ff94f8a8cea2469e746a590 (patch) | |
| tree | 2184ce050f47fbdb6f3477216ebed5d8f26ed220 /mesonbuild/scripts | |
| parent | bfa96def243340841c1752bb63eeb4add92fe25a (diff) | |
| download | meson-651fe54d12f07dd98ff94f8a8cea2469e746a590.tar.gz | |
add clippy-json target
Add a clippy-json target to the ninja script.
This is useful for rust-analyzer, which requires an "external check
command" to function when not using cargo.
Also we add a "clippy-json-prereq" target, and invoke it in the
clippy.py script. The prereq target tries to build as much of the
project as possible with "-k0".
Diffstat (limited to 'mesonbuild/scripts')
| -rw-r--r-- | mesonbuild/scripts/clippy.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mesonbuild/scripts/clippy.py b/mesonbuild/scripts/clippy.py index 0ea7a3429..519d3ab22 100644 --- a/mesonbuild/scripts/clippy.py +++ b/mesonbuild/scripts/clippy.py @@ -6,16 +6,18 @@ from collections import defaultdict import os import tempfile import typing as T +import subprocess from .run_tool import run_tool_on_targets, run_with_buffered_output from .. import build, mlog from ..mesonlib import MachineChoice, PerMachine +from ..tooldetect import detect_ninja if T.TYPE_CHECKING: from ..compilers.rust import RustCompiler class ClippyDriver: - def __init__(self, build: build.Build, tempdir: str): + def __init__(self, build: build.Build, tempdir: str, args: list[str]): self.tools: PerMachine[T.List[str]] = PerMachine([], []) self.warned: T.DefaultDict[str, bool] = defaultdict(lambda: False) self.tempdir = tempdir @@ -24,6 +26,7 @@ class ClippyDriver: if 'rust' in compilers: compiler = T.cast('RustCompiler', compilers['rust']) self.tools[machine] = compiler.get_rust_tool('clippy-driver') + self.args = args def warn_missing_clippy(self, machine: str) -> None: if self.warned[machine]: @@ -67,10 +70,17 @@ class ClippyDriver: cmdlist.append('metadata') cmdlist.append('--out-dir') cmdlist.append(self.tempdir) + cmdlist += self.args yield run_with_buffered_output(cmdlist) def run(args: T.List[str]) -> int: os.chdir(args[0]) build_data = build.load(os.getcwd()) + + # Build as much of the project as possible, or else + # we get errors about missing libraries in the build directory and + # other related errors. + subprocess.run(detect_ninja() + ['clippy-json-prereq', '-k0']) + with tempfile.TemporaryDirectory() as d: - return run_tool_on_targets(ClippyDriver(build_data, d)) + return run_tool_on_targets(ClippyDriver(build_data, d, args[1:])) |
