build.rs 623 B

1234567891011121314151617181920
  1. use std::error::Error;
  2. fn main() -> Result<(), Box<dyn Error>> {
  3. #[cfg(all(feature = "call", not(feature = "vdso")))]
  4. {
  5. let config = cbindgen::Config::from_file("cbindgen.toml")?;
  6. println!("cargo:rerun-if-changed=cbindgen.toml");
  7. let src_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
  8. let bindings = cbindgen::Builder::new()
  9. .with_config(config)
  10. .with_crate(".")
  11. .generate()?;
  12. let c_target_path = src_dir.join("../../../target/sysroot/usr/include/h2o.h");
  13. bindings.write_to_file(c_target_path);
  14. }
  15. Ok(())
  16. }