use prost::Message;
use std::path::PathBuf;
fn main() {
let proto = "proto/onnx.proto3";
println!("cargo:rerun-if-changed={proto}");
println!("cargo:rerun-if-changed=build.rs");
let file_descriptors = protox::compile([proto], ["proto"])
.expect("failed to compile proto/onnx.proto3 with protox");
let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR not set"));
std::fs::write(
out_dir.join("onnx_descriptor.bin"),
file_descriptors.encode_to_vec(),
)
.expect("failed to write ONNX descriptor set");
prost_build::Config::new()
.out_dir(&out_dir)
.compile_fds(file_descriptors)
.expect("prost-build failed to generate ONNX types");
}