diff options
| author | sneurlax <sneurlax@gmail.com> | 2024-10-11 18:48:46 -0500 |
|---|---|---|
| committer | sneurlax <sneurlax@gmail.com> | 2024-10-11 18:48:46 -0500 |
| commit | a81f173168ade4ae3f3c6d2ee38d69bec9a7a2e8 (patch) | |
| tree | 3ef3bfd15092d33400b9399e6447e4df17a74e0d /impls/monero.rs/src | |
| parent | 2bdb7f95729461c3fba2e0ae6595b636df4ccbe6 (diff) | |
add ../../release as first lib location candidate
in response to (but not resolving) https://github.com/MrCyjaneK/monero_c/pull/67#discussion_r1796441212
Diffstat (limited to 'impls/monero.rs/src')
| -rw-r--r-- | impls/monero.rs/src/lib.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/impls/monero.rs/src/lib.rs b/impls/monero.rs/src/lib.rs index 28b7ddb..cc45c13 100644 --- a/impls/monero.rs/src/lib.rs +++ b/impls/monero.rs/src/lib.rs @@ -26,11 +26,15 @@ pub struct WalletManager { } #[cfg(target_os = "windows")] -const LIB_NAME: &str = "wallet2_api_c.dll"; -#[cfg(target_os = "linux")] -const LIB_NAME: &str = "libwallet2_api_c.so"; +const LIB_NAME: &str = "monero_libwallet2_api_c.dll"; #[cfg(target_os = "macos")] -const LIB_NAME: &str = "libwallet2_api_c.dylib"; +const LIB_NAME: &str = "monero_libwallet2_api_c.dylib"; +#[cfg(target_os = "ios")] +const LIB_NAME: &str = "MoneroWallet.framework/MoneroWallet"; +#[cfg(target_os = "android")] +const LIB_NAME: &str = "MoneroWallet.framework/MoneroWallet"; +#[cfg(target_os = "linux")] +const LIB_NAME: &str = "monero_libwallet2_api_c.so"; impl WalletManager { /// Create a new WalletManager, optionally specifying the path to the shared library. @@ -50,16 +54,27 @@ impl WalletManager { // Prepare the list of candidate paths. let mut candidates: Vec<PathBuf> = Vec::new(); - // Candidate 1: ../../lib/libwallet2_api_c.so relative to the executable. + // Candidate 1: ../../../../release/ relative to the executable. + if let Some(lib_dir) = exe_dir + .parent() + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) + .and_then(|p| p.parent()) + { + let lib_path = lib_dir.join("release").join(LIB_NAME); + candidates.push(lib_path); + } + + // Candidate 2: ../../lib/ relative to the executable. if let Some(lib_dir) = exe_dir.parent().and_then(|p| p.parent()) { let lib_path = lib_dir.join("lib").join(LIB_NAME); candidates.push(lib_path); } - // Candidate 2: libwallet2_api_c.so in the same directory as the executable. + // Candidate 3: library in the same directory as the executable. candidates.push(exe_dir.join(LIB_NAME)); - // Candidate 3: Let the library loader search standard library paths. + // Candidate 4: Let the library loader search standard library paths. // We represent this by using the library name directly. candidates.push(PathBuf::from(LIB_NAME)); |
