From 23b738c5ca16697b5497a9fdadfaacffa71a8504 Mon Sep 17 00:00:00 2001 From: Michal Budzynski Date: Sun, 5 Nov 2017 01:03:11 +0100 Subject: [PATCH] Fix problem with linking duplicate *.so deps --- src/skeptic/lib.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/skeptic/lib.rs b/src/skeptic/lib.rs index 8cebabe..524bcd4 100644 --- a/src/skeptic/lib.rs +++ b/src/skeptic/lib.rs @@ -590,6 +590,16 @@ pub mod rt { mtime: SystemTime, } + fn guess_ext(mut pth: PathBuf, exts: &[&str]) -> Result { + for ext in exts { + pth.set_extension(ext); + if pth.exists() { + return Ok(pth); + } + } + Err(ErrorKind::Fingerprint.into()) + } + impl Fingerprint { fn from_path>(pth: P) -> Result { let pth = pth.as_ref(); @@ -611,7 +621,8 @@ pub mod rt { rlib.pop(); rlib.pop(); rlib.pop(); - rlib.push(format!("deps/lib{}-{}.rlib", libname, hash)); + rlib.push(format!("deps/lib{}-{}", libname, hash)); + rlib = guess_ext(rlib, &["rlib", "so", "dylib", "dll"])?; let file = File::open(pth)?; let mtime = file.metadata()?.modified()?; @@ -678,7 +689,7 @@ pub mod rt { } } (Entry::Vacant(e), ver) => { - // we se exact match or unversioned version + // we see an exact match or unversioned version if ver.unwrap_or_else(|| locked_ver.clone()) == *locked_ver { e.insert(finger); } @@ -783,7 +794,7 @@ pub mod rt { cmd.arg(format!( "{}={}", dep.libname, - dep.rlib.to_str().expect("filename not utf8") + dep.rlib.to_str().expect("filename not utf8"), )); }