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