fn main() {
let proto_files = [
"proto/chunk.proto",
];
std::fs::create_dir_all("src/proto").expect("Failed to create output directory");
let mut config = prost_build::Config::new();
config.out_dir("src/proto");
config
.compile_protos(&proto_files, &["proto/"])
.expect("Failed to compile protobuf files");
use std::process::Command;
let flatbuffer_files = [
"flatbuffers/chunk_data.fbs",
];
let out_dir = "src/proto";
std::fs::create_dir_all(out_dir).expect("Failed to create output directory");
for file in &flatbuffer_files {
println!("cargo:rerun-if-changed={}", file);
let status = Command::new("flatc")
.args(&["--rust", "-o", out_dir, file])
.status();
match status {
Ok(s) if s.success() => {
println!("Successfully compiled {}", file);
}
Ok(s) => {
eprintln!("flatc failed with status: {}", s);
eprintln!("Note: Install flatc with 'sudo apt install flatbuffers-compiler' or similar");
}
Err(e) => {
eprintln!("Failed to run flatc: {}", e);
eprintln!("Note: Install flatc with 'sudo apt install flatbuffers-compiler' or similar");
}
}
}
println!("cargo:rerun-if-changed=build.rs");
}