Skip to content

Unable to correctly identify a type of Windows static library name, such as foo.lib #146

Open

Description

I have made a patch to fix it.

fn is_static_available(name: &str, system_roots: &[PathBuf], dirs: &[PathBuf]) -> bool {
    let libname = format!("lib{}.a", name);
    let libname_win = if cfg!(windows) {
        format!("{}.lib", name)
    } else {
        Default::default()
    };

    dirs.iter().any(|dir| {
        !system_roots.iter().any(|sys| dir.starts_with(sys))
            && (dir.join(&libname).exists()
                || (!libname_win.is_empty() && dir.join(&libname_win).exists()))
    })
}
diff --git a/src/lib.rs b/src/lib.rs
index 2c690fa..a5df218 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -832,9 +832,16 @@ 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 libname_win = if cfg!(windows) {
+        format!("{}.lib", name)
+    } else {
+        Default::default()
+    };
 
     dirs.iter().any(|dir| {
-        !system_roots.iter().any(|sys| dir.starts_with(sys)) && dir.join(&libname).exists()
+        !system_roots.iter().any(|sys| dir.starts_with(sys))
+            && (dir.join(&libname).exists()
+                || (!libname_win.is_empty() && dir.join(&libname_win).exists()))
     })
 }
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions