Link against C++ standard library and macOS Accelerate framework
This commit is contained in:
parent
b81c6c9454
commit
15dbd58c7e
27
sys/build.rs
27
sys/build.rs
|
@ -4,6 +4,16 @@ use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let target = env::var("TARGET").unwrap();
|
||||||
|
// Link C++ standard library
|
||||||
|
if let Some(cpp_stdlib) = get_cpp_link_stdlib(&target) {
|
||||||
|
println!("cargo:rustc-link-lib=dylib={}", cpp_stdlib);
|
||||||
|
}
|
||||||
|
// Link macOS Accelerate framework for matrix calculations
|
||||||
|
if target.contains("apple") {
|
||||||
|
println!("cargo:rustc-link-lib=framework=Accelerate");
|
||||||
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-search={}", env::var("OUT_DIR").unwrap());
|
println!("cargo:rustc-link-search={}", env::var("OUT_DIR").unwrap());
|
||||||
println!("cargo:rustc-link-lib=static=whisper");
|
println!("cargo:rustc-link-lib=static=whisper");
|
||||||
println!("cargo:rerun-if-changed=wrapper.h");
|
println!("cargo:rerun-if-changed=wrapper.h");
|
||||||
|
@ -66,3 +76,20 @@ fn main() {
|
||||||
.status()
|
.status()
|
||||||
.expect("Failed to clean whisper build directory");
|
.expect("Failed to clean whisper build directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// From https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
|
||||||
|
fn get_cpp_link_stdlib(target: &str) -> Option<&'static str> {
|
||||||
|
if target.contains("msvc") {
|
||||||
|
None
|
||||||
|
} else if target.contains("apple") {
|
||||||
|
Some("c++")
|
||||||
|
} else if target.contains("freebsd") {
|
||||||
|
Some("c++")
|
||||||
|
} else if target.contains("openbsd") {
|
||||||
|
Some("c++")
|
||||||
|
} else if target.contains("android") {
|
||||||
|
Some("c++_shared")
|
||||||
|
} else {
|
||||||
|
Some("stdc++")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue