From b3358dc6acf11ec800571735de1e1f1e449ec96a Mon Sep 17 00:00:00 2001 From: Pruthvikar Reddy <2778014+pruthvikar@users.noreply.github.com> Date: Mon, 20 Mar 2023 18:40:37 +0000 Subject: [PATCH] Allow setting skip_protoc_run on the prost Builder (#1318) --- tonic-build/src/prost.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tonic-build/src/prost.rs b/tonic-build/src/prost.rs index 623705b72..978533cc8 100644 --- a/tonic-build/src/prost.rs +++ b/tonic-build/src/prost.rs @@ -20,6 +20,7 @@ pub fn configure() -> Builder { build_server: true, build_transport: true, file_descriptor_set_path: None, + skip_protoc_run: false, out_dir: None, extern_path: Vec::new(), field_attributes: Vec::new(), @@ -224,6 +225,7 @@ pub struct Builder { pub(crate) build_server: bool, pub(crate) build_transport: bool, pub(crate) file_descriptor_set_path: Option, + pub(crate) skip_protoc_run: bool, pub(crate) extern_path: Vec<(String, String)>, pub(crate) field_attributes: Vec<(String, String)>, pub(crate) type_attributes: Vec<(String, String)>, @@ -271,6 +273,14 @@ impl Builder { self } + /// In combination with with file_descriptor_set_path, this can be used to provide a file + /// descriptor set as an input file, rather than having prost-build generate the file by + /// calling protoc. + pub fn skip_protoc_run(mut self) -> Self { + self.skip_protoc_run = true; + self + } + /// Set the output directory to generate code to. /// /// Defaults to the `OUT_DIR` environment variable. @@ -464,6 +474,9 @@ impl Builder { if let Some(path) = self.file_descriptor_set_path.as_ref() { config.file_descriptor_set_path(path); } + if self.skip_protoc_run { + config.skip_protoc_run(); + } for (proto_path, rust_path) in self.extern_path.iter() { config.extern_path(proto_path, rust_path); }