Skip to content
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

tonic-build: Allow setting skip_protoc_run on the prost Builder #1318

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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