use std::path::PathBuf;
use pkg_config::Config;
fn main() {
if std::env::var("CARGO_DOC").is_ok() {
return;
}
if std::env::var("CARGO_CFG_UNIX").is_err() {
return;
}
if std::env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "arm" {
return;
}
Config::new()
.atleast_version("60")
.probe("libavcodec")
.unwrap();
Config::new()
.atleast_version("58")
.probe("libavutil")
.unwrap();
Config::new()
.atleast_version("7")
.probe("libswscale")
.unwrap();
let bindings = bindgen::Builder::default()
.header("src/bindings.h")
.allowlist_function("av_.*")
.allowlist_function("avcodec_.*")
.allowlist_function("sws_.*")
.allowlist_function("av_image_.*")
.allowlist_var("AV_PROFILE.*")
.allowlist_var("AV_.*")
.allowlist_var("AVERROR_.*")
.blocklist_type(".*va_list.*")
.blocklist_function("av_log_.*")
.blocklist_function("av_vlog")
.generate()
.expect("failed to generate bindings");
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("writing bindings to file failed");
}