about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-01 00:46:23 -0800
committerbors <bors@rust-lang.org>2014-02-01 00:46:23 -0800
commitc80d28c8e322b6da49b7725d2b5e5b5cc86da822 (patch)
tree2b74e7ee268820b3cadb9ff53f1646a5c0340209 /src
parentac000cd8e1117339f274850571b90af9e30981dc (diff)
parent723072ff6a66dab863e7c012c06aadf8a5c4ee91 (diff)
downloadrust-c80d28c8e322b6da49b7725d2b5e5b5cc86da822.tar.gz
rust-c80d28c8e322b6da49b7725d2b5e5b5cc86da822.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/librustpkg/path_util.rs37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs
index a0d49e7565f..908e5e5c381 100644
--- a/src/librustpkg/path_util.rs
+++ b/src/librustpkg/path_util.rs
@@ -21,9 +21,7 @@ use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
 use std::os;
 use std::io;
 use std::io::fs;
-use extra::hex::ToHex;
 use syntax::crateid::CrateId;
-use rustc::util::sha2::{Digest, Sha256};
 use rustc::metadata::filesearch::{libdir, relative_target_lib_path};
 use rustc::driver::driver::host_triple;
 use messages::*;
@@ -206,24 +204,27 @@ pub fn system_library(sysroot: &Path, crate_id: &CrateId) -> Option<Path> {
 }
 
 fn library_in(crate_id: &CrateId, dir_to_search: &Path) -> Option<Path> {
-    let mut hasher = Sha256::new();
-    hasher.reset();
-    hasher.input_str(crate_id.to_str());
-    let hash = hasher.result_bytes().to_hex();
-    let hash = hash.slice_chars(0, 8);
-
-    let lib_name = format!("{}-{}-{}", crate_id.name, hash, crate_id.version_or_default());
-    let filenames = [
-        format!("{}{}.{}", "lib", lib_name, "rlib"),
-        format!("{}{}{}", os::consts::DLL_PREFIX, lib_name, os::consts::DLL_SUFFIX),
+    let version_str = match crate_id.version {
+        Some(ref v) => format!("-{}", *v),
+        None => ~"",
+    };
+    let patterns = ~[
+        (format!("lib{}", crate_id.name), format!("{}.rlib", version_str)),
+        (format!("{}{}", os::consts::DLL_PREFIX, crate_id.name),
+         format!("{}{}", version_str, os::consts::DLL_SUFFIX)),
     ];
 
-    for filename in filenames.iter() {
-        debug!("filename = {}", filename.as_slice());
-        let path = dir_to_search.join(filename.as_slice());
-        if path.exists() {
-            debug!("found: {}", path.display());
-            return Some(path);
+    for (prefix, suffix) in patterns.move_iter() {
+        let files = match io::result(|| fs::readdir(dir_to_search)) {
+            Ok(dir) => dir, Err(..) => continue,
+        };
+        for file in files.move_iter() {
+            let filename = match file.filename_str() {
+                Some(s) => s, None => continue,
+            };
+            if filename.starts_with(prefix) && filename.ends_with(suffix) {
+                return Some(file.clone())
+            }
         }
     }
     debug!("warning: library_in_workspace didn't find a library in {} for {}",