aspect-build / aspect-workflows-template

Scaffolding to create an Aspect-flavored Bazel workspace
https://docs.aspect.build
2 stars 1 forks source link

feat: add Rust support in 'aspect init' #125

Closed alexeagle closed 1 month ago

alexeagle commented 2 months ago

Goals:

alexeagle commented 2 months ago

@illicitonion first thing I'm missing is: how do you run the cargo command that rules_rust has installed, so you can add a dependency? See npm, python, and Go where the README says how to do that: https://github.com/aspect-build/aspect-workflows-template/blob/main/%7B%7B%20.ProjectSnake%20%7D%7D/README.bazel.md#working-with-npm-packages

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

illicitonion commented 1 month ago

@alexeagle Ok, I've fixed up a few things, and got this working some - cargo add and friends are now supported and documented :) Shall we put together a list of things you'd be wanting to support out of the box?

I'm thinking (and please add/comment/edit):

rustfmt via rules_lint

This should Just Work, but we can do some testing and make sure the UX is as desired

We should make sure the correct editions are being used per-target

clippy via rules_lint

cc @mrmeku and https://github.com/aspect-build/rules_lint/issues/385

VS Code integration via rust-analyzer

If we're defaulting to "just lay stuff out like Cargo would expect", rust-analyzer should just work out of the box with nothing special.

But in general, rules_rust offers a target: bazel run @rules_rust//tools/rust_analyzer:gen_rust_project which will generate a rust-project.json in the workspace root (which we should probably .gitignore), which rust-analyzer will detect and configure itself with.

protobuf

We have a choice to make here between using build.rs for cargo compatibility, or using rules_proto for re-use between other Bazel languages.

We could probably put together a "use rules_proto, and copy_file the generated code somewhere Cargo will see it" approach, and even if we wanted to be fancy generate a build.rs which runs Bazel to update this generated code...

Version stamping

We should probably make the sample app be a clap application, and show how to hook version stamping into Clap's versioning, as well as maybe how to expose it from a custom metrics page or something.

rules_oci image example

alexeagle commented 1 month ago

We should probably make the sample app be a clap application

We don't have any sample apps in this setup right now. It would be neat to scaffold those out but it should be a separate effort and include the existing languages

alexeagle commented 1 month ago

I forgot to say, yay, very cool :)