fn main() {
let proto_dir = "../arcbox-protocol/proto";
let protos = [
"common.proto",
"machine.proto",
"macos.proto",
"container.proto",
"image.proto",
"agent.proto",
"api.proto",
"kubernetes.proto",
"stats.proto",
"arcbox/sandbox/v1/sandbox.proto",
"arcbox/sandbox/v1/process.proto",
"arcbox/sandbox/v1/filesystem.proto",
"arcbox/sandbox/v1/snapshot.proto",
"arcbox/sandbox/v1/template.proto",
"arcbox/sandbox/v1/errors.proto",
];
let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").expect("OUT_DIR unset"));
let descriptor = out_dir.join("arcbox_connect.protoset");
let protoc = std::env::var("PROTOC").unwrap_or_else(|_| "protoc".to_string());
let status = std::process::Command::new(&protoc)
.arg("--experimental_allow_proto3_optional")
.arg("--include_imports")
.arg("--include_source_info")
.arg(format!("--descriptor_set_out={}", descriptor.display()))
.arg(format!("--proto_path={proto_dir}"))
.args(protos)
.status()
.unwrap_or_else(|e| panic!("failed to invoke {protoc}: {e}"));
assert!(
status.success(),
"protoc failed building the Connect descriptor set"
);
for proto in protos {
println!("cargo:rerun-if-changed={proto_dir}/{proto}");
}
connectrpc_build::Config::new()
.files(&protos)
.descriptor_set(&descriptor)
.emit_rerun_directives(false)
.include_file("_connectrpc.rs")
.generate_json(true)
.file_per_package(true)
.compile()
.expect("Failed to compile protos for Connect");
}