build.rs 1.3 KB

1234567891011121314151617181920212223242526272829
  1. use std::path::PathBuf;
  2. /// Custom build script to compile and include the wormhole protobufs into the source.
  3. /// The wormhole protobufs are vendored from the Wormhole git repository at https://github.com/wormhole-foundation/wormhole.git
  4. /// They reference other protobufs from the Google API repository at https://github.com/googleapis/googleapis.git , which are also vendored.
  5. /// Our copies live in `proto/vendor`.
  6. fn main() {
  7. let proto_dir = PathBuf::from("proto/vendor");
  8. // Tell cargo to recompile if any .proto files change
  9. println!("cargo:rerun-if-changed=proto/");
  10. // Build the wormhole and google protobufs using Rust's prost_build crate.
  11. // The generated Rust code is placed in the OUT_DIR (env var set by cargo).
  12. // `network/wormhole.rs` then includes the generated code into the source while compilation is happening.
  13. #[allow(clippy::expect_used, reason = "failing at build time is fine")]
  14. tonic_build::configure()
  15. .build_server(false)
  16. .compile(
  17. &[
  18. proto_dir.join("spy/v1/spy.proto"),
  19. proto_dir.join("gossip/v1/gossip.proto"),
  20. proto_dir.join("node/v1/node.proto"),
  21. proto_dir.join("publicrpc/v1/publicrpc.proto"),
  22. ],
  23. &[proto_dir],
  24. )
  25. .expect("failed to compile protobuf definitions");
  26. }