use std::io::Result;
fn main() -> Result<()> {
std::fs::create_dir_all("src/common/protocol")?;
let mut config = prost_build::Config::new();
config.out_dir("src/common/protocol");
config.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]");
config.type_attribute(".", "#[serde(rename_all = \"snake_case\")]");
config.compile_protos(&["frame.proto", "commands.proto"], &["proto/"])?;
let flare_core_path = "src/common/protocol/flare.core.rs";
if std::path::Path::new(flare_core_path).exists() {
let content = std::fs::read_to_string(flare_core_path)?;
let fixed_content = content.replace(
"commands::Command",
"super::commands::Command"
);
std::fs::write(flare_core_path, fixed_content)?;
}
println!("cargo:rerun-if-changed=proto/frame.proto");
println!("cargo:rerun-if-changed=proto/commands.proto");
Ok(())
}