use std::path::Path;
fn have_protoc() -> bool {
if std::env::var_os("PROTOC").is_some() {
return true;
}
std::env::var_os("PATH")
.is_some_and(|paths| std::env::split_paths(&paths).any(|dir| dir.join("protoc").is_file()))
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=proto");
if !have_protoc() && Path::new("src/grpc/atradio.v1.rs").exists() {
return Ok(());
}
tonic_build::configure()
.out_dir("src/grpc")
.file_descriptor_set_path("src/grpc/descriptor.bin")
.compile_protos(&["proto/atradio/v1/atradio.proto"], &["proto"])?;
Ok(())
}