Skip to content

Commit c80d28c

Browse files
committed
auto merge of #11963 : alexcrichton/rust/fix-rustpkg, r=brson
Right now the bots are all injecting a libstd version, so all the rustpkg tests are passing. All rustpkg compilations will fail unless the version number is explicitly given because rustpkg attempts to exactly guess the target file name. Switch back to using a pattern match in order to unbreak tests. Closes #11852
2 parents ac000cd + 723072f commit c80d28c

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/librustpkg/path_util.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
2121
use std::os;
2222
use std::io;
2323
use std::io::fs;
24-
use extra::hex::ToHex;
2524
use syntax::crateid::CrateId;
26-
use rustc::util::sha2::{Digest, Sha256};
2725
use rustc::metadata::filesearch::{libdir, relative_target_lib_path};
2826
use rustc::driver::driver::host_triple;
2927
use messages::*;
@@ -206,24 +204,27 @@ pub fn system_library(sysroot: &Path, crate_id: &CrateId) -> Option<Path> {
206204
}
207205

208206
fn library_in(crate_id: &CrateId, dir_to_search: &Path) -> Option<Path> {
209-
let mut hasher = Sha256::new();
210-
hasher.reset();
211-
hasher.input_str(crate_id.to_str());
212-
let hash = hasher.result_bytes().to_hex();
213-
let hash = hash.slice_chars(0, 8);
214-
215-
let lib_name = format!("{}-{}-{}", crate_id.name, hash, crate_id.version_or_default());
216-
let filenames = [
217-
format!("{}{}.{}", "lib", lib_name, "rlib"),
218-
format!("{}{}{}", os::consts::DLL_PREFIX, lib_name, os::consts::DLL_SUFFIX),
207+
let version_str = match crate_id.version {
208+
Some(ref v) => format!("-{}", *v),
209+
None => ~"",
210+
};
211+
let patterns = ~[
212+
(format!("lib{}", crate_id.name), format!("{}.rlib", version_str)),
213+
(format!("{}{}", os::consts::DLL_PREFIX, crate_id.name),
214+
format!("{}{}", version_str, os::consts::DLL_SUFFIX)),
219215
];
220216

221-
for filename in filenames.iter() {
222-
debug!("filename = {}", filename.as_slice());
223-
let path = dir_to_search.join(filename.as_slice());
224-
if path.exists() {
225-
debug!("found: {}", path.display());
226-
return Some(path);
217+
for (prefix, suffix) in patterns.move_iter() {
218+
let files = match io::result(|| fs::readdir(dir_to_search)) {
219+
Ok(dir) => dir, Err(..) => continue,
220+
};
221+
for file in files.move_iter() {
222+
let filename = match file.filename_str() {
223+
Some(s) => s, None => continue,
224+
};
225+
if filename.starts_with(prefix) && filename.ends_with(suffix) {
226+
return Some(file.clone())
227+
}
227228
}
228229
}
229230
debug!("warning: library_in_workspace didn't find a library in {} for {}",

0 commit comments

Comments
 (0)