-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Replace rust rules with new prost and tonic rules #202
Conversation
I've updated this to use |
Awesome work. Since this is a breaking change in the rust rules, I expect this will need a major version bump, since I don’t think the current rust rules are marked experimental. This isn’t a problem, but it won’t land in the 4.2.0 release currently “in progress”. I’ve not heard of that crates_universe before, but I’ll take a look. As long as it doesn’t make things more complex for end users, I don’t mind which we use. Let me know when that blocking issue is resolved and we’ll get this into dev branch where CI is less broken. |
Chiming in, should we support |
I haven’t written the docs up yet, but the basic flow is going to be that the consumer of these rules will usually define the cargo dependencies in their workspace (just like with the JavaScript rules). I need to do a bit of testing, I think we can make it work with any configuration of cargo-raze or variant of crates_universe. |
TODO: use rules-proto-grpc fork with prost and tonic <rules-proto-grpc/rules_proto_grpc#202>
As of right now there's not really any functionality for consuming dependencies from I opened bazelbuild/rules_rust#1423 to maybe make the |
Sorry to write this here but issues are not available on your fork...
From my understanding, this error is raised because you are directly creating a |
Yeah, I need to finish up the docs, you need to define the dependencies in your workspace so that either a |
You might want to set |
@UebelAndre will that work if consumers use |
This is now blocked on neoeinstein/protoc-gen-prost#17 getting released. |
I haven’t looked to closely, but the general pattern used in rules_rust is there’s a toolchain which provides all the necessary info for rules. The repo provides some toolchains by default that users can instantiate off they want. Otherwise, they can create their own toolchain to use their own dependencies. So if that’s how this is setup then the renamed set of dependencies should be just fine. It’s also recommended so the rules here don’t accidentally block the use of other dependencies needed in a workspace but not defined here. |
Thanks, can you point me to an example of such a toolchain definition in rules_rust? (specifically for a rule that depends on specific crates, ideally) |
Maybe take a look at @rules_rust//wasm_bindgen. |
I opened neoeinstein/protoc-gen-prost#18 but think you'll just have to depend on that project via a git commit and not a published crate. |
Thank you @titanous for your work. The introduction of Prost as the default backend works for simple use cases. There are some Protocol Buffer features that do not work. Looking at the way how Prost works, I'm not sure, whether it will be possible to implement these features without some major overhaul.
|
1e8495b
to
3792b72
Compare
Hello - is there anything blocking being able to merge this? |
I've not tested it yet, since the PR is still marked as draft and the comment in the first post. Are there any outstanding items that need completing? |
@titanous any updates? |
I have not had time to address the comment from @realtimetodie or to make the dependency management work sustainably. It works fine for simple use cases though. |
I'll publish an example repository over the weekend. I just need to get my ass up. |
it took me five beers and here it is. originally, I posted #202 (comment) and pointed out some limitations. my thing has nothing to do with rules_proto_grpc or @titanous's PR. it is straightforward. https://github.com/realtimetodie/bazel-rust-grpc-aperture write me an email if u have questions. |
3792b72
to
fdf691c
Compare
fdf691c
to
394812b
Compare
This is ready for initial review. It now supports building a crate from multiple named proto packages which resolves the issues mentioned in #202 (comment). There are probably still a few rough edges, and a bit of documentation is needed about how to make the necessary prost/tonic dependency targets. The expectation is that the rule will be used to build a single
|
14f36b0
to
975c0a7
Compare
975c0a7
to
0b97a94
Compare
@titanous thanks for all your time and energy writing this! |
Please go ahead and take over! The main thing outstanding is implementing a good solution for the dependencies and documenting it. I also received no feedback from the maintainers about the approach and ended up iterating a bit more in my monorepo (I can post an export of that if you'd like). I do not currently have the bandwidth to continue work on this PR. |
An export would be wonderful! As far as dependencies go, I have a macro solution I implemented for my own workspace that I was working on turning into a ruleset when I stumbled upon your PR. I am thinking about applying my dependency solution to your PR, but would appreciate your feedback the approach if you don't mind (or anybody else who also has feedback 😄 ) Declaring a prost_library and tonic_library in my current solution looks like so: proto_library(
name = "some_proto",
srcs = ["some.proto"],
deps = ["@go_googleapis//google/api:annotations_proto"],
)
prost_library(
name = "some_prost_rs",
externs = {
".google.api": "::googleapi_rs::google::api",
},
protos = [
":some_proto",
],
deps = [
"//rust/proto/common:googleapi_rs",
],
)
tonic_library(
name = "some_tonic_rs",
prost_proto = ":some_prost_rs",
proto_package = "path.to.my.proto.v1",
proto = ":some_proto",
) It allows you to compile each I think that a small ergonomics improvement could be made via making
|
Here's the export: https://github.com/titanous/rules_proto_grpc_rust I think your approach is interesting, and might be reasonably ergonomic with a gazelle plugin to the annoying bits automatically... |
@titanous Sounds good and thank you @aaliddell This will be my first time writing custom bazel rules. Is it ok for me to have a custom |
I've been really lacking in my tracking of this work, sorry @titanous & @echochamber Am I right in saying that conceptually the core of this PR is good (compiles & links etc) but the remaining aspect is how to make it pleasant to work with? I'm going to have to do a bit of re-reading on Rust crates structuring, since the last time I looked at them was with the current rust rules... 🙄
Yep, the proto_compile function is setup to allow you to do this, as |
Closing since #265 merged. Thanks for all the work and once again sorry for the long response times |
Closes #143.