fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "grpc")]
{
compile_protos()?;
}
Ok(())
}
#[cfg(feature = "grpc")]
fn compile_protos() -> Result<(), Box<dyn std::error::Error>> {
let proto_file = "proto/a2a.proto";
let proto_dir = "proto";
let googleapis_dir = "proto/googleapis";
if !std::path::Path::new(proto_file).exists() {
println!("cargo:warning=Proto file not found: {proto_file}");
return Ok(());
}
if !std::path::Path::new(googleapis_dir).exists() {
println!("cargo:warning=googleapis submodule not found. Run: git submodule update --init");
return Ok(());
}
tonic_prost_build::configure()
.build_server(true)
.build_client(true)
.extern_path(".google.api", "::google_api_proto::google::api")
.compile_protos(
&[proto_file],
&[proto_dir, googleapis_dir],
)?;
println!("cargo:rerun-if-changed={proto_file}");
println!("cargo:rerun-if-changed={proto_dir}");
Ok(())
}