Skip to content

Commit 8364cf7

Browse files
committed
Solve issues with cargo test.
1 parent 59e7b91 commit 8364cf7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

source/ports/rs_port/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)