Skip to content

Commit 76967a0

Browse files
committed
Support linking of rlib files in rustpkg
1 parent 68ebe81 commit 76967a0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/librustpkg/path_util.rs

+13-6
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

@@ -261,8 +264,12 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
261264
Some(ref found_vers) if version == found_vers => {
262265
match f_name.slice(0, i).rfind('-') {
263266
Some(j) => {
264-
debug!("Maybe {} equals {}", f_name.slice(0, j), lib_prefix);
265-
if f_name.slice(0, j) == lib_prefix {
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 {
266273
result_filename = Some(p_path.clone());
267274
}
268275
break;

0 commit comments

Comments
 (0)