-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Rust prost tonic #265
Rust prost tonic #265
Conversation
@aaliddell The majority of the logic here is done and ready for review/initial feedback. All of the targets in rust/example/ should build and run just fine. I'm still working on getting the rules to work outside of the main rules_proto_grpc Workspace. Currently getting an error when I try to
|
5a47de5
to
b02cfc3
Compare
And it works! All of the examples build and run smoothly. That said, there is something interesting going on with deriving the hash/eq type for the pbjson types.
However this only occurs in this second example code snippet below, in the first the build succeeds (even though Thing doesn't derive Hash in the generated code), which is interesting. This buildsrust_tonic_grpc_library(
name = "greeter_tonic",
declared_proto_packages = ["example.proto"],
protos = [
"@rules_proto_grpc//example/proto:greeter_grpc",
"@rules_proto_grpc//example/proto:person_proto",
"@rules_proto_grpc//example/proto:place_proto",
],
options = {
"//rust:rust_prost_plugin": [
"type_attribute=.example.proto.Person=#[derive(Eq\\,Hash)]",
"type_attribute=.example.proto.Place=#[derive(Eq\\,Hash)]",
]},
prost_proto_deps = [
":thing_prost"
]
)
rust_prost_proto_library(
name = "thing_prost",
declared_proto_packages = ["example.proto"],
protos = [
"@rules_proto_grpc//example/proto:thing_proto",
],
) This doesn't buildrust_tonic_grpc_library(
name = "greeter_tonic",
declared_proto_packages = ["example.proto"],
protos = [
"@rules_proto_grpc//example/proto:greeter_grpc",
"@rules_proto_grpc//example/proto:person_proto",
"@rules_proto_grpc//example/proto:place_proto",
"@rules_proto_grpc//example/proto:thing_proto",
],
options = {
"//rust:rust_prost_plugin": [
"type_attribute=.example.proto.Person=#[derive(Eq\\,Hash)]",
"type_attribute=.example.proto.Place=#[derive(Eq\\,Hash)]",
]},
) build error
|
b02cfc3
to
14cd69b
Compare
Currently we default to rules_proto version which, which is out of date and missing @platforms//os:fuchsia. This causes any downstream rulesets that are configuring using this constraint (rules_rust) to fail to build.
14cd69b
to
5e60e62
Compare
Ok, time for me to get reading. Thankfully most of those 20,000 lines changed are just raze -> crate_universe 😱 I'm trying to think if there's any tricks we can play with an aspect that'd let us discover the externs automatically |
As an update of where I am with this:
I'll start adding commits here as I do the above |
I've spun the aspect investigation off into #282 as future work, so it doesn't hold this up any further. The rest is now passing with rulegen aligned with your work. Sorry it's taken me so long |
Status: It works!
Updated version of @titanous PR #202.
Users will need to manually declare the
declared_proto_packages=["proto.package.name", ...]
. The compile rule also requires thecrate_name=my_crate
be provided (but the macros take care of this part for you).However, with this information the custom rule implementation will handle creating all the necessary
--externs_path=.proto.package.name=::my_create::proto::package::name
mappings for you (prost docs).Things I've tested on both
rust_prost_proto_library
andrust_tonic_grpc_library
:nested.proto.namespaces
rust_prost_proto_library
.Known limitations: