magick-rust/build.rs

29 lines
891 B
Rust
Raw Normal View History

2017-04-07 12:20:32 +00:00
extern crate bindgen;
extern crate pkg_config;
use std::env;
2017-04-07 12:20:32 +00:00
use std::path::PathBuf;
2017-04-07 12:20:32 +00:00
const MIN_VERSION: &'static str = "6.9";
const MAX_VERSION: &'static str = "6.10";
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()));
}
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();
}