use std::env;
fn infer_static(name: &str) -> bool {
#[allow(clippy::if_same_then_else, clippy::needless_bool)]
if env::var(format!("{}_STATIC", name.to_uppercase())).is_ok() {
true
} else if env::var(format!("{}_DYNAMIC", name.to_uppercase())).is_ok() {
false
} else if env::var("PKG_CONFIG_ALL_STATIC").is_ok() {
true
} else if env::var("PKG_CONFIG_ALL_DYNAMIC").is_ok() {
false
} else {
false
}
}
fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
if env::var("MWALIB_LINK_STATIC_CFITSIO") == Ok("1".to_string()) || infer_static("cfitsio") {
println!("cargo:rustc-link-lib=static=cfitsio");
}
match env::var("DOCS_RS").as_deref() {
Ok("1") => (),
_ => {
cbindgen::Builder::new()
.with_config(cbindgen::Config {
cpp_compat: true,
pragma_once: true,
..Default::default()
})
.include_item("VisPol")
.with_crate(env::var("CARGO_MANIFEST_DIR").unwrap())
.with_language(cbindgen::Language::C)
.generate()
.expect("Unable to generate bindings")
.write_to_file("include/mwalib.h");
}
}
}