#[cfg(feature = "protobuf")]
mod proto_build {
use std::env;
use std::path::PathBuf;
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
let proto_dir = manifest_dir.join("proto/cursor");
let proto_file = proto_dir.join("agent.proto");
assert!(
proto_file.exists(),
"Cursor agent.proto missing at {}",
proto_file.display()
);
let protoc_path = protoc_bin_vendored::protoc_bin_path()
.expect("protoc-bin-vendored failed to locate bundled protoc");
unsafe {
env::set_var("PROTOC", &protoc_path);
}
let mut config = prost_build::Config::new();
config.protoc_arg("--experimental_allow_proto3_optional");
config.compile_protos(&[&proto_file], &[&proto_dir])?;
println!("cargo:rerun-if-changed={}", proto_file.display());
Ok(())
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=build.rs");
#[cfg(feature = "protobuf")]
{
proto_build::run()?;
}
Ok(())
}