2022-10-08 04:30:12 -06:00
|
|
|
use std::fs;
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2023-01-30 07:36:16 -07:00
|
|
|
println!("cargo:rerun-if-changed=../../proto/generate.proto");
|
2022-10-08 04:30:12 -06:00
|
|
|
fs::create_dir("src/pb").unwrap_or(());
|
2023-02-13 05:02:45 -07:00
|
|
|
|
|
|
|
let mut config = prost_build::Config::new();
|
|
|
|
config.protoc_arg("--experimental_allow_proto3_optional");
|
|
|
|
|
2022-10-08 04:30:12 -06:00
|
|
|
tonic_build::configure()
|
|
|
|
.build_client(true)
|
|
|
|
.build_server(false)
|
|
|
|
.out_dir("src/pb")
|
|
|
|
.include_file("mod.rs")
|
2023-02-13 05:02:45 -07:00
|
|
|
.compile_with_config(config, &["../../proto/generate.proto"], &["../../proto"])
|
|
|
|
.unwrap_or_else(|e| panic!("protobuf compilation failed: {e}"));
|
2022-10-08 04:30:12 -06:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|