#20119 A plugin for Rust
New discussion created by
tgolsson
Hello friends!
TL;DR - see bottom.
I've started working on a
Pants plugin for Rust support, and this is both an announcement and a call-for-contributors . I (along with many others) have wanted Rust support in Pants for a long while now, and there's been multiple topics on this in the past. For example:
•
https://github.com/pantsbuild/pants/discussions/14649
•
https://docs.google.com/document/d/1Q5h0PTusb2WyD3EScgeqUxBPF1IuEXCaa3qO31HEHjQ/edit#heading=h.y6yifumv9d8g
•
#15093
•
#15775
•
https://github.com/pantsbuild/pants/discussions/17502
Based on all of these discussions, the lack of progress, and the ratio of unknowns to knowns, I went for the simplest alternative: only wrap Cargo. Doing this will not be efficient or "Pants-like" but it'll allow shipping Rust from Pants tomorrow. That's the baseline for dogfooding this, and everything else can come later. This is how I've developed all my other plugins, most of which I use daily and in production.
To make this easier to adopt and improve, I've opted to develop this is as a fully independent plugin. This means that if you're on Pants 2.17 or a pre-release of 2.18
1 you can immediately start using it. The plugin will automatically install Rust for you as part of Pants (isolated from your system), though not any C/C++ tools or native tools that might be needed. Later on,
To get startedthis, add the following to your
pants.toml
.
plugins = [
"pants_cargo_porcelain @ git+<https://github.com/tgolsson/pants-cargo-porcelain#egg=pants_cargo_porcelain&subdirectory=pants-plugins/cargo-porcelain>",
]
backend_packages = [
"pants.backend.tools.taplo", # optional but suggested
"pants_cargo_porcelain",
"pants_cargo_porcelain.backends.clippy",
]
Then, once you've added a rust package you can run
tailor
as usual, and start running, packaging, linting, formatting, and testing Rust code. There is currently no support for workspaces, but it's very high on the TODO, and contributions are welcome!
There is also
an example repository which shows how to set this up.
Footnotes
1. Once 2.18 is released, the plan is to only support the
current stable Pants moving forward.
:leftwards_arrow_with_hook:
pantsbuild/pants