Hack to get build working on FreeBSD again
Due to a bug in rust-bindgen, use the bindings as generated on the Mac for the same version of MagickWand as found on FreeBSD. That is, when build.rs is invoked on a FreeBSD system, it will use the Mac-generated bindings.rs rather than pulling down rust-bindgen and invoking it to generate the bindings on the fly. See issue #385 in the rust-bindgen project for details. cargo test passes
This commit is contained in:
8097
bindings.rs
Normal file
8097
bindings.rs
Normal file
File diff suppressed because it is too large
Load Diff
30
build.rs
30
build.rs
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::fs::{copy, File};
|
||||
use std::io::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
@ -23,14 +23,7 @@ use std::process::Command;
|
||||
static HEADER: &'static str = "#include <wand/MagickWand.h>\n";
|
||||
static LIBPATH: &'static str = "/Library/Developer/CommandLineTools/usr/lib";
|
||||
|
||||
fn main() {
|
||||
//
|
||||
// If the MagickWand bindings are missing, generate them using
|
||||
// rust-bindgen.
|
||||
//
|
||||
let out_dir = ::std::env::var("OUT_DIR").unwrap();
|
||||
let bindings_path_str = out_dir.clone() + "/bindings.rs";
|
||||
if !Path::new(&bindings_path_str).exists() {
|
||||
fn run_bindgen(out_dir: String, bindings_path_str: &str) {
|
||||
// Install rust-bindgen so we can generate the bindings. While the
|
||||
// bindgen crate is nice, it does not appear to support setting
|
||||
// environment variables like DYLD_LIBRARY_PATH.
|
||||
@ -121,7 +114,26 @@ fn main() {
|
||||
println!("BINDING_GENERATION={:?}", cmd);
|
||||
cmd.status().expect("rust-bindgen invocation");
|
||||
std::fs::remove_file(&gen_h_path).expect("could not remove header file");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
//
|
||||
// If the MagickWand bindings are missing, generate them using
|
||||
// rust-bindgen.
|
||||
//
|
||||
let out_dir = ::std::env::var("OUT_DIR").unwrap();
|
||||
let bindings_path_str = out_dir.clone() + "/bindings.rs";
|
||||
if !Path::new(&bindings_path_str).exists() {
|
||||
// Either generate the bindings.rs or copy an already generated
|
||||
// version for FreeBSD. See rust-bindgen issue #385 for details. We
|
||||
// also need to hack the library path to `cargo test` can find the
|
||||
// MagickWand libraries.
|
||||
if cfg!(target_os = "freebsd") {
|
||||
copy("bindings.rs", &bindings_path_str).expect("cp bindings.rs to out_dir");
|
||||
println!("cargo:rustc-link-search=native=/usr/local/lib");
|
||||
} else {
|
||||
run_bindgen(out_dir, &bindings_path_str);
|
||||
}
|
||||
// Work around the include! issue in rustc (as described in the
|
||||
// rust-bindgen README file) by wrapping the generated code in a
|
||||
// `pub mod` declaration; see issue #359 in rust-bindgen.
|
||||
|
||||
Reference in New Issue
Block a user