Skip to content

Commit

Permalink
is_static_available: Also consider Windows MSVC libraries for dynamic…
Browse files Browse the repository at this point in the history
… linkage
  • Loading branch information
amyspark committed Jan 16, 2024
1 parent 73d776d commit e37f666
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 @@ -1004,10 +1004,19 @@ fn envify(name: &str) -> String {

/// System libraries should only be linked dynamically
fn is_static_available(name: &str, system_roots: &[PathBuf], dirs: &[PathBuf]) -> 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
};

dirs.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());
library_exists && !system_roots.iter().any(|sys| dir.starts_with(sys))
})
}

Expand Down

0 comments on commit e37f666

Please sign in to comment.