Skip to content

Commit

Permalink
Fix problem with linking duplicate *.so deps
Browse files Browse the repository at this point in the history
  • Loading branch information
budziq committed Nov 5, 2017
1 parent 8b3ba1a commit 23b738c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/skeptic/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,16 @@ pub mod rt {
mtime: SystemTime,
}

fn guess_ext(mut pth: PathBuf, exts: &[&str]) -> Result<PathBuf> {
for ext in exts {
pth.set_extension(ext);
if pth.exists() {
return Ok(pth);
}
}
Err(ErrorKind::Fingerprint.into())
}

impl Fingerprint {
fn from_path<P: AsRef<Path>>(pth: P) -> Result<Fingerprint> {
let pth = pth.as_ref();
Expand All @@ -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()?;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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"),
));
}

Expand Down

0 comments on commit 23b738c

Please sign in to comment.