Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 14 commits into from
Oct 2, 2024
Merged

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

merged 14 commits into from
Oct 2, 2024

Conversation

alexeagle
Copy link
Member

Goals:

  • should be as similar as possible to using Rust outside of Bazel. All non-Bazel tooling should continue to work.
  • should be consistent with other languages under Aspect, for example the cargo "repinning" operation ought to appear similar-shaped

@alexeagle
Copy link
Member Author

@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
Copy link

CLAassistant commented Sep 19, 2024

CLA assistant check
All committers have signed the CLA.

@illicitonion
Copy link
Collaborator

illicitonion commented Sep 19, 2024

@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 aspect-build/rules_lint#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
Copy link
Member Author

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
Copy link
Member Author

I forgot to say, yay, very cool :)

@alexeagle alexeagle merged commit b4d57f0 into main Oct 2, 2024
10 checks passed
@alexeagle alexeagle deleted the rust branch October 2, 2024 16:16
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.

4 participants