File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -197,8 +197,25 @@ fn main() {
197197 // When building from Cargo, try to find MetaCall
198198 match find_metacall_library ( ) {
199199 Ok ( lib_path) => {
200+ // Define linker flags
200201 println ! ( "cargo:rustc-link-search=native={}" , lib_path. path. display( ) ) ;
201202 println ! ( "cargo:rustc-link-lib=dylib={}" , lib_path. library) ;
203+
204+ // Set the runtime environment variable for finding the library during tests
205+ #[ cfg( target_os = "linux" ) ]
206+ println ! (
207+ "cargo:rustc-env=LD_LIBRARY_PATH={}" ,
208+ lib_path. path. display( )
209+ ) ;
210+
211+ #[ cfg( target_os = "macos" ) ]
212+ println ! (
213+ "cargo:rustc-env=DYLD_LIBRARY_PATH={}" ,
214+ lib_path. path. display( )
215+ ) ;
216+
217+ #[ cfg( target_os = "windows" ) ]
218+ println ! ( "cargo:rustc-env=PATH={}" , lib_path. path. display( ) ) ;
202219 }
203220 Err ( e) => {
204221 // Print the error
You can’t perform that action at this time.
0 commit comments