use std::path::PathBuf;
use std::process::Command;
fn main() {
let proto_dir = PathBuf::from("proto");
let out_dir = PathBuf::from("src/generated");
std::fs::create_dir_all(&out_dir).expect("Failed to create output directory");
let protos = [
"proto/common.proto",
"proto/machine.proto",
"proto/container.proto",
"proto/image.proto",
"proto/agent.proto",
"proto/api.proto",
"proto/kubernetes.proto",
"proto/sandbox.proto",
];
let mut config = prost_build::Config::new();
config.out_dir(&out_dir);
config.protoc_arg("--experimental_allow_proto3_optional");
config.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]");
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
config
.compile_protos(&protos, &[proto_dir])
.expect("Failed to compile protobuf files");
let generated_file = out_dir.join("arcbox.v1.rs");
let _ = Command::new("rustfmt").arg(&generated_file).status();
let generated_file = out_dir.join("sandbox.v1.rs");
let _ = Command::new("rustfmt").arg(&generated_file).status();
for proto in &protos {
println!("cargo:rerun-if-changed={proto}");
}
}