fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=proto/raft_peer.proto");
println!("cargo:rerun-if-changed=proto/paxos_peer.proto");
println!("cargo:rerun-if-changed=proto/admin.proto");
let mut protos: Vec<&str> = Vec::new();
if std::env::var_os("CARGO_FEATURE_OPENRAFT").is_some()
&& std::path::Path::new("proto/raft_peer.proto").exists()
{
protos.push("proto/raft_peer.proto");
}
if std::env::var_os("CARGO_FEATURE_OPENRAFT").is_some()
&& std::path::Path::new("proto/admin.proto").exists()
{
protos.push("proto/admin.proto");
}
if std::env::var_os("CARGO_FEATURE_PAXOS").is_some()
&& std::path::Path::new("proto/paxos_peer.proto").exists()
{
protos.push("proto/paxos_peer.proto");
}
if !protos.is_empty() {
tonic_prost_build::configure()
.build_server(true)
.build_client(true)
.compile_protos(&protos, &["proto"])?;
}
Ok(())
}