fix(build): Correctly convert Empty to () (#734)

This commit is contained in:
Tom Dyas
2021-10-22 08:44:27 -04:00
committed by GitHub
parent 4947b076f5
commit ff6a690cec
5 changed files with 53 additions and 31 deletions
+1
View File
@@ -16,4 +16,5 @@ tonic = { path = "../../tonic" }
prost = "0.9"
[build-dependencies]
prost-build = "0.9"
tonic-build = { path = "../../tonic-build" }
+8 -1
View File
@@ -1,6 +1,13 @@
fn main() {
let mut config = prost_build::Config::new();
config.extern_path(".google.protobuf.Empty", "()");
tonic_build::configure()
.compile_well_known_types(true)
.compile(&["proto/google.proto"], &["proto"])
.compile_with_config(
config,
&["proto/google.proto", "proto/test.proto"],
&["proto"],
)
.unwrap();
}
+11
View File
@@ -0,0 +1,11 @@
syntax = "proto3";
package test;
import "google/protobuf/empty.proto";
message Input {
}
service Service {
rpc Call(Input) returns (google.protobuf.Empty);
}
+13 -4
View File
@@ -1,9 +1,18 @@
pub mod google {
pub mod protobuf {
tonic::include_proto!("google.protobuf");
pub mod gen {
pub mod google {
pub mod protobuf {
tonic::include_proto!("google.protobuf");
}
}
pub mod test {
tonic::include_proto!("test");
}
}
pub fn grok() {
let _empty = crate::google::protobuf::Empty {};
let _any = crate::gen::google::protobuf::Any {
type_url: "foo".to_owned(),
value: Vec::new(),
};
}