build.rs 666 B

123456789101112131415161718192021
  1. use std::io::Result;
  2. use fs_err::read_dir;
  3. /// Automatically runs during cargo build.
  4. /// Proto files for Lazer are defined in the lazer sdk folder in the proto/ subdirectory.
  5. /// Both JS and Rust SDKs read the proto files for generating types.
  6. fn main() -> Result<()> {
  7. // Tell cargo to recompile if any .proto files change
  8. println!("cargo:rerun-if-changed=../proto/");
  9. protobuf_codegen::Codegen::new()
  10. .protoc()
  11. .protoc_extra_arg("--include_source_info")
  12. .include("../proto")
  13. .inputs(read_dir("../proto")?.map(|item| item.unwrap().path()))
  14. .cargo_out_dir("protobuf")
  15. .run_from_script();
  16. Ok(())
  17. }