Skip to content

Conversation

@Jturnerusa
Copy link
Contributor

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.

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.
@Jturnerusa Jturnerusa requested a review from jpakkane as a code owner November 30, 2025 20:08
@bonzini
Copy link
Collaborator

bonzini commented Nov 30, 2025

You need to explain better why you're changing --emit.

The best way would be with the sequence of clippy-driver invocations that cause problems, and how clippy-json handles it.

In particular I am confused because I don't understand well how --extern picks up the libraries from the temporary directory where they are placed.

That said, you are skipping all dependencies that have --cap-lints allow, which is wrong because there is no dependency from clippy-json to the compilation of those crates.

As mentioned before, I think the best way to do this is to create a new clippy-prereq target that builds the library crates, and invoke it with ninja -k0 from within clippy.py.

@Jturnerusa
Copy link
Contributor Author

You need to explain better why you're changing --emit.

The best way would be with the sequence of clippy-driver invocations that cause problems, and how clippy-json handles it.

In particular I am confused because I don't understand well how --extern picks up the libraries from the temporary directory where they are placed.

That said, you are skipping all dependencies that have --cap-lints allow, which is wrong because there is no dependency from clippy-json to the compilation of those crates.

As mentioned before, I think the best way to do this is to create a new clippy-prereq target that builds the library crates, and invoke it with ninja -k0 from within clippy.py.

That sounds good. This was mostly intended to be a draft to get official review on and to get it out there instead of just running a patched meson locally forever.

I'm not super sure how to add the prereq target yet so I will probably have a bunch of questions!

@Jturnerusa Jturnerusa marked this pull request as draft November 30, 2025 23:09
@bonzini
Copy link
Collaborator

bonzini commented Dec 1, 2025

The prereq target is essentially the same as the existing clippy target, but with a PHONY rule instead of the custom command to invoke meson's clippy script.

scanbuild.py has an example of how to find ninja.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants