Files

28 lines
1.0 KiB
Rust
Raw Permalink Normal View History

2026-05-12 13:44:53 -07:00
fn main() {
let proto_file = "proto/hello.proto";
let out_dir = std::env::var("OUT_DIR").unwrap();
let dest_path = std::path::Path::new(&out_dir).join("hello.rs");
// Find the protoc-gen-roto binary
// Since we added roto-codegen to build-dependencies, it will be built.
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let target_dir = std::path::Path::new(&manifest_dir).join("../../target/debug");
2026-05-12 13:44:53 -07:00
let plugin_path = target_dir.join("protoc-gen-roto");
if !plugin_path.exists() {
panic!("protoc-gen-roto plugin not found at {:?}", plugin_path);
}
let status = std::process::Command::new("protoc")
.arg(format!("--plugin=protoc-gen-roto={}", plugin_path.display()))
.arg(format!("--roto_out={}", out_dir))
.arg(format!("--roto_opt=src=proto")) // Assuming the plugin handles this or we just pass it
.arg(proto_file)
.status()
.expect("Failed to execute protoc");
if !status.success() {
panic!("protoc failed with status {}", status);
}
}