use std::env;
use std::path::PathBuf;
fn main() {
let libuvc = pkg_config::Config::new()
.atleast_version("0.0.7")
.probe("libuvc")
.expect("pkg-config probe libuvc");
let libuvc_h = libuvc
.include_paths
.into_iter()
.filter_map(|mut p| {
p.push("libuvc");
p.push("libuvc.h");
if p.exists() { Some(p) } else { None }
})
.next()
.expect("find libuvc headers");
let libuvc_h = libuvc_h.to_str().expect("libuvc header path is utf-8");
let bindings = bindgen::Builder::default()
.allowlist_recursively(false)
.allowlist_file(".*libuvc.h")
.header(libuvc_h)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("couldn't write bindings!");
}