Merge remote-tracking branch 'origin/master'

This commit is contained in:
0/0 2023-02-08 16:19:12 -07:00
commit 7350453ffe
No known key found for this signature in database
GPG key ID: 3861E636EA1E0E2B
3 changed files with 116 additions and 1 deletions

View file

@ -6,6 +6,16 @@ use std::env;
use std::path::PathBuf;
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-lib=static=whisper");
println!("cargo:rerun-if-changed=wrapper.h");
@ -68,3 +78,20 @@ fn main() {
.status()
.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++")
}
}