vlc-rs/libvlc-sys/build.rs

35 lines
1.0 KiB
Rust
Raw Normal View History

2019-11-21 11:00:26 +00:00
use bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=wrapper.h");
2019-12-15 05:22:50 +00:00
let mut bindings = bindgen::Builder::default()
2019-11-21 11:00:26 +00:00
.header("wrapper.h")
// For no_std
.use_core()
// Use libc
.ctypes_prefix("libc")
2019-11-23 11:21:35 +00:00
// Whitelist
.whitelist_type(".*vlc.*")
.whitelist_function(".*vlc.*")
.whitelist_var(".*vlc.*")
.whitelist_function("vsnprintf")
2019-12-15 05:22:50 +00:00
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
// Set header include paths
let pkg_config_library = pkg_config::Config::new().probe("libvlc").unwrap();
for include_path in &pkg_config_library.include_paths {
bindings = bindings.clang_arg(format!("-I{}", include_path.display()));
}
let bindings = bindings.generate().expect("Unable to generate bindings");
2019-11-21 11:00:26 +00:00
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}