Skip to content

Commit

Permalink
Allow setting skip_protoc_run on the prost Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
pruthvikar committed Mar 20, 2023
1 parent a9db219 commit 5552647
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tonic-build/src/prost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -224,6 +225,7 @@ pub struct Builder {
pub(crate) build_server: bool,
pub(crate) build_transport: bool,
pub(crate) file_descriptor_set_path: Option<PathBuf>,
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)>,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5552647

Please sign in to comment.