build.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. //! Builds libthreema (d'oh!).
  2. use std::{env, io::Result};
  3. #[cfg(feature = "uniffi")]
  4. use uniffi as _;
  5. fn main() -> Result<()> {
  6. // Configure and compile protobuf
  7. println!("cargo:rerun-if-changed=../threema-protocols/src/");
  8. let mut builder = prost_build::Config::new();
  9. let builder = builder
  10. .message_attribute(".", "#[libthreema_macros::protobuf_annotations]")
  11. .enable_type_names();
  12. let builder = if env::var("CARGO_FEATURE_CLI").is_ok() {
  13. // For the CLI, we want to be able to parse some enums via clap.
  14. builder.enum_attribute(".d2m.DeviceSlotState", "#[derive(clap::ValueEnum)]")
  15. } else {
  16. builder
  17. };
  18. builder.compile_protos(
  19. &[
  20. "../threema-protocols/src/common.proto",
  21. "../threema-protocols/src/csp-e2e.proto",
  22. "../threema-protocols/src/md-d2d.proto",
  23. "../threema-protocols/src/md-d2d-sync.proto",
  24. "../threema-protocols/src/md-d2d-rendezvous.proto",
  25. "../threema-protocols/src/md-d2m.proto",
  26. ],
  27. &["../threema-protocols/src/"],
  28. )?;
  29. // Done
  30. Ok(())
  31. }