()
| 17 | } |
| 18 | |
| 19 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 20 | #[cfg(feature = "node")] |
| 21 | napi_build::setup(); |
| 22 | let manifest = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?); |
| 23 | let proto_root = manifest.join("proto"); |
| 24 | let mut files = Vec::new(); |
| 25 | collect_protos(&proto_root, &mut files); |
| 26 | assert!( |
| 27 | !files.is_empty(), |
| 28 | "no protos found under {}", |
| 29 | proto_root.display() |
| 30 | ); |
| 31 | |
| 32 | // protox is a pure-Rust protoc replacement: no system protoc dependency. |
| 33 | // The include root carries `atomic/...`, matching the imports |
| 34 | // (`atomic/common/common.proto`). |
| 35 | let fds = protox::compile(&files, [proto_root.clone()])?; |
| 36 | // Foreign-language bindings generate their types from this exact contract, |
| 37 | // without carrying a second copy of the protobuf sources. |
| 38 | let out = PathBuf::from(std::env::var("OUT_DIR")?); |
| 39 | std::fs::write(out.join("atomic_descriptor.bin"), fds.encode_to_vec())?; |
| 40 | println!("cargo:rerun-if-changed={}", proto_root.display()); |
| 41 | |
| 42 | tonic_build::configure() |
| 43 | .build_client(true) |
| 44 | .build_server(true) |
| 45 | .compile_fds(fds)?; |
| 46 | Ok(()) |
| 47 | } |
nothing calls this directly
no test coverage detected