2017-04-07 12:20:32 +00:00
|
|
|
extern crate bindgen;
|
|
|
|
extern crate pkg_config;
|
2016-01-25 05:56:11 +00:00
|
|
|
|
2016-08-04 03:36:52 +00:00
|
|
|
use std::env;
|
2017-04-07 12:20:32 +00:00
|
|
|
use std::path::PathBuf;
|
2016-01-25 05:56:11 +00:00
|
|
|
|
2017-04-07 12:20:32 +00:00
|
|
|
const MIN_VERSION: &'static str = "6.9";
|
|
|
|
const MAX_VERSION: &'static str = "6.10";
|
2016-10-16 18:00:06 +00:00
|
|
|
|
2015-12-23 19:34:51 +00:00
|
|
|
fn main() {
|
2017-04-07 12:20:32 +00:00
|
|
|
let library = pkg_config::Config::new()
|
|
|
|
.atleast_version(MIN_VERSION)
|
|
|
|
.arg(format!("--max-version={}", MAX_VERSION))
|
|
|
|
.probe("MagickWand")
|
|
|
|
.unwrap();
|
|
|
|
let mut builder = bindgen::Builder::default()
|
|
|
|
.no_unstable_rust()
|
|
|
|
.emit_builtins()
|
|
|
|
.ctypes_prefix("libc")
|
|
|
|
.raw_line("extern crate libc;")
|
|
|
|
.header("wrapper.h");
|
|
|
|
for include_path in library.include_paths {
|
|
|
|
builder = builder.clang_arg(format!("-I{}", include_path.to_string_lossy()));
|
2016-01-25 05:56:11 +00:00
|
|
|
}
|
2017-04-07 12:20:32 +00:00
|
|
|
let bindings = builder.generate().unwrap();
|
|
|
|
let outfile = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
bindings.write_to_file(outfile.join("bindings.rs")).unwrap();
|
2015-12-23 19:34:51 +00:00
|
|
|
}
|