#![expect(clippy::exit)]
pub const FILE_DESCRIPTOR_SET_FILE_NAME: &str = "rerun.v1alpha1.fds.bin";
pub fn generate_rust_code<P>(definitions_dir: P, proto_paths: &[P], output_dir: &P)
where
P: AsRef<std::path::Path>,
{
let mut prost_config = tonic_prost_build::Config::new();
prost_config.enable_type_names(); prost_config.file_descriptor_set_path(output_dir.as_ref().join(FILE_DESCRIPTOR_SET_FILE_NAME));
prost_config.bytes([
".rerun.common.v1alpha1",
".rerun.cloud.v1alpha1",
".rerun.log_msg.v1alpha1",
".rerun.manifest_registry.v1alpha1",
]);
if let Err(err) = tonic_prost_build::configure()
.out_dir(output_dir)
.build_client(true)
.build_server(true)
.build_transport(false) .compile_with_config(prost_config, proto_paths, &[definitions_dir])
{
match err.kind() {
std::io::ErrorKind::Other => {
eprintln!("Failed to generate protobuf types:\n{err}");
std::process::exit(1);
}
_ => {
panic!("{err}");
}
}
}
}