Skip to content

Commit

Permalink
Don't ignore transitive imports when probing a static library
Browse files Browse the repository at this point in the history
Suppressing cargo_metadata silences libraries with full paths, in turn
causing linking against static libraries to fail utterly on Windows.
  • Loading branch information
amyspark committed Jan 16, 2024
1 parent 7d10f40 commit e48632e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,19 @@ impl Library {
};

let is_static_available = |name: &String| -> bool {
let libname = format!("lib{}.a", name);
let libnames = {
let mut names = vec![format!("lib{}.a", name)];

if cfg!(target_os = "windows") {
names.push(format!("{}.lib", name));
}

names
};

l.link_paths.iter().any(|dir| {
!system_roots.iter().any(|sys| dir.starts_with(sys)) && dir.join(&libname).exists()
let library_exists = libnames.iter().any(|libname| dir.join(&libname).exists());

Check failure on line 1022 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

the borrowed expression implements the required traits
library_exists && !system_roots.iter().any(|sys| dir.starts_with(sys))
})
};

Expand Down

0 comments on commit e48632e

Please sign in to comment.