fn main() {
println!("cargo:rerun-if-changed=build.rs");
let fcft = pkg_config::Config::new()
.atleast_version("3.0.0")
.probe("fcft")
.expect("fcft >= 3.0 should be installed and discoverable via pkg-config (fcft-dev)");
let pixman = pkg_config::probe_library("pixman-1")
.expect("pixman-1 should be installed and discoverable via pkg-config (pixman-dev)");
let clang_args = fcft
.include_paths
.iter()
.chain(pixman.include_paths.iter())
.map(|p| format!("-I{}", p.display()))
.chain(
fcft.defines
.iter()
.chain(pixman.defines.iter())
.map(|(k, v)| match v {
Some(v) => format!("-D{k}={v}"),
None => format!("-D{k}"),
}),
);
let bindings = bindgen::Builder::default()
.header_contents("wrapper.h", "#include <fcft/fcft.h>\n")
.clang_args(clang_args)
.allowlist_function("fcft_.*")
.allowlist_type("fcft_.*")
.allowlist_var("FCFT_.*")
.blocklist_function("fcft_set_scaling_filter")
.blocklist_function("fcft_set_emoji_presentation")
.allowlist_function("pixman_image_get_format")
.allowlist_function("pixman_image_get_data")
.allowlist_function("pixman_image_get_stride")
.allowlist_function("pixman_image_get_width")
.allowlist_function("pixman_image_get_height")
.allowlist_function("pixman_image_create_bits_no_clear")
.allowlist_function("pixman_image_create_solid_fill")
.allowlist_function("pixman_image_composite32")
.allowlist_function("pixman_image_unref")
.allowlist_function("pixman_image_set_component_alpha")
.generate()
.expect("bindgen should generate bindings for <fcft/fcft.h>");
let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out.join("bindings.rs"))
.expect("bindings should be written to OUT_DIR");
}