fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "grpc")]
{
let manifest_dir = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
let proto_dir = manifest_dir
.parent()
.and_then(|p| p.parent())
.map(|p| p.join("proto"))
.ok_or("linkrs-server is expected under <workspace>/crates")?;
println!(
"cargo:rerun-if-changed={}",
proto_dir.join("linkrs.proto").display()
);
tonic_build::configure()
.build_server(true)
.build_client(true)
.compile_protos(&[proto_dir.join("linkrs.proto")], &[proto_dir])?;
}
Ok(())
}