@@ -5,6 +5,7 @@ use std::{
55
66use anyhow:: { Context , Result } ;
77use glob:: glob;
8+ use regex:: Regex ;
89
910use crate :: {
1011 build_config:: { LinkageInfo , ProjectConfig } ,
@@ -134,20 +135,26 @@ impl Project<PathBuf> {
134135 // Use the linkage type to find the library from the given name
135136 // TODO: We should allow for a fix name in the configuration if the library does not follow the unix convention
136137 // TODO: We should also allow a way to define objects based on the architecture
137- let object_name = match linkage {
138- Linkage :: Static => format ! { "lib{}.a" , & conf . name } ,
139- Linkage :: Shared ( _) => format ! { "lib{} .so" , & conf . name } ,
138+ let file_suffix_regex = match linkage {
139+ Linkage :: Static => Regex :: new ( r"\.a$" ) . unwrap ( ) ,
140+ Linkage :: Shared ( _) => Regex :: new ( r"\ .so(\.\d+)*$" ) . unwrap ( ) ,
140141 } ;
141142
142- let lib_file = lib_path. join ( object_name) ;
143143 let mut objects = vec ! [ ] ;
144- if lib_file. exists ( ) {
145- objects. push ( lib_file. into ( ) ) ;
144+ for entry in std:: fs:: read_dir ( & lib_path) ?. flatten ( ) {
145+ let file_name = entry. file_name ( ) ;
146+ let file_name_str = file_name. to_string_lossy ( ) ;
147+
148+ if file_suffix_regex. is_match ( & file_name_str) {
149+ objects. push ( entry. path ( ) . into ( ) ) ;
150+ }
146151 }
152+
147153 let compiled_library = CompiledLibrary {
148154 objects,
149155 headers : resolve_file_paths ( Some ( & lib_path) , conf. include_path ) ?,
150156 } ;
157+
151158 Ok ( LibraryInformation {
152159 name : conf. name ,
153160 location : Some ( lib_path) ,
0 commit comments