Skip to content

Commit f8477c9

Browse files
committed
auto merge of #11500 : jhasse/rust/patch-rlib, r=alexcrichton
Currently `rustpkg` only looks for shared libraries. After this patch it also looks for `*.rlib` files.
2 parents 918a731 + 6ccc1e8 commit f8477c9

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/librustpkg/path_util.rs

+22-15
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,13 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
226226
};
227227
debug!("dir has {:?} entries", dir_contents.len());
228228

229-
let lib_prefix = format!("{}{}", os::consts::DLL_PREFIX, short_name);
230-
let lib_filetype = os::consts::DLL_EXTENSION;
229+
let dll_prefix = format!("{}{}", os::consts::DLL_PREFIX, short_name);
230+
let dll_filetype = os::consts::DLL_EXTENSION;
231+
let rlib_prefix = format!("{}{}", "lib", short_name);
232+
let rlib_filetype = "rlib";
231233

232-
debug!("lib_prefix = {} and lib_filetype = {}", lib_prefix, lib_filetype);
234+
debug!("dll_prefix = {} and dll_filetype = {}", dll_prefix, dll_filetype);
235+
debug!("rlib_prefix = {} and rlib_filetype = {}", rlib_prefix, rlib_filetype);
233236

234237
// Find a filename that matches the pattern:
235238
// (lib_prefix)-hash-(version)(lib_suffix)
@@ -238,7 +241,7 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
238241
debug!("p = {}, p's extension is {:?}", p.display(), extension);
239242
match extension {
240243
None => false,
241-
Some(ref s) => lib_filetype == *s
244+
Some(ref s) => dll_filetype == *s || rlib_filetype == *s,
242245
}
243246
});
244247

@@ -258,17 +261,21 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
258261
Some(i) => {
259262
debug!("Maybe {} is a version", f_name.slice(i + 1, f_name.len()));
260263
match try_parsing_version(f_name.slice(i + 1, f_name.len())) {
261-
Some(ref found_vers) if version == found_vers => {
262-
match f_name.slice(0, i).rfind('-') {
263-
Some(j) => {
264-
debug!("Maybe {} equals {}", f_name.slice(0, j), lib_prefix);
265-
if f_name.slice(0, j) == lib_prefix {
266-
result_filename = Some(p_path.clone());
267-
}
268-
break;
269-
}
270-
None => break
271-
}
264+
Some(ref found_vers) if version == found_vers => {
265+
match f_name.slice(0, i).rfind('-') {
266+
Some(j) => {
267+
let lib_prefix = match p_path.extension_str() {
268+
Some(ref s) if dll_filetype == *s => &dll_prefix,
269+
_ => &rlib_prefix,
270+
};
271+
debug!("Maybe {} equals {}", f_name.slice(0, j), *lib_prefix);
272+
if f_name.slice(0, j) == *lib_prefix {
273+
result_filename = Some(p_path.clone());
274+
}
275+
break;
276+
}
277+
None => break
278+
}
272279

273280
}
274281
_ => { f_name = f_name.slice(0, i); }

0 commit comments

Comments
 (0)