Handle building on macos a little better
First, only add the special environment variable when building on Mac OS X. Second, look for the path to ensure the Xcode command line tools are installed, and panic if that is not the case. cargo test passes
This commit is contained in:
30
build.rs
30
build.rs
@ -21,6 +21,7 @@ use std::path::Path;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
static HEADER: &'static str = "#include <wand/MagickWand.h>\n";
|
static HEADER: &'static str = "#include <wand/MagickWand.h>\n";
|
||||||
|
static LIBPATH: &'static str = "/Library/Developer/CommandLineTools/usr/lib";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
//
|
//
|
||||||
@ -69,17 +70,24 @@ fn main() {
|
|||||||
let mw_ldflags = std::str::from_utf8(&mw_ldflags_output.stdout).unwrap().trim();
|
let mw_ldflags = std::str::from_utf8(&mw_ldflags_output.stdout).unwrap().trim();
|
||||||
let mw_ldflags_arr: Vec<&str> = mw_ldflags.split_whitespace().collect();
|
let mw_ldflags_arr: Vec<&str> = mw_ldflags.split_whitespace().collect();
|
||||||
// Combine all of that in the invocation of rust-bindgen.
|
// Combine all of that in the invocation of rust-bindgen.
|
||||||
Command::new("./rust-bindgen/target/debug/bindgen")
|
let mut cmd = &mut Command::new("./rust-bindgen/target/debug/bindgen");
|
||||||
// always include this even though it only makes sense on Mac to
|
if cfg!(target_os = "macos") {
|
||||||
// work around https://github.com/crabtw/rust-bindgen/issues/89
|
// Mac requires that the xcode tools are installed so that
|
||||||
.env("DYLD_LIBRARY_PATH", "/Library/Developer/CommandLineTools/usr/lib")
|
// rustc can find the clang.dylib file. See also issue
|
||||||
.args(&mw_cflags_arr[..])
|
// https://github.com/crabtw/rust-bindgen/issues/89
|
||||||
.arg("-builtins")
|
let lib_path = Path::new(LIBPATH);
|
||||||
.arg("-o")
|
if !lib_path.exists() {
|
||||||
.arg("src/bindings.rs")
|
panic!("missing {}, run xcode-select --install", LIBPATH);
|
||||||
.args(&mw_ldflags_arr[..])
|
}
|
||||||
.arg("gen.h")
|
cmd.env("DYLD_LIBRARY_PATH", LIBPATH);
|
||||||
.status().unwrap();
|
}
|
||||||
|
cmd.args(&mw_cflags_arr[..])
|
||||||
|
.arg("-builtins")
|
||||||
|
.arg("-o")
|
||||||
|
.arg("src/bindings.rs")
|
||||||
|
.args(&mw_ldflags_arr[..])
|
||||||
|
.arg("gen.h")
|
||||||
|
.status().unwrap();
|
||||||
// how to get the output of the command...
|
// how to get the output of the command...
|
||||||
// let output = Commad::new(...).output().unwrap();
|
// let output = Commad::new(...).output().unwrap();
|
||||||
// let out = std::str::from_utf8(&output.stdout).unwrap();
|
// let out = std::str::from_utf8(&output.stdout).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user