use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let schema_dir = Path::new("proto/");
let mut schemas = vec![];
for entry in std::fs::read_dir(schema_dir)
.expect(format!("Failed to read {} directory", schema_dir.display()).as_str())
{
let entry = entry.expect("Failed to read directory entry");
let path = entry.path();
if path.extension().map_or(false, |ext| ext == "proto") {
schemas.push(path);
}
}
println!("cargo:rerun-if-changed={}", schema_dir.to_str().unwrap());
prost_build::compile_protos(&schemas, &[schema_dir.to_str().unwrap()])?;
Ok(())
}