build.rs 761 B

123456789101112131415161718192021222324252627
  1. extern crate vergen;
  2. #[cfg(feature = "with-syntex")] extern crate syntex;
  3. #[cfg(feature = "with-syntex")] extern crate json_macros;
  4. #[cfg(feature = "with-syntex")] extern crate protobuf_macros;
  5. #[cfg(feature = "with-syntex")]
  6. fn codegen() {
  7. use std::env;
  8. use std::path::PathBuf;
  9. use std::path::Path;
  10. let mut registry = syntex::Registry::new();
  11. let out = PathBuf::from(env::var("OUT_DIR").unwrap());
  12. json_macros::plugin_registrar(&mut registry);
  13. protobuf_macros::plugin_registrar(&mut registry);
  14. registry.expand("librespot", Path::new("src/lib.in.rs"), &out.join("lib.rs")).unwrap();
  15. }
  16. #[cfg(not(feature = "with-syntex"))]
  17. fn codegen() { }
  18. fn main() {
  19. vergen::vergen(vergen::OutputFns::all()).unwrap();
  20. codegen();
  21. }