extern crate bindgen; use std::env; use std::path::PathBuf; use bindgen::Bindings; fn main() { // Tell cargo to tell rustc to link the system bzip2 // shared library. println!("cargo:rustc-link-lib=glfw"); let bindings = bindgen::Builder::default(); let finalb:Bindings; // Tell cargo to invalidate the built crate whenever the wrapper changes #[cfg(feature = "wayland")] { println!("cargo:rerun-if-changed=wayland.h"); finalb=bindings.header("wayland.h").generate().expect("failed to generate wayland bindings"); } #[cfg(feature = "x11")] { println!("cargo:rerun-if-changed=x11.h"); finalb=bindings.header("x11.h").generate().expect("failed to generate x11 bindings"); } // Write the bindings to the $OUT_DIR/bindings.rs file. let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); finalb .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); }