Skip to content

Commit

Permalink
link to OUT_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
jordy25519 committed Nov 12, 2024
1 parent 84f501b commit f4cb466
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,35 @@ fn main() {
fail_build();
}

// install the dylib to system path
let libffi_out_path =
drift_ffi_sys_crate.join(Path::new(&format!("target/{profile}/{LIB}.{lib_ext}")));
let output = std::process::Command::new("ln")
.args([
"-sf",
libffi_out_path.to_str().expect("ffi build path"),
"/usr/local/lib/",
])
.output()
.expect("install ok");

if !output.status.success() {
eprintln!(
"{LIB} could not be installed: {}",
String::from_utf8_lossy(output.stderr.as_slice())
);
}

if let Ok(out_dir) = std::env::var("OUT_DIR") {
println!("cargo:rustc-link-search=native={out_dir}");
} else {
// install the dylib to system path
let libffi_out_path =
drift_ffi_sys_crate.join(Path::new(&format!("target/{profile}/{LIB}.{lib_ext}")));
let _output = std::process::Command::new("ln")
.args([
"-sf",
libffi_out_path.to_str().expect("ffi build path"),
"/usr/local/lib/",
])
.output()
.expect("install ok");
println!("cargo:rustc-link-search=native=/usr/local/lib/");
}
}

if let Ok(lib_path) = std::env::var("CARGO_DRIFT_FFI_PATH") {
println!("{LIB}: searching for lib at: {lib_path}");
println!("cargo:rustc-link-search=native={lib_path}");
}
println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-lib=dylib=drift_ffi_sys");
}

Expand Down

0 comments on commit f4cb466

Please sign in to comment.