use std::env; use std::path::PathBuf; fn main() { println!("cargo:rerun-if-changed=curses.h"); if cfg!(not(target_os = "macos")) { println!("cargo:rustc-link-lib=ncursesw"); } else { println!("cargo:rustc-link-lib=ncurses"); } let bindings = bindgen::Builder::default() .header("curses.h") .allowlist_var("ERR") .allowlist_type("WINDOW") .allowlist_function("doupdate") .allowlist_function("endwin") .allowlist_function("initscr") .allowlist_function("isendwin") .allowlist_function("wrefresh") .allowlist_function("wnoutrefresh") .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .merge_extern_blocks(true) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("curses.rs")) .expect("Couldn't write bindings!"); }