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/macos.proto",
"proto/container.proto",
"proto/image.proto",
"proto/agent.proto",
"proto/api.proto",
"proto/kubernetes.proto",
"proto/arcbox/sandbox/v1/sandbox.proto",
"proto/arcbox/sandbox/v1/process.proto",
"proto/arcbox/sandbox/v1/filesystem.proto",
"proto/arcbox/sandbox/v1/snapshot.proto",
"proto/arcbox/sandbox/v1/template.proto",
"proto/arcbox/sandbox/v1/errors.proto",
"proto/stats.proto",
];
let mut config = prost_build::Config::new();
config.out_dir(&out_dir);
config.protoc_arg("--experimental_allow_proto3_optional");
config.compile_well_known_types();
config.extern_path(".google.protobuf", "::pbjson_types");
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("arcbox.sandbox.v1.rs");
let _ = Command::new("rustfmt").arg(&generated_file).status();
for proto in &protos {
println!("cargo:rerun-if-changed={proto}");
}
}