You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
657 B

use std::fs::read_dir;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=../protobuf/");
println!("cargo:rerun-if-changed=build.rs");
let mut files = Vec::new();
for f in read_dir("../protobuf").unwrap().flatten() {
if f.path().is_file() && f.path().extension().map(|x| x == "proto").unwrap_or(false) {
files.push(f.path());
}
}
if let Err(e) = prost_build::Config::new()
.out_dir("src/server/protos")
.compile_protos(
&files,
&[
<std::path::PathBuf as From<&str>>::from("../protobuf"),
"../protobuf/include".into(),
],
) {
eprintln!("{}", e);
return Err(e.into());
}
Ok(())
}