use std::fs::read_dir; fn main() -> Result<(), Box> { 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() { if let Ok(f) = f { 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, &["../protobuf".into(), "../protobuf/include".into()]) { eprintln!("{}", e); return Err(e.into()); } Ok(()) }