summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/clippy.py
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-11-30 15:00:14 -0500
committerJohn Turner <jturner.usa@gmail.com>2025-12-11 17:45:18 -0500
commitd2ea7cdad6868411c09b39fa3d8978a77ac336d7 (patch)
tree85f45068b477414683c42d37c51a1ebb96cd6bad /mesonbuild/scripts/clippy.py
parentbfa96def243340841c1752bb63eeb4add92fe25a (diff)
downloadmeson-clippy-json.tar.gz
add clippy-json targetclippy-json
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. This also changes the --emit option in the clippy script to "emit", without this, clippy will fail with errors about missing libraries. These would normally be created with the normal compilation target, but we can't rely on that, because if it fails, clippy-json never runs, and you won't get error messages to the LSP.
Diffstat (limited to 'mesonbuild/scripts/clippy.py')
-rw-r--r--mesonbuild/scripts/clippy.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/mesonbuild/scripts/clippy.py b/mesonbuild/scripts/clippy.py
index 0ea7a3429..0a8d85779 100644
--- a/mesonbuild/scripts/clippy.py
+++ b/mesonbuild/scripts/clippy.py
@@ -15,7 +15,7 @@ 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 +24,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]:
@@ -64,13 +65,14 @@ class ClippyDriver:
# and --emit dep-info= is not enough for clippy to do
# enough analysis, so use --emit metadata.
cmdlist.append('--emit')
- cmdlist.append('metadata')
+ cmdlist.append('link')
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())
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:]))