File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub(crate) struct Env {
3434 pub ( crate ) opt_level : Option < OsString > ,
3535 pub ( crate ) android_ndk_home : Option < PathBuf > ,
3636 pub ( crate ) cmake_toolchain_file : Option < PathBuf > ,
37+ pub ( crate ) cpp_runtime_lib : Option < OsString > ,
3738}
3839
3940impl Config {
@@ -164,6 +165,7 @@ impl Env {
164165 opt_level : target_var ( "OPT_LEVEL" ) ,
165166 android_ndk_home : target_var ( "ANDROID_NDK_HOME" ) . map ( Into :: into) ,
166167 cmake_toolchain_file : target_var ( "CMAKE_TOOLCHAIN_FILE" ) . map ( Into :: into) ,
168+ cpp_runtime_lib : target_var ( "BORING_BSSL_RUST_CPPLIB" ) . map ( Into :: into) ,
167169 }
168170 }
169171}
Original file line number Diff line number Diff line change 11use fslock:: LockFile ;
2+ use std:: env;
23use std:: ffi:: OsString ;
34use std:: fs;
45use std:: io;
@@ -636,6 +637,22 @@ fn link_in_precompiled_bcm_o(config: &Config) {
636637 . unwrap ( ) ;
637638}
638639
640+ fn get_cpp_runtime_lib ( config : & Config ) -> Option < String > {
641+ if let Some ( ref cpp_lib) = config. env . cpp_runtime_lib {
642+ return cpp_lib. clone ( ) . into_string ( ) . ok ( ) ;
643+ }
644+
645+ // TODO(rmehra): figure out how to do this for windows
646+ if env:: var_os ( "CARGO_CFG_UNIX" ) . is_some ( ) {
647+ match env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap ( ) . as_ref ( ) {
648+ "macos" | "ios" => Some ( "c++" . into ( ) ) ,
649+ _ => Some ( "stdc++" . into ( ) ) ,
650+ }
651+ } else {
652+ None
653+ }
654+ }
655+
639656fn main ( ) {
640657 let config = Config :: from_env ( ) ;
641658 let bssl_dir = built_boring_source_path ( & config) ;
@@ -673,6 +690,9 @@ fn main() {
673690 link_in_precompiled_bcm_o ( & config) ;
674691 }
675692
693+ if let Some ( cpp_lib) = get_cpp_runtime_lib ( & config) {
694+ println ! ( "cargo:rustc-link-lib={}" , cpp_lib) ;
695+ }
676696 println ! ( "cargo:rustc-link-lib=static=crypto" ) ;
677697 println ! ( "cargo:rustc-link-lib=static=ssl" ) ;
678698
You can’t perform that action at this time.
0 commit comments