extern crate bindgen;
extern crate pkg_config;
mod csource;
const NC_VERSION: &str = "3.0.7";
fn main() {
let nc_src = csource::NcCSource::new(NC_VERSION);
if cfg!(feature = "vendor_csource") {
nc_src.vendor_csource();
}
if cfg!(feature = "keep_vendored") {
} else {
nc_src.delete_vendored();
}
if cfg!(feature = "compile_csource") {
nc_src.compile_csource();
}
if cfg!(feature = "use_vendored_bindings") {
nc_src.use_vendored_bindings();
} else {
let plib = pkg_config::Config::new()
.atleast_version(NC_VERSION)
.probe("notcurses")
.expect("pkg-config couldn't find the notcurses library");
println!("cargo:rerun-if-changed=build/wrapper.h");
let mut builder = bindgen::Builder::default()
.use_core()
.ctypes_prefix("cty")
.clang_arg("-D_XOPEN_SOURCE")
.clang_arg(&nc_src.headers_include_string())
.header("build/wrapper.h")
.generate_comments(true)
.clang_arg("-fretain-comments-from-system-headers")
.clang_arg("-fparse-all-comments")
.size_t_is_usize(true)
.blocklist_function("strtold")
.blocklist_function("wcstold")
.blocklist_function("socketpair")
.blocklist_function("[^ns].*")
.blocklist_function("n[^co].*")
.blocklist_function("s[^i].*") .blocklist_item("B[0-9]+")
.blocklist_item("_BITS.*")
.blocklist_item("_POSIX.*")
.blocklist_item("__[A-Z].*")
.blocklist_item("[ADHJ-MQ-Z].*")
.blocklist_item("IN.*")
.blocklist_item("IP[^R].*")
.blocklist_item("ip.*")
.blocklist_item("m.*")
.blocklist_item("PF.*")
.blocklist_item("MSG_.*")
.blocklist_item("N[^C].*")
.blocklist_type("_bindgen.*")
.layout_tests(false)
.no_copy("ncdirect")
.no_copy("ncdplot")
.no_copy("ncfdplane")
.no_copy("ncmenu")
.no_copy("ncmenu_item")
.no_copy("ncmenu_section")
.no_copy("ncmenu_options")
.no_copy("ncmultiselector")
.no_copy("ncmultiselector_options")
.no_copy("ncmselector_item")
.no_copy("ncplane")
.no_copy("ncplane_options")
.no_copy("ncprogbar")
.no_copy("ncreader")
.no_copy("ncreel")
.no_copy("ncselector")
.no_copy("ncselector_item")
.no_copy("ncselector_options")
.no_copy("ncuplot")
.no_copy("ncdplot")
.no_copy("ncsubproc")
.no_copy("nctab")
.no_copy("nctabbed")
.no_copy("nctabbed_options")
.no_copy("nctree")
.no_copy("nctree_item")
.no_copy("nctree_options")
.no_copy("ncvisual")
.no_copy("ncvisual_options")
.no_copy("notcurses")
.no_copy("notcurses_options")
.no_partialeq("ncinput")
.derive_default(true)
.derive_hash(true)
.derive_partialord(true)
.derive_ord(true)
.derive_partialeq(true)
.derive_eq(true)
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
for d in plib.include_paths {
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
}
let bindings = builder.generate().expect("Unable to generate bindings");
bindings
.write_to_file(nc_src.deployed_bindings())
.expect("Couldn't write bindings!");
if cfg!(feature = "vendor_bindings") {
nc_src.vendor_bindings();
}
}
}