about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorHaitao Li <lihaitao@gmail.com>2011-10-30 17:40:35 +0800
committerBrian Anderson <banderson@mozilla.com>2011-10-31 14:43:43 -0700
commit16dad84f7b2f173db012dda2e77b08ccb423391f (patch)
treee1aa10f312d6bfb88ee83c63af9507e73f70f31a /src/comp
parent329f045d4c5f27275dcf1cadf8d0f51919ba8027 (diff)
downloadrust-16dad84f7b2f173db012dda2e77b08ccb423391f.tar.gz
rust-16dad84f7b2f173db012dda2e77b08ccb423391f.zip
rustc: Find crates by matching the name metadata
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/metadata/creader.rs31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs
index de504efb008..3aaf89126f6 100644
--- a/src/comp/metadata/creader.rs
+++ b/src/comp/metadata/creader.rs
@@ -119,37 +119,24 @@ fn find_library_crate(sess: session::session, ident: ast::ident,
 
     attr::require_unique_names(sess, metas);
 
-    let crate_name =
-        {
-            let name_items = attr::find_meta_items_by_name(metas, "name");
-            alt vec::last(name_items) {
-              some(i) {
-                alt attr::get_meta_item_value_str(i) {
-                  some(n) { n }
-                  // FIXME: Probably want a warning here since the user
-                  // is using the wrong type of meta item
-                  _ { ident }
-                }
-              }
-              none. { ident }
-            }
-        };
-
+    // Metadata "name" will be used to find the crate. Use `ident'
+    // as "name" if the attribute is not explicitly specified
+    if !attr::contains_name(metas, "name") {
+      metas += [attr::mk_name_value_item_str("name", ident)];
+    }
     let nn = default_native_lib_naming(sess, sess.get_opts().static);
     let x =
-        find_library_crate_aux(nn, crate_name, metas,
-                               sess.filesearch());
+        find_library_crate_aux(nn, metas, sess.filesearch());
     if x != none || sess.get_opts().static { ret x; }
     let nn2 = default_native_lib_naming(sess, true);
-    ret find_library_crate_aux(nn2, crate_name, metas,
-                               sess.filesearch());
+    ret find_library_crate_aux(nn2, metas, sess.filesearch());
 }
 
-fn find_library_crate_aux(nn: {prefix: str, suffix: str}, crate_name: str,
+fn find_library_crate_aux(nn: {prefix: str, suffix: str},
                           metas: [@ast::meta_item],
                           filesearch: filesearch::filesearch) ->
    option::t<{ident: str, data: @[u8]}> {
-    let prefix: str = nn.prefix + crate_name;
+    let prefix: str = nn.prefix;
     let suffix: str = nn.suffix;
 
     ret filesearch::search(filesearch, { |path|