diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-08-21 10:27:34 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-08-21 10:27:34 -0400 |
| commit | 3d088d6dae28ab851b584a11678c9993eb18da10 (patch) | |
| tree | b524fc39c7be138d919eefb0b606e7acfedbadfe | |
| parent | a48cc7e466cbbed8abf465d30fb03d867ce07185 (diff) | |
Fix symlink logic in rust api build on linux
| -rw-r--r-- | rust/binaryninjacore-sys/build.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/rust/binaryninjacore-sys/build.rs b/rust/binaryninjacore-sys/build.rs index 00abcfd3..4f3cf2f4 100644 --- a/rust/binaryninjacore-sys/build.rs +++ b/rust/binaryninjacore-sys/build.rs @@ -60,12 +60,14 @@ fn main() { // and add it to the library search path. #[cfg(target_os = "linux")] { - let symlink_target = PathBuf::from(&out_dir).join("libbinaryninjacore.so"); - if link_path.join("libbinaryninjacore.so.1").exists() && !symlink_target.exists() { + let symlink_source = PathBuf::from(&out_dir).join("libbinaryninjacore.so"); + let symlink_target = link_path.join("libbinaryninjacore.so.1"); + // Make a symlink "libbinaryninjacore.so" pointing to "libbinaryninjacore.so.1" + if symlink_target.exists() && symlink_source.symlink_metadata().is_err() { use std::os::unix::fs; fs::symlink( - link_path.join("libbinaryninjacore.so.1"), - PathBuf::from(&out_dir).join("libbinaryninjacore.so"), + symlink_target, + symlink_source, ) .expect("failed to create required symlink"); } |
