use std::fs::read_dir; fn main() -> Result<(), Box> { 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()); } } } tonic_build::configure() .build_client(false) .out_dir("src/server/grpc") .compile(&files, &["../protobuf".into()])?; Ok(()) }