@@ -12,6 +12,7 @@ use std::sync::Mutex;
1212use bindgen:: callbacks:: IntKind ;
1313use bindgen:: callbacks:: ParseCallbacks ;
1414use lazy_static:: lazy_static;
15+ use regex:: Regex ;
1516
1617#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Default ) ]
1718pub struct Version {
@@ -109,8 +110,23 @@ fn get_runtime_version_single<P: AsRef<Path>>(path: P) -> io::Result<Version> {
109110}
110111
111112fn validate_runtime_version ( config : & Config ) {
113+ println ! ( "Looking for HDF5 library binary..." ) ;
112114 let libfiles = & [ "libhdf5.dylib" , "libhdf5.so" , "hdf5.dll" ] ;
113- for link_path in & config. link_paths {
115+ let mut link_paths = config. link_paths . clone ( ) ;
116+ if cfg ! ( all( unix, not( target_os = "macos" ) ) ) {
117+ if let Some ( ldv) = run_command ( "ld" , & [ "--verbose" ] ) {
118+ let re = Regex :: new ( r#"SEARCH_DIR\("=(?P<path>[^"]+)"\)"# ) . unwrap ( ) ;
119+ println ! ( "Adding extra link paths (ld)..." ) ;
120+ for caps in re. captures_iter ( & ldv) {
121+ let path = & caps[ "path" ] ;
122+ println ! ( " {}" , path) ;
123+ link_paths. push ( path. into ( ) ) ;
124+ }
125+ } else {
126+ println ! ( "Unable to add extra link paths (ld)." ) ;
127+ }
128+ }
129+ for link_path in & link_paths {
114130 if let Ok ( paths) = fs:: read_dir ( link_path) {
115131 for path in paths {
116132 if let Ok ( path) = path {
@@ -141,7 +157,7 @@ fn validate_runtime_version(config: &Config) {
141157 }
142158 }
143159 }
144- panic ! ( "Unable to infer HDF5 library runtime version." ) ;
160+ panic ! ( "Unable to infer HDF5 library runtime version (can't find the binary) ." ) ;
145161}
146162
147163#[ derive( Clone , Copy , Debug , Default ) ]
0 commit comments