File tree Expand file tree Collapse file tree
wrapper/rust/wolfssl-wolfcrypt Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use regex::Regex;
44use std:: env;
55use std:: fs;
66use std:: io:: { self , Read , Result } ;
7- use std:: path:: PathBuf ;
7+ use std:: path:: { Path , PathBuf } ;
88
99/// Perform crate build.
1010fn main ( ) {
@@ -69,12 +69,19 @@ fn generate_bindings() -> Result<()> {
6969/// Returns `Ok(())` if successful, or an error if any step fails.
7070fn setup_wolfssl_link ( ) -> Result < ( ) > {
7171 println ! ( "cargo:rustc-link-lib=wolfssl" ) ;
72- println ! ( "cargo:rustc-link-search={}" , wolfssl_lib_dir( ) ?) ;
73- println ! ( "cargo:rustc-link-arg=-Wl,-rpath,{}" , wolfssl_lib_dir( ) ?) ;
7472
7573// TODO: do we need this if only a static library is built?
7674// println!("cargo:rustc-link-lib=static=wolfssl");
7775
76+ let build_in_repo = Path :: new ( & wolfssl_lib_dir ( ) ?) . exists ( ) ;
77+ if build_in_repo {
78+ // When the crate is built in the wolfssl repository, link with the
79+ // locally build wolfssl library to allow testing any local changes
80+ // and running unit tests even if library is not installed.
81+ println ! ( "cargo:rustc-link-search={}" , wolfssl_lib_dir( ) ?) ;
82+ println ! ( "cargo:rustc-link-arg=-Wl,-rpath,{}" , wolfssl_lib_dir( ) ?) ;
83+ }
84+
7885 Ok ( ( ) )
7986}
8087
You can’t perform that action at this time.
0 commit comments