File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ use std::env;
4
4
use std:: path:: PathBuf ;
5
5
6
6
fn main ( ) {
7
+ let target = env:: var ( "TARGET" ) . unwrap ( ) ;
8
+ // Link C++ standard library
9
+ if let Some ( cpp_stdlib) = get_cpp_link_stdlib ( & target) {
10
+ println ! ( "cargo:rustc-link-lib=dylib={}" , cpp_stdlib) ;
11
+ }
12
+ // Link macOS Accelerate framework for matrix calculations
13
+ if target. contains ( "apple" ) {
14
+ println ! ( "cargo:rustc-link-lib=framework=Accelerate" ) ;
15
+ }
16
+
7
17
println ! ( "cargo:rustc-link-search={}" , env:: var( "OUT_DIR" ) . unwrap( ) ) ;
8
18
println ! ( "cargo:rustc-link-lib=static=whisper" ) ;
9
19
println ! ( "cargo:rerun-if-changed=wrapper.h" ) ;
@@ -66,3 +76,20 @@ fn main() {
66
76
. status ( )
67
77
. expect ( "Failed to clean whisper build directory" ) ;
68
78
}
79
+
80
+ // From https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
81
+ fn get_cpp_link_stdlib ( target : & str ) -> Option < & ' static str > {
82
+ if target. contains ( "msvc" ) {
83
+ None
84
+ } else if target. contains ( "apple" ) {
85
+ Some ( "c++" )
86
+ } else if target. contains ( "freebsd" ) {
87
+ Some ( "c++" )
88
+ } else if target. contains ( "openbsd" ) {
89
+ Some ( "c++" )
90
+ } else if target. contains ( "android" ) {
91
+ Some ( "c++_shared" )
92
+ } else {
93
+ Some ( "stdc++" )
94
+ }
95
+ }
You can’t perform that action at this time.
0 commit comments