-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.rs
34 lines (27 loc) · 905 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#[cfg(feature = "serde")]
use std::{env, path::PathBuf};
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "serde")]
let descriptor_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("proto_descriptor.bin");
let config = tonic_build::configure()
.compile_well_known_types(true)
.build_server(cfg!(feature = "server"))
.build_client(cfg!(feature = "client"));
#[cfg(feature = "serde")]
let config = config.file_descriptor_set_path(&descriptor_path);
config.compile_protos(
&[
"scuffle/image_processor/service.proto",
"scuffle/image_processor/types.proto",
"scuffle/image_processor/events.proto",
],
&["./"],
)?;
#[cfg(feature = "serde")]
let descriptor_set = std::fs::read(&descriptor_path)?;
#[cfg(feature = "serde")]
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.build(&[".scuffle.image_processor"])?;
Ok(())
}