feat(build): Support compiling well-known protobuf types (#522)

This commit is contained in:
Tom Dyas
2021-02-23 16:21:03 -05:00
committed by GitHub
parent 49d517fac9
commit 61555ff2b5
9 changed files with 198 additions and 39 deletions
+19
View File
@@ -0,0 +1,19 @@
[package]
name = "wellknown-compiled"
version = "0.1.0"
authors = ["Lucio Franco <[email protected]>"]
edition = "2018"
publish = false
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
doctest = false
[dependencies]
tonic = { path = "../../tonic" }
prost = "0.7"
[build-dependencies]
tonic-build = { path = "../../tonic-build" }
+6
View File
@@ -0,0 +1,6 @@
fn main() {
tonic_build::configure()
.compile_well_known_types(true)
.compile(&["proto/google.proto"], &["proto"])
.unwrap();
}
@@ -0,0 +1,16 @@
syntax = "proto3";
package google.protobuf;
import "google/protobuf/any.proto";
import "google/protobuf/api.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/source_context.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/type.proto";
import "google/protobuf/wrappers.proto";
+9
View File
@@ -0,0 +1,9 @@
pub mod google {
pub mod protobuf {
tonic::include_proto!("google.protobuf");
}
}
pub fn grok() {
let _empty = crate::google::protobuf::Empty {};
}