use std::path::PathBuf;
use glob::glob;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let generated_dir = PathBuf::from(std::env::var("OUT_DIR").map_err(
|_| "OUT_DIR environment variable is not set. This script must be run by cargo.",
)?);
let proto_files: Vec<String> = glob("proto/**/*.proto")?
.filter_map(Result::ok)
.map(|p| p.to_string_lossy().into_owned())
.collect();
if proto_files.is_empty() {
return Err("No proto files found".into());
}
prost_build::Config::new()
.out_dir(&generated_dir)
.bytes(["."])
.type_attribute(
"ActrId",
"#[derive(Ord, PartialOrd, serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
"ActrType",
"#[derive(Ord, PartialOrd, serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
"Realm",
"#[derive(Ord, PartialOrd, serde::Serialize, serde::Deserialize)]",
)
.compile_protos(&proto_files, &["proto/"])?;
println!("cargo:rerun-if-changed=proto/");
Ok(())
}