]> git.lizzy.rs Git - rust.git/commitdiff
Rename uses of PkgId to CrateId in librustpkg
authorLuis de Bethencourt <luis@debethencourt.com>
Sat, 28 Dec 2013 20:24:15 +0000 (15:24 -0500)
committerLuis de Bethencourt <luis@debethencourt.com>
Sun, 29 Dec 2013 20:25:37 +0000 (15:25 -0500)
13 files changed:
src/etc/combine-tests.py
src/librustpkg/api.rs
src/librustpkg/conditions.rs
src/librustpkg/crate_id.rs [new file with mode: 0644]
src/librustpkg/installed_packages.rs
src/librustpkg/lib.rs
src/librustpkg/package_id.rs [deleted file]
src/librustpkg/package_source.rs
src/librustpkg/path_util.rs
src/librustpkg/tests.rs
src/librustpkg/util.rs
src/librustpkg/workspace.rs
src/test/compile-fail/issue-7573.rs

index aaba80aa446400720e2e9955a76af6be34b6ea7d..e87187abbcbf4d25c524432444cb04b8341bc03d 100755 (executable)
@@ -45,7 +45,7 @@ c.write(
 """
 // AUTO-GENERATED FILE: DO NOT EDIT
 #[crate_id=\"run_pass_stage2#0.1\"];
-#[pkgid=\"run_pass_stage2#0.1\"];
+#[crate_id=\"run_pass_stage2#0.1\"];
 #[feature(globs, macro_rules, struct_variant, managed_boxes)];
 #[allow(warnings)];
 """
index 8e4216562c0a5deada1c265d3cc3f74c62dc925e..0730a6fc3a210d35ce2ab7ac2b0ac3ade4798e92 100644 (file)
@@ -10,7 +10,7 @@
 
 use context::*;
 use crate::*;
-use package_id::*;
+use crate_id::*;
 use package_source::*;
 use path_util::{platform_library_name, target_build_dir};
 use target::*;
@@ -92,7 +92,7 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
         build_in_destination: false,
         destination_workspace: root.clone(),
         start_dir: root.join_many(["src", name.as_slice()]),
-        id: PkgId{ version: version, ..PkgId::new(name)},
+        id: CrateId{ version: version, ..CrateId::new(name)},
         // n.b. This assumes the package only has one crate
         libs: ~[mk_crate(lib)],
         mains: ~[],
@@ -115,7 +115,7 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
         build_in_destination: false,
         destination_workspace: root.clone(),
         start_dir: root.join_many(["src", name.as_slice()]),
-        id: PkgId{ version: version, ..PkgId::new(name)},
+        id: CrateId{ version: version, ..CrateId::new(name)},
         libs: ~[],
         // n.b. This assumes the package only has one crate
         mains: ~[mk_crate(main)],
@@ -132,8 +132,8 @@ pub fn install_pkg(cx: &BuildContext,
                    version: Version,
                    // For now, these inputs are assumed to be inputs to each of the crates
                    more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path
-    let pkgid = PkgId{ version: version, ..PkgId::new(name)};
-    cx.install(PkgSrc::new(workspace.clone(), workspace, false, pkgid),
+    let crateid = CrateId{ version: version, ..CrateId::new(name)};
+    cx.install(PkgSrc::new(workspace.clone(), workspace, false, crateid),
                &WhatToBuild{ build_type: Inferred,
                              inputs_to_discover: more_inputs,
                              sources: Everything });
@@ -157,10 +157,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
     let out_name = workspace_build_dir.join_many([package_name.to_str(),
                                                   platform_library_name(output)]);
     // make paths absolute
-    let pkgid = PkgId::new(package_name);
+    let crateid = CrateId::new(package_name);
     let absolute_paths = paths.map(|s| {
             let whatever = workspace.join_many([~"src",
-                                pkgid.to_str(),
+                                crateid.to_str(),
                                 s.to_owned()]);
             whatever.as_str().unwrap().to_owned()
         });
@@ -190,8 +190,8 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
     use bad_pkg_id     = conditions::bad_pkg_id::cond;
 
     // (this assumes no particular version is requested)
-    let pkgid = PkgId::new(package_name);
-    let workspaces = pkg_parent_workspaces(context, &pkgid);
+    let crateid = CrateId::new(package_name);
+    let workspaces = pkg_parent_workspaces(context, &crateid);
     if workspaces.is_empty() {
         bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
     }
index 023bba15f97a192a5db4a175c866be9944171a1c..6c38d63a518019a90990c8b1265e154e5be80ceb 100644 (file)
@@ -10,7 +10,7 @@
 
 // Useful conditions
 
-pub use package_id::PkgId;
+pub use crate_id::CrateId;
 pub use std::io::FileStat;
 pub use std::io::process::ProcessExit;
 pub use std::path::Path;
 }
 
 condition! {
-    pub nonexistent_package: (PkgId, ~str) -> Path;
+    pub nonexistent_package: (CrateId, ~str) -> Path;
 }
 
 condition! {
-    pub missing_pkg_files: (PkgId) -> ();
+    pub missing_pkg_files: (CrateId) -> ();
 }
 
 condition! {
-    pub bad_pkg_id: (Path, ~str) -> PkgId;
+    pub bad_pkg_id: (Path, ~str) -> CrateId;
 }
 
 condition! {
diff --git a/src/librustpkg/crate_id.rs b/src/librustpkg/crate_id.rs
new file mode 100644 (file)
index 0000000..7ff8417
--- /dev/null
@@ -0,0 +1,162 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use version::{try_getting_version, try_getting_local_version,
+              Version, NoVersion, split_version};
+use std::hash::Streaming;
+use std::hash;
+
+/// Path-fragment identifier of a package such as
+/// 'github.com/graydon/test'; path must be a relative
+/// path with >=1 component.
+#[deriving(Clone)]
+pub struct CrateId {
+    /// This is a path, on the local filesystem, referring to where the
+    /// files for this package live. For example:
+    /// github.com/mozilla/quux-whatever (it's assumed that if we're
+    /// working with a package ID of this form, rustpkg has already cloned
+    /// the sources into a local directory in the RUST_PATH).
+    path: Path,
+    /// Short name. This is the path's filestem, but we store it
+    /// redundantly so as to not call get() everywhere (filestem() returns an
+    /// option)
+    /// The short name does not need to be a valid Rust identifier.
+    /// Users can write: `extern mod foo = "...";` to get around the issue
+    /// of package IDs whose short names aren't valid Rust identifiers.
+    short_name: ~str,
+    /// The requested package version.
+    version: Version
+}
+
+impl Eq for CrateId {
+    fn eq(&self, other: &CrateId) -> bool {
+        self.path == other.path && self.version == other.version
+    }
+}
+
+impl CrateId {
+    pub fn new(s: &str) -> CrateId {
+        use conditions::bad_pkg_id::cond;
+
+        let mut given_version = None;
+
+        // Did the user request a specific version?
+        let s = match split_version(s) {
+            Some((path, v)) => {
+                given_version = Some(v);
+                path
+            }
+            None => {
+                s
+            }
+        };
+
+        let path = Path::new(s);
+        if !path.is_relative() {
+            return cond.raise((path, ~"absolute crate_id"));
+        }
+        if path.filename().is_none() {
+            return cond.raise((path, ~"0-length crate_id"));
+        }
+        let short_name = path.filestem_str().expect(format!("Strange path! {}", s));
+
+        let version = match given_version {
+            Some(v) => v,
+            None => match try_getting_local_version(&path) {
+                Some(v) => v,
+                None => match try_getting_version(&path) {
+                    Some(v) => v,
+                    None => NoVersion
+                }
+            }
+        };
+
+        CrateId {
+            path: path.clone(),
+            short_name: short_name.to_owned(),
+            version: version
+        }
+    }
+
+    pub fn hash(&self) -> ~str {
+        // FIXME (#9639): hash should take a &[u8] so we can hash the real path
+        self.path.display().with_str(|s| {
+            let vers = self.version.to_str();
+            format!("{}-{}-{}", s, hash(s + vers), vers)
+        })
+    }
+
+    pub fn short_name_with_version(&self) -> ~str {
+        format!("{}{}", self.short_name, self.version.to_str())
+    }
+
+    /// True if the ID has multiple components
+    pub fn is_complex(&self) -> bool {
+        self.short_name.as_bytes() != self.path.as_vec()
+    }
+
+    pub fn prefixes(&self) -> Prefixes {
+        prefixes(&self.path)
+    }
+
+    // This is the workcache function name for the *installed*
+    // binaries for this package (as opposed to the built ones,
+    // which are per-crate).
+    pub fn install_tag(&self) -> ~str {
+        format!("install({})", self.to_str())
+    }
+}
+
+pub fn prefixes(p: &Path) -> Prefixes {
+    Prefixes {
+        components: p.str_components().map(|x|x.unwrap().to_owned()).to_owned_vec(),
+        remaining: ~[]
+    }
+}
+
+struct Prefixes {
+    priv components: ~[~str],
+    priv remaining: ~[~str]
+}
+
+impl Iterator<(Path, Path)> for Prefixes {
+    #[inline]
+    fn next(&mut self) -> Option<(Path, Path)> {
+        if self.components.len() <= 1 {
+            None
+        }
+        else {
+            let last = self.components.pop();
+            self.remaining.unshift(last);
+            // converting to str and then back is a little unfortunate
+            Some((Path::new(self.components.connect("/")),
+                  Path::new(self.remaining.connect("/"))))
+        }
+    }
+}
+
+impl ToStr for CrateId {
+    fn to_str(&self) -> ~str {
+        // should probably use the filestem and not the whole path
+        format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str())
+    }
+}
+
+
+pub fn write<W: Writer>(writer: &mut W, string: &str) {
+    writer.write(string.as_bytes());
+}
+
+pub fn hash(data: ~str) -> ~str {
+    let hasher = &mut hash::default_state();
+    write(hasher, data);
+    hasher.result_str()
+}
+
index 48c25a53682098fbb8cf9a8197ceb9a67a83f496..67ba5d2b8e83f822ed2cdd7c0dc59db3179875ad 100644 (file)
@@ -16,7 +16,7 @@
 use std::io;
 use std::io::fs;
 
-pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool  {
+pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool  {
     let workspaces = rust_path();
     for p in workspaces.iter() {
         let binfiles = {
@@ -28,7 +28,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool  {
             match exec.filestem_str() {
                 None => (),
                 Some(exec_path) => {
-                    if !f(&PkgId::new(exec_path)) {
+                    if !f(&CrateId::new(exec_path)) {
                         return false;
                     }
                 }
@@ -50,7 +50,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool  {
                     let rel_path = rel_p.join(basename);
                     rel_path.display().with_str(|s| {
                         debug!("Rel name: {}", s);
-                        f(&PkgId::new(s));
+                        f(&CrateId::new(s));
                     });
                 }
                 None => ()
@@ -78,7 +78,7 @@ pub fn has_library(p: &Path) -> Option<~str> {
     None
 }
 
-pub fn package_is_installed(p: &PkgId) -> bool {
+pub fn package_is_installed(p: &CrateId) -> bool {
     let mut is_installed = false;
     list_installed_packages(|installed| {
         if installed == p {
index 6bb6add407a41eb26130e958c32f98f866503bd5..2b54a6d6f1c150da6187a108bbdf6dae882f835a 100644 (file)
@@ -45,7 +45,7 @@
 use context::{Context, BuildContext,
                        RustcFlags, Trans, Link, Nothing, Pretty, Analysis, Assemble,
                        LLVMAssemble, LLVMCompileBitcode};
-use package_id::PkgId;
+use crate_id::CrateId;
 use package_source::PkgSrc;
 use target::{WhatToBuild, Everything, is_lib, is_main, is_test, is_bench};
 use target::{Main, Tests, MaybeCustom, Inferred, JustOne};
@@ -59,7 +59,7 @@
 pub mod exit_codes;
 mod installed_packages;
 mod messages;
-pub mod package_id;
+pub mod crate_id;
 pub mod package_source;
 mod path_util;
 mod source_control;
@@ -78,7 +78,7 @@
 /// an explicit package script.
 struct PkgScript<'a> {
     /// Uniquely identifies this package
-    id: &'a PkgId,
+    id: &'a CrateId,
     /// File path for the package script
     input: Path,
     /// The session to use *only* for compiling the custom
@@ -99,7 +99,7 @@ impl<'a> PkgScript<'a> {
     fn parse<'a>(sysroot: Path,
                  script: Path,
                  workspace: &Path,
-                 id: &'a PkgId) -> PkgScript<'a> {
+                 id: &'a CrateId) -> PkgScript<'a> {
         // Get the executable name that was invoked
         let binary = os::args()[0].to_managed();
         // Build the rustc session data structures to pass
@@ -208,10 +208,10 @@ pub trait CtxMethods {
     fn run(&self, cmd: &str, args: ~[~str]);
     fn do_cmd(&self, _cmd: &str, _pkgname: &str);
     /// Returns a pair of the selected package ID, and the destination workspace
-    fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>;
+    fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)>;
     /// Returns the destination workspace
     fn build(&self, pkg_src: &mut PkgSrc, what: &WhatToBuild);
-    fn clean(&self, workspace: &Path, id: &PkgId);
+    fn clean(&self, workspace: &Path, id: &CrateId);
     fn info(&self);
     /// Returns a pair. First component is a list of installed paths,
     /// second is a list of declared and discovered inputs
@@ -221,24 +221,24 @@ fn install_no_build(&self,
                         build_workspace: &Path,
                         build_inputs: &[Path],
                         target_workspace: &Path,
-                        id: &PkgId) -> ~[~str];
+                        id: &CrateId) -> ~[~str];
     fn prefer(&self, _id: &str, _vers: Option<~str>);
-    fn test(&self, id: &PkgId, workspace: &Path);
+    fn test(&self, id: &CrateId, workspace: &Path);
     fn uninstall(&self, _id: &str, _vers: Option<~str>);
     fn unprefer(&self, _id: &str, _vers: Option<~str>);
     fn init(&self);
 }
 
 impl CtxMethods for BuildContext {
-    fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)> {
+    fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)> {
         let cwd = os::getcwd();
 
         if args.len() < 1 {
             match cwd_to_workspace() {
                 None  if dir_has_crate_file(&cwd) => {
                     // FIXME (#9639): This needs to handle non-utf8 paths
-                    let pkgid = PkgId::new(cwd.filename_str().unwrap());
-                    let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, pkgid);
+                    let crateid = CrateId::new(cwd.filename_str().unwrap());
+                    let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, crateid);
                     self.build(&mut pkg_src, what);
                     match pkg_src {
                         PkgSrc { destination_workspace: ws,
@@ -248,8 +248,8 @@ fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>
                     }
                 }
                 None => { usage::build(); None }
-                Some((ws, pkgid)) => {
-                    let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, pkgid);
+                Some((ws, crateid)) => {
+                    let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, crateid);
                     self.build(&mut pkg_src, what);
                     match pkg_src {
                         PkgSrc { destination_workspace: ws,
@@ -262,23 +262,23 @@ fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>
         } else {
             // The package id is presumed to be the first command-line
             // argument
-            let pkgid = PkgId::new(args[0].clone());
+            let crateid = CrateId::new(args[0].clone());
             let mut dest_ws = default_workspace();
-            each_pkg_parent_workspace(&self.context, &pkgid, |workspace| {
+            each_pkg_parent_workspace(&self.context, &crateid, |workspace| {
                 debug!("found pkg {} in workspace {}, trying to build",
-                       pkgid.to_str(), workspace.display());
+                       crateid.to_str(), workspace.display());
                 dest_ws = determine_destination(os::getcwd(),
                                                 self.context.use_rust_path_hack,
                                                 workspace);
                 let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(),
-                                              false, pkgid.clone());
+                                              false, crateid.clone());
                 self.build(&mut pkg_src, what);
                 true
             });
             // n.b. If this builds multiple packages, it only returns the workspace for
             // the last one. The whole building-multiple-packages-with-the-same-ID is weird
             // anyway and there are no tests for it, so maybe take it out
-            Some((pkgid, dest_ws))
+            Some((crateid, dest_ws))
         }
     }
     fn run(&self, cmd: &str, args: ~[~str]) {
@@ -293,15 +293,15 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                         None => { usage::clean(); return }
                         // tjc: Maybe clean should clean all the packages in the
                         // current workspace, though?
-                        Some((ws, pkgid)) => self.clean(&ws, &pkgid)
+                        Some((ws, crateid)) => self.clean(&ws, &crateid)
                     }
 
                 }
                 else {
                     // The package id is presumed to be the first command-line
                     // argument
-                    let pkgid = PkgId::new(args[0].clone());
-                    self.clean(&cwd, &pkgid); // tjc: should use workspace, not cwd
+                    let crateid = CrateId::new(args[0].clone());
+                    self.clean(&cwd, &crateid); // tjc: should use workspace, not cwd
                 }
             }
             "do" => {
@@ -320,15 +320,15 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                         None if dir_has_crate_file(&cwd) => {
                             // FIXME (#9639): This needs to handle non-utf8 paths
 
-                            let inferred_pkgid =
-                                PkgId::new(cwd.filename_str().unwrap());
+                            let inferred_crateid =
+                                CrateId::new(cwd.filename_str().unwrap());
                             self.install(PkgSrc::new(cwd, default_workspace(),
-                                                     true, inferred_pkgid),
+                                                     true, inferred_crateid),
                                          &WhatToBuild::new(MaybeCustom, Everything));
                         }
                         None  => { usage::install(); return; }
-                        Some((ws, pkgid))                => {
-                            let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, pkgid);
+                        Some((ws, crateid))                => {
+                            let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, crateid);
                             self.install(pkg_src, &WhatToBuild::new(MaybeCustom,
                                                                     Everything));
                       }
@@ -337,13 +337,13 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                 else {
                     // The package id is presumed to be the first command-line
                     // argument
-                    let pkgid = PkgId::new(args[0]);
-                    let workspaces = pkg_parent_workspaces(&self.context, &pkgid);
+                    let crateid = CrateId::new(args[0]);
+                    let workspaces = pkg_parent_workspaces(&self.context, &crateid);
                     debug!("package ID = {}, found it in {:?} workspaces",
-                           pkgid.to_str(), workspaces.len());
+                           crateid.to_str(), workspaces.len());
                     if workspaces.is_empty() {
                         let d = default_workspace();
-                        let src = PkgSrc::new(d.clone(), d, false, pkgid.clone());
+                        let src = PkgSrc::new(d.clone(), d, false, crateid.clone());
                         self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
                     }
                     else {
@@ -354,7 +354,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                             let src = PkgSrc::new(workspace.clone(),
                                                   dest,
                                                   self.context.use_rust_path_hack,
-                                                  pkgid.clone());
+                                                  crateid.clone());
                             self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
                         };
                     }
@@ -400,8 +400,8 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                     return usage::uninstall();
                 }
 
-                let pkgid = PkgId::new(args[0]);
-                if !installed_packages::package_is_installed(&pkgid) {
+                let crateid = CrateId::new(args[0]);
+                if !installed_packages::package_is_installed(&crateid) {
                     warn(format!("Package {} doesn't seem to be installed! \
                                   Doing nothing.", args[0]));
                     return;
@@ -409,10 +409,10 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                 else {
                     let rp = rust_path();
                     assert!(!rp.is_empty());
-                    each_pkg_parent_workspace(&self.context, &pkgid, |workspace| {
-                        path_util::uninstall_package_from(workspace, &pkgid);
+                    each_pkg_parent_workspace(&self.context, &crateid, |workspace| {
+                        path_util::uninstall_package_from(workspace, &crateid);
                         note(format!("Uninstalled package {} (was installed in {})",
-                                  pkgid.to_str(), workspace.display()));
+                                  crateid.to_str(), workspace.display()));
                         true
                     });
                 }
@@ -437,34 +437,34 @@ fn build(&self, pkg_src: &mut PkgSrc, what_to_build: &WhatToBuild) {
         use conditions::git_checkout_failed::cond;
 
         let workspace = pkg_src.source_workspace.clone();
-        let pkgid = pkg_src.id.clone();
+        let crateid = pkg_src.id.clone();
 
         debug!("build: workspace = {} (in Rust path? {:?} is git dir? {:?} \
-                pkgid = {} pkgsrc start_dir = {}", workspace.display(),
-               in_rust_path(&workspace), is_git_dir(&workspace.join(&pkgid.path)),
-               pkgid.to_str(), pkg_src.start_dir.display());
+                crateid = {} pkgsrc start_dir = {}", workspace.display(),
+               in_rust_path(&workspace), is_git_dir(&workspace.join(&crateid.path)),
+               crateid.to_str(), pkg_src.start_dir.display());
         debug!("build: what to build = {:?}", what_to_build);
 
         // If workspace isn't in the RUST_PATH, and it's a git repo,
         // then clone it into the first entry in RUST_PATH, and repeat
-        if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&pkgid.path)) {
+        if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&crateid.path)) {
             let mut out_dir = default_workspace().join("src");
-            out_dir.push(&pkgid.path);
-            let git_result = source_control::safe_git_clone(&workspace.join(&pkgid.path),
-                                                            &pkgid.version,
+            out_dir.push(&crateid.path);
+            let git_result = source_control::safe_git_clone(&workspace.join(&crateid.path),
+                                                            &crateid.version,
                                                             &out_dir);
             match git_result {
                 CheckedOutSources => make_read_only(&out_dir),
                 // FIXME (#9639): This needs to handle non-utf8 paths
-                _ => cond.raise((pkgid.path.as_str().unwrap().to_owned(), out_dir.clone()))
+                _ => cond.raise((crateid.path.as_str().unwrap().to_owned(), out_dir.clone()))
             };
             let default_ws = default_workspace();
             debug!("Calling build recursively with {:?} and {:?}", default_ws.display(),
-                   pkgid.to_str());
+                   crateid.to_str());
             return self.build(&mut PkgSrc::new(default_ws.clone(),
                                                default_ws,
                                                false,
-                                               pkgid.clone()), what_to_build);
+                                               crateid.clone()), what_to_build);
         }
 
         // Is there custom build logic? If so, use it
@@ -482,7 +482,7 @@ fn build(&self, pkg_src: &mut PkgSrc, what_to_build: &WhatToBuild) {
                     let subsysroot = sysroot.clone();
                     let psp = package_script_path.clone();
                     let ws = workspace.clone();
-                    let pid = pkgid.clone();
+                    let pid = crateid.clone();
                     prep.exec(proc(exec) {
                         let mut pscript = PkgScript::parse(subsysroot.clone(),
                                                            psp.clone(),
@@ -550,7 +550,7 @@ fn build(&self, pkg_src: &mut PkgSrc, what_to_build: &WhatToBuild) {
         }
     }
 
-    fn clean(&self, workspace: &Path, id: &PkgId)  {
+    fn clean(&self, workspace: &Path, id: &CrateId)  {
         // Could also support a custom build hook in the pkg
         // script for cleaning files rustpkg doesn't know about.
         // Do something reasonable for now
@@ -616,7 +616,7 @@ fn install_no_build(&self,
                         build_workspace: &Path,
                         build_inputs: &[Path],
                         target_workspace: &Path,
-                        id: &PkgId) -> ~[~str] {
+                        id: &CrateId) -> ~[~str] {
 
         debug!("install_no_build: assuming {} comes from {} with target {}",
                id.to_str(), build_workspace.display(), target_workspace.display());
@@ -705,8 +705,8 @@ fn prefer(&self, _id: &str, _vers: Option<~str>)  {
         fail!("prefer not yet implemented");
     }
 
-    fn test(&self, pkgid: &PkgId, workspace: &Path)  {
-        match built_test_in_workspace(pkgid, workspace) {
+    fn test(&self, crateid: &CrateId, workspace: &Path)  {
+        match built_test_in_workspace(crateid, workspace) {
             Some(test_exec) => {
                 debug!("test: test_exec = {}", test_exec.display());
                 // FIXME (#9639): This needs to handle non-utf8 paths
@@ -723,7 +723,7 @@ fn test(&self, pkgid: &PkgId, workspace: &Path)  {
             None => {
                 error(format!("Internal error: test executable for package ID {} in workspace {} \
                            wasn't built! Please report this as a bug.",
-                           pkgid.to_str(), workspace.display()));
+                           crateid.to_str(), workspace.display()));
             }
         }
     }
diff --git a/src/librustpkg/package_id.rs b/src/librustpkg/package_id.rs
deleted file mode 100644 (file)
index 04ac30e..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use version::{try_getting_version, try_getting_local_version,
-              Version, NoVersion, split_version};
-use std::hash::Streaming;
-use std::hash;
-
-/// Path-fragment identifier of a package such as
-/// 'github.com/graydon/test'; path must be a relative
-/// path with >=1 component.
-#[deriving(Clone)]
-pub struct PkgId {
-    /// This is a path, on the local filesystem, referring to where the
-    /// files for this package live. For example:
-    /// github.com/mozilla/quux-whatever (it's assumed that if we're
-    /// working with a package ID of this form, rustpkg has already cloned
-    /// the sources into a local directory in the RUST_PATH).
-    path: Path,
-    /// Short name. This is the path's filestem, but we store it
-    /// redundantly so as to not call get() everywhere (filestem() returns an
-    /// option)
-    /// The short name does not need to be a valid Rust identifier.
-    /// Users can write: `extern mod foo = "...";` to get around the issue
-    /// of package IDs whose short names aren't valid Rust identifiers.
-    short_name: ~str,
-    /// The requested package version.
-    version: Version
-}
-
-impl Eq for PkgId {
-    fn eq(&self, other: &PkgId) -> bool {
-        self.path == other.path && self.version == other.version
-    }
-}
-
-impl PkgId {
-    pub fn new(s: &str) -> PkgId {
-        use conditions::bad_pkg_id::cond;
-
-        let mut given_version = None;
-
-        // Did the user request a specific version?
-        let s = match split_version(s) {
-            Some((path, v)) => {
-                given_version = Some(v);
-                path
-            }
-            None => {
-                s
-            }
-        };
-
-        let path = Path::new(s);
-        if !path.is_relative() {
-            return cond.raise((path, ~"absolute pkgid"));
-        }
-        if path.filename().is_none() {
-            return cond.raise((path, ~"0-length pkgid"));
-        }
-        let short_name = path.filestem_str().expect(format!("Strange path! {}", s));
-
-        let version = match given_version {
-            Some(v) => v,
-            None => match try_getting_local_version(&path) {
-                Some(v) => v,
-                None => match try_getting_version(&path) {
-                    Some(v) => v,
-                    None => NoVersion
-                }
-            }
-        };
-
-        PkgId {
-            path: path.clone(),
-            short_name: short_name.to_owned(),
-            version: version
-        }
-    }
-
-    pub fn hash(&self) -> ~str {
-        // FIXME (#9639): hash should take a &[u8] so we can hash the real path
-        self.path.display().with_str(|s| {
-            let vers = self.version.to_str();
-            format!("{}-{}-{}", s, hash(s + vers), vers)
-        })
-    }
-
-    pub fn short_name_with_version(&self) -> ~str {
-        format!("{}{}", self.short_name, self.version.to_str())
-    }
-
-    /// True if the ID has multiple components
-    pub fn is_complex(&self) -> bool {
-        self.short_name.as_bytes() != self.path.as_vec()
-    }
-
-    pub fn prefixes(&self) -> Prefixes {
-        prefixes(&self.path)
-    }
-
-    // This is the workcache function name for the *installed*
-    // binaries for this package (as opposed to the built ones,
-    // which are per-crate).
-    pub fn install_tag(&self) -> ~str {
-        format!("install({})", self.to_str())
-    }
-}
-
-pub fn prefixes(p: &Path) -> Prefixes {
-    Prefixes {
-        components: p.str_components().map(|x|x.unwrap().to_owned()).to_owned_vec(),
-        remaining: ~[]
-    }
-}
-
-struct Prefixes {
-    priv components: ~[~str],
-    priv remaining: ~[~str]
-}
-
-impl Iterator<(Path, Path)> for Prefixes {
-    #[inline]
-    fn next(&mut self) -> Option<(Path, Path)> {
-        if self.components.len() <= 1 {
-            None
-        }
-        else {
-            let last = self.components.pop();
-            self.remaining.unshift(last);
-            // converting to str and then back is a little unfortunate
-            Some((Path::new(self.components.connect("/")),
-                  Path::new(self.remaining.connect("/"))))
-        }
-    }
-}
-
-impl ToStr for PkgId {
-    fn to_str(&self) -> ~str {
-        // should probably use the filestem and not the whole path
-        format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str())
-    }
-}
-
-
-pub fn write<W: Writer>(writer: &mut W, string: &str) {
-    writer.write(string.as_bytes());
-}
-
-pub fn hash(data: ~str) -> ~str {
-    let hasher = &mut hash::default_state();
-    write(hasher, data);
-    hasher.result_str()
-}
-
index 4865003cb5e9f99a9210b5fdedede4498f2b49ef..651d64aa9d32f50bd214912c4ad6c116077133be 100644 (file)
@@ -11,7 +11,7 @@
 extern mod extra;
 
 use target::*;
-use package_id::PkgId;
+use crate_id::CrateId;
 use std::io;
 use std::io::fs;
 use std::os;
@@ -49,7 +49,7 @@ pub struct PkgSrc {
     // Directory to start looking in for packages -- normally
     // this is workspace/src/id but it may be just workspace
     start_dir: Path,
-    id: PkgId,
+    id: CrateId,
     libs: ~[Crate],
     mains: ~[Crate],
     tests: ~[Crate],
@@ -77,7 +77,7 @@ impl PkgSrc {
     pub fn new(mut source_workspace: Path,
                destination_workspace: Path,
                use_rust_path_hack: bool,
-               id: PkgId) -> PkgSrc {
+               id: CrateId) -> PkgSrc {
         use conditions::nonexistent_package::cond;
 
         debug!("Checking package source for package ID {}, \
@@ -133,14 +133,14 @@ pub fn new(mut source_workspace: Path,
                 // See if any of the prefixes of this package ID form a valid package ID
                 // That is, is this a package ID that points into the middle of a workspace?
                 for (prefix, suffix) in id.prefixes() {
-                    let package_id = PkgId::new(prefix.as_str().unwrap());
-                    let path = build_dir.join(&package_id.path);
+                    let crate_id = CrateId::new(prefix.as_str().unwrap());
+                    let path = build_dir.join(&crate_id.path);
                     debug!("in loop: checking if {} is a directory", path.display());
                     if path.is_dir() {
                         let ps = PkgSrc::new(source_workspace,
                                              destination_workspace,
                                              use_rust_path_hack,
-                                             package_id);
+                                             crate_id);
                         match ps {
                             PkgSrc {
                                 source_workspace: source,
@@ -264,36 +264,36 @@ pub fn new(mut source_workspace: Path,
     /// if this was successful, None otherwise. Similarly, if the package id
     /// refers to a git repo on the local version, also check it out.
     /// (right now we only support git)
-    pub fn fetch_git(local: &Path, pkgid: &PkgId) -> Option<Path> {
+    pub fn fetch_git(local: &Path, crateid: &CrateId) -> Option<Path> {
         use conditions::git_checkout_failed::cond;
 
         let cwd = os::getcwd();
         debug!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
-                pkgid.to_str(), pkgid.path.display(),
+                crateid.to_str(), crateid.path.display(),
                 cwd.display(),
-                pkgid.path.exists());
+                crateid.path.exists());
 
-        match safe_git_clone(&pkgid.path, &pkgid.version, local) {
+        match safe_git_clone(&crateid.path, &crateid.version, local) {
             CheckedOutSources => {
                 make_read_only(local);
                 Some(local.clone())
             }
             DirToUse(clone_target) => {
-                if pkgid.path.components().nth(1).is_none() {
+                if crateid.path.components().nth(1).is_none() {
                     // If a non-URL, don't bother trying to fetch
                     return None;
                 }
 
                 // FIXME (#9639): This needs to handle non-utf8 paths
-                let url = format!("https://{}", pkgid.path.as_str().unwrap());
+                let url = format!("https://{}", crateid.path.as_str().unwrap());
                 debug!("Fetching package: git clone {} {} [version={}]",
-                        url, clone_target.display(), pkgid.version.to_str());
+                        url, clone_target.display(), crateid.version.to_str());
 
                 let mut failed = false;
 
                 cond.trap(|_| {
                     failed = true;
-                }).inside(|| git_clone_url(url, &clone_target, &pkgid.version));
+                }).inside(|| git_clone_url(url, &clone_target, &crateid.version));
 
                 if failed {
                     return None;
index 0d927fc36aece5cecdde0176b0a7ee78ba96808e..1b8a988ab2c5a570fa493aa400a15ccf4548e0fe 100644 (file)
@@ -12,7 +12,7 @@
 
 #[allow(dead_code)];
 
-pub use package_id::PkgId;
+pub use crate_id::CrateId;
 pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
 pub use version::{Version, NoVersion, split_version_general, try_parsing_version};
 pub use rustc::metadata::filesearch::rust_path;
@@ -59,12 +59,12 @@ pub fn make_dir_rwx_recursive(p: &Path) -> bool {
 // now. Should fix that.
 
 /// True if there's a directory in <workspace> with
-/// pkgid's short name
-pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
-    workspace_contains_package_id_(pkgid, workspace, |p| p.join("src")).is_some()
+/// crateid's short name
+pub fn workspace_contains_crate_id(crateid: &CrateId, workspace: &Path) -> bool {
+    workspace_contains_crate_id_(crateid, workspace, |p| p.join("src")).is_some()
 }
 
-pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
+pub fn workspace_contains_crate_id_(crateid: &CrateId, workspace: &Path,
 // Returns the directory it was actually found in
              workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
     if !workspace.is_dir() {
@@ -77,14 +77,14 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
     let mut found = None;
     for p in fs::walk_dir(&src_dir) {
         if p.is_dir() {
-            if p == src_dir.join(&pkgid.path) || {
+            if p == src_dir.join(&crateid.path) || {
                 let pf = p.filename_str();
                 pf.iter().any(|&g| {
                     match split_version_general(g, '-') {
                         None => false,
                         Some((ref might_match, ref vers)) => {
-                            *might_match == pkgid.short_name
-                                && (pkgid.version == *vers || pkgid.version == NoVersion)
+                            *might_match == crateid.short_name
+                                && (crateid.version == *vers || crateid.version == NoVersion)
                         }
                     }
                 })
@@ -96,9 +96,9 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
     }
 
     if found.is_some() {
-        debug!("Found {} in {}", pkgid.to_str(), workspace.display());
+        debug!("Found {} in {}", crateid.to_str(), workspace.display());
     } else {
-        debug!("Didn't find {} in {}", pkgid.to_str(), workspace.display());
+        debug!("Didn't find {} in {}", crateid.to_str(), workspace.display());
     }
     found
 }
@@ -126,11 +126,11 @@ fn target_bin_dir(workspace: &Path) -> Path {
     workspace.join("bin")
 }
 
-/// Figure out what the executable name for <pkgid> in <workspace>'s build
+/// Figure out what the executable name for <crateid> in <workspace>'s build
 /// directory is, and if the file exists, return it.
-pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
+pub fn built_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
     let mut result = target_build_dir(workspace);
-    result = mk_output_path(Main, Build, pkgid, result);
+    result = mk_output_path(Main, Build, crateid, result);
     debug!("built_executable_in_workspace: checking whether {} exists",
            result.display());
     if result.exists() {
@@ -142,22 +142,22 @@ pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<
     }
 }
 
-/// Figure out what the test name for <pkgid> in <workspace>'s build
+/// Figure out what the test name for <crateid> in <workspace>'s build
 /// directory is, and if the file exists, return it.
-pub fn built_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
-    output_in_workspace(pkgid, workspace, Test)
+pub fn built_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
+    output_in_workspace(crateid, workspace, Test)
 }
 
-/// Figure out what the test name for <pkgid> in <workspace>'s build
+/// Figure out what the test name for <crateid> in <workspace>'s build
 /// directory is, and if the file exists, return it.
-pub fn built_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
-    output_in_workspace(pkgid, workspace, Bench)
+pub fn built_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
+    output_in_workspace(crateid, workspace, Bench)
 }
 
-fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Option<Path> {
+fn output_in_workspace(crateid: &CrateId, workspace: &Path, what: OutputType) -> Option<Path> {
     let mut result = target_build_dir(workspace);
     // should use a target-specific subdirectory
-    result = mk_output_path(what, Build, pkgid, result);
+    result = mk_output_path(what, Build, crateid, result);
     debug!("output_in_workspace: checking whether {} exists",
            result.display());
     if result.exists() {
@@ -169,10 +169,11 @@ fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Opt
     }
 }
 
-/// Figure out what the library name for <pkgid> in <workspace>'s build
+/// Figure out what the library name for <crateid> in <workspace>'s build
 /// directory is, and if the file exists, return it.
-pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
-    library_in_workspace(&pkgid.path, pkgid.short_name, Build, workspace, "build", &pkgid.version)
+pub fn built_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
+    library_in_workspace(&crateid.path, crateid.short_name, Build, workspace, "build",
+                         &crateid.version)
 }
 
 /// Does the actual searching stuff
@@ -292,45 +293,45 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
     abs_path
 }
 
-/// Returns the executable that would be installed for <pkgid>
+/// Returns the executable that would be installed for <crateid>
 /// in <workspace>
 /// As a side effect, creates the bin-dir if it doesn't exist
-pub fn target_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
-    target_file_in_workspace(pkgid, workspace, Main, Install)
+pub fn target_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
+    target_file_in_workspace(crateid, workspace, Main, Install)
 }
 
 
-/// Returns the executable that would be installed for <pkgid>
+/// Returns the executable that would be installed for <crateid>
 /// in <workspace>
 /// As a side effect, creates the lib-dir if it doesn't exist
-pub fn target_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
+pub fn target_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
     use conditions::bad_path::cond;
     if !workspace.is_dir() {
         cond.raise(((*workspace).clone(),
                     format!("Workspace supplied to target_library_in_workspace \
                              is not a directory! {}", workspace.display())));
     }
-    target_file_in_workspace(pkgid, workspace, Lib, Install)
+    target_file_in_workspace(crateid, workspace, Lib, Install)
 }
 
-/// Returns the test executable that would be installed for <pkgid>
+/// Returns the test executable that would be installed for <crateid>
 /// in <workspace>
 /// note that we *don't* install test executables, so this is just for unit testing
-pub fn target_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
-    target_file_in_workspace(pkgid, workspace, Test, Install)
+pub fn target_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
+    target_file_in_workspace(crateid, workspace, Test, Install)
 }
 
-/// Returns the bench executable that would be installed for <pkgid>
+/// Returns the bench executable that would be installed for <crateid>
 /// in <workspace>
 /// note that we *don't* install bench executables, so this is just for unit testing
-pub fn target_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
-    target_file_in_workspace(pkgid, workspace, Bench, Install)
+pub fn target_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
+    target_file_in_workspace(crateid, workspace, Bench, Install)
 }
 
 
-/// Returns the path that pkgid `pkgid` would have if placed `where`
+/// Returns the path that crateid `crateid` would have if placed `where`
 /// in `workspace`
-fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
+fn target_file_in_workspace(crateid: &CrateId, workspace: &Path,
                             what: OutputType, where: Target) -> Path {
     use conditions::bad_path::cond;
 
@@ -340,25 +341,25 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
     // Artifacts in the build directory live in a package-ID-specific subdirectory,
     // but installed ones don't.
     let result = match (where, what) {
-                (Build, _)      => target_build_dir(workspace).join(&pkgid.path),
+                (Build, _)      => target_build_dir(workspace).join(&crateid.path),
                 (Install, Lib)  => target_lib_dir(workspace),
                 (Install, _)    => target_bin_dir(workspace)
     };
     if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() {
         cond.raise((result.clone(), format!("target_file_in_workspace couldn't \
-            create the {} dir (pkgid={}, workspace={}, what={:?}, where={:?}",
-            subdir, pkgid.to_str(), workspace.display(), what, where)));
+            create the {} dir (crateid={}, workspace={}, what={:?}, where={:?}",
+            subdir, crateid.to_str(), workspace.display(), what, where)));
     }
-    mk_output_path(what, where, pkgid, result)
+    mk_output_path(what, where, crateid, result)
 }
 
-/// Return the directory for <pkgid>'s build artifacts in <workspace>.
+/// Return the directory for <crateid>'s build artifacts in <workspace>.
 /// Creates it if it doesn't exist.
-pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
+pub fn build_pkg_id_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
     let mut result = target_build_dir(workspace);
-    result.push(&pkgid.path);
+    result.push(&crateid.path);
     debug!("Creating build dir {} for package id {}", result.display(),
-           pkgid.to_str());
+           crateid.to_str());
     fs::mkdir_recursive(&result, io::UserRWX);
     return result;
 }
@@ -366,7 +367,7 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
 /// Return the output file for a given directory name,
 /// given whether we're building a library and whether we're building tests
 pub fn mk_output_path(what: OutputType, where: Target,
-                      pkg_id: &PkgId, workspace: Path) -> Path {
+                      pkg_id: &CrateId, workspace: Path) -> Path {
     let short_name_with_version = format!("{}-{}", pkg_id.short_name,
                                           pkg_id.version.to_str());
     // Not local_path.dir_path()! For package foo/bar/blat/, we want
@@ -399,22 +400,22 @@ pub fn mk_output_path(what: OutputType, where: Target,
     output_path
 }
 
-/// Removes files for the package `pkgid`, assuming it's installed in workspace `workspace`
-pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
+/// Removes files for the package `crateid`, assuming it's installed in workspace `workspace`
+pub fn uninstall_package_from(workspace: &Path, crateid: &CrateId) {
     let mut did_something = false;
-    let installed_bin = target_executable_in_workspace(pkgid, workspace);
+    let installed_bin = target_executable_in_workspace(crateid, workspace);
     if installed_bin.exists() {
         fs::unlink(&installed_bin);
         did_something = true;
     }
-    let installed_lib = target_library_in_workspace(pkgid, workspace);
+    let installed_lib = target_library_in_workspace(crateid, workspace);
     if installed_lib.exists() {
         fs::unlink(&installed_lib);
         did_something = true;
     }
     if !did_something {
         warn(format!("Warning: there don't seem to be any files for {} installed in {}",
-             pkgid.to_str(), workspace.display()));
+             crateid.to_str(), workspace.display()));
     }
 
 }
@@ -429,7 +430,7 @@ fn dir_has_file(dir: &Path, file: &str) -> bool {
     dir.join(file).exists()
 }
 
-pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
+pub fn find_dir_using_rust_path_hack(p: &CrateId) -> Option<Path> {
     let rp = rust_path();
     for dir in rp.iter() {
         // Require that the parent directory match the package ID
index 21f18eda1409d648d1a70fc491433dc3d358dce5..7f6342dba5c794eb47159475f01ff8d61d9de68c 100644 (file)
@@ -24,7 +24,7 @@
 use extra::getopts::groups::getopts;
 use std::run::ProcessOutput;
 use installed_packages::list_installed_packages;
-use package_id::{PkgId};
+use crate_id::{CrateId};
 use version::{ExactRevision, NoVersion, Version, Tagged};
 use path_util::{target_executable_in_workspace, target_test_in_workspace,
                target_bench_in_workspace, make_dir_rwx,
@@ -59,25 +59,25 @@ fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
     }
 }
 
-fn fake_pkg() -> PkgId {
+fn fake_pkg() -> CrateId {
     let sn = ~"bogus";
-    PkgId {
+    CrateId {
         path: Path::new(sn.as_slice()),
         short_name: sn,
         version: NoVersion
     }
 }
 
-fn git_repo_pkg() -> PkgId {
-    PkgId {
+fn git_repo_pkg() -> CrateId {
+    CrateId {
         path: Path::new("mockgithub.com/catamorphism/test-pkg"),
         short_name: ~"test-pkg",
         version: NoVersion
     }
 }
 
-fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
-    PkgId {
+fn git_repo_pkg_with_tag(a_tag: ~str) -> CrateId {
+    CrateId {
         path: Path::new("mockgithub.com/catamorphism/test-pkg"),
         short_name: ~"test-pkg",
         version: Tagged(a_tag)
@@ -302,15 +302,16 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
     }
 }
 
-fn create_local_package(pkgid: &PkgId) -> TempDir {
-    let (workspace, parent_dir) = mk_temp_workspace(&pkgid.path, &pkgid.version);
-    debug!("Created empty package dir for {}, returning {}", pkgid.to_str(), parent_dir.display());
+fn create_local_package(crateid: &CrateId) -> TempDir {
+    let (workspace, parent_dir) = mk_temp_workspace(&crateid.path, &crateid.version);
+    debug!("Created empty package dir for {}, returning {}", crateid.to_str(),
+           parent_dir.display());
     workspace
 }
 
-fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
+fn create_local_package_in(crateid: &CrateId, pkgdir: &Path) -> Path {
 
-    let package_dir = pkgdir.join_many([~"src", pkgid.to_str()]);
+    let package_dir = pkgdir.join_many([~"src", crateid.to_str()]);
 
     // Create main, lib, test, and bench files
     fs::mkdir_recursive(&package_dir, io::UserRWX);
@@ -329,29 +330,29 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
     package_dir
 }
 
-fn create_local_package_with_test(pkgid: &PkgId) -> TempDir {
-    debug!("Dry run -- would create package {:?} with test", pkgid);
-    create_local_package(pkgid) // Already has tests???
+fn create_local_package_with_test(crateid: &CrateId) -> TempDir {
+    debug!("Dry run -- would create package {:?} with test", crateid);
+    create_local_package(crateid) // Already has tests???
 }
 
-fn create_local_package_with_dep(pkgid: &PkgId, subord_pkgid: &PkgId) -> TempDir {
-    let package_dir = create_local_package(pkgid);
-    create_local_package_in(subord_pkgid, package_dir.path());
-    // Write a main.rs file into pkgid that references subord_pkgid
-    writeFile(&package_dir.path().join_many([~"src", pkgid.to_str(), ~"main.rs"]),
+fn create_local_package_with_dep(crateid: &CrateId, subord_crateid: &CrateId) -> TempDir {
+    let package_dir = create_local_package(crateid);
+    create_local_package_in(subord_crateid, package_dir.path());
+    // Write a main.rs file into crateid that references subord_crateid
+    writeFile(&package_dir.path().join_many([~"src", crateid.to_str(), ~"main.rs"]),
               format!("extern mod {};\nfn main() \\{\\}",
-                   subord_pkgid.short_name));
-    // Write a lib.rs file into subord_pkgid that has something in it
-    writeFile(&package_dir.path().join_many([~"src", subord_pkgid.to_str(), ~"lib.rs"]),
+                   subord_crateid.short_name));
+    // Write a lib.rs file into subord_crateid that has something in it
+    writeFile(&package_dir.path().join_many([~"src", subord_crateid.to_str(), ~"lib.rs"]),
               "pub fn f() {}");
     package_dir
 }
 
-fn create_local_package_with_custom_build_hook(pkgid: &PkgId,
+fn create_local_package_with_custom_build_hook(crateid: &CrateId,
                                                custom_build_hook: &str) -> TempDir {
     debug!("Dry run -- would create package {} with custom build hook {}",
-           pkgid.to_str(), custom_build_hook);
-    create_local_package(pkgid)
+           crateid.to_str(), custom_build_hook);
+    create_local_package(crateid)
     // actually write the pkg.rs with the custom build hook
 
 }
@@ -376,18 +377,18 @@ fn assert_executable_exists(repo: &Path, short_name: &str) {
 
 fn executable_exists(repo: &Path, short_name: &str) -> bool {
     debug!("executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
-    let exec = target_executable_in_workspace(&PkgId::new(short_name), repo);
+    let exec = target_executable_in_workspace(&CrateId::new(short_name), repo);
     exec.exists() && is_rwx(&exec)
 }
 
 fn test_executable_exists(repo: &Path, short_name: &str) -> bool {
     debug!("test_executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
-    let exec = built_test_in_workspace(&PkgId::new(short_name), repo);
+    let exec = built_test_in_workspace(&CrateId::new(short_name), repo);
     exec.map_default(false, |exec| exec.exists() && is_rwx(&exec))
 }
 
-fn remove_executable_file(p: &PkgId, workspace: &Path) {
-    let exec = target_executable_in_workspace(&PkgId::new(p.short_name), workspace);
+fn remove_executable_file(p: &CrateId, workspace: &Path) {
+    let exec = target_executable_in_workspace(&CrateId::new(p.short_name), workspace);
     if exec.exists() {
         fs::unlink(&exec);
     }
@@ -400,15 +401,15 @@ fn assert_built_executable_exists(repo: &Path, short_name: &str) {
 fn built_executable_exists(repo: &Path, short_name: &str) -> bool {
     debug!("assert_built_executable_exists: repo = {}, short_name = {}",
             repo.display(), short_name);
-    let exec = built_executable_in_workspace(&PkgId::new(short_name), repo);
+    let exec = built_executable_in_workspace(&CrateId::new(short_name), repo);
     exec.is_some() && {
        let execname = exec.get_ref();
        execname.exists() && is_rwx(execname)
     }
 }
 
-fn remove_built_executable_file(p: &PkgId, workspace: &Path) {
-    let exec = built_executable_in_workspace(&PkgId::new(p.short_name), workspace);
+fn remove_built_executable_file(p: &CrateId, workspace: &Path) {
+    let exec = built_executable_in_workspace(&CrateId::new(p.short_name), workspace);
     match exec {
         Some(r) => fs::unlink(&r),
         None    => ()
@@ -443,7 +444,7 @@ fn assert_built_library_exists(repo: &Path, short_name: &str) {
 
 fn built_library_exists(repo: &Path, short_name: &str) -> bool {
     debug!("assert_built_library_exists: repo = {}, short_name = {}", repo.display(), short_name);
-    let lib = built_library_in_workspace(&PkgId::new(short_name), repo);
+    let lib = built_library_in_workspace(&CrateId::new(short_name), repo);
     lib.is_some() && {
         let libname = lib.get_ref();
         libname.exists() && is_rwx(libname)
@@ -493,9 +494,9 @@ fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
 }
 
 #[cfg(target_os = "linux")]
-fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
+fn touch_source_file(workspace: &Path, crateid: &CrateId) {
     use conditions::bad_path::cond;
-    let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
+    let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
     let contents = fs::readdir(&pkg_src_dir);
     for p in contents.iter() {
         if p.extension_str() == Some("rs") {
@@ -513,9 +514,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
 }
 
 #[cfg(not(target_os = "linux"))]
-fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
+fn touch_source_file(workspace: &Path, crateid: &CrateId) {
     use conditions::bad_path::cond;
-    let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
+    let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
     let contents = fs::readdir(&pkg_src_dir);
     for p in contents.iter() {
         if p.extension_str() == Some("rs") {
@@ -532,9 +533,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
 }
 
 /// Add a comment at the end
-fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
+fn frob_source_file(workspace: &Path, crateid: &CrateId, filename: &str) {
     use conditions::bad_path::cond;
-    let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
+    let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
     let mut maybe_p = None;
     let maybe_file = pkg_src_dir.join(filename);
     debug!("Trying to frob {} -- {}", pkg_src_dir.display(), filename);
@@ -618,7 +619,7 @@ fn test_install_valid() {
 #[ignore]
 fn test_install_invalid() {
     let sysroot = test_sysroot();
-    let pkgid = fake_pkg();
+    let crateid = fake_pkg();
     let temp_workspace = TempDir::new("test").expect("couldn't create temp dir");
     let temp_workspace = temp_workspace.path().clone();
     let ctxt = fake_ctxt(sysroot, &temp_workspace);
@@ -628,7 +629,7 @@ fn test_install_invalid() {
         let pkg_src = PkgSrc::new(temp_workspace.clone(),
                                   temp_workspace.clone(),
                                   false,
-                                  pkgid.clone());
+                                  crateid.clone());
         ctxt.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything));
     };
     assert!(result.unwrap_err()
@@ -637,7 +638,7 @@ fn test_install_invalid() {
 
 #[test]
 fn test_install_valid_external() {
-    let temp_pkg_id = PkgId::new("foo");
+    let temp_pkg_id = CrateId::new("foo");
     let (tempdir, _) = mk_temp_workspace(&temp_pkg_id.path,
                                          &temp_pkg_id.version);
     let temp_workspace = tempdir.path();
@@ -724,7 +725,7 @@ fn test_install_git() {
 }
 
 #[test]
-fn test_package_ids_must_be_relative_path_like() {
+fn test_crate_ids_must_be_relative_path_like() {
     use conditions::bad_pkg_id::cond;
 
     /*
@@ -738,30 +739,30 @@ fn test_package_ids_must_be_relative_path_like() {
 
     */
 
-    let whatever = PkgId::new("foo");
+    let whatever = CrateId::new("foo");
 
     assert_eq!(~"foo-0.0", whatever.to_str());
     assert!("github.com/catamorphism/test-pkg-0.0" ==
-            PkgId::new("github.com/catamorphism/test-pkg").to_str());
+            CrateId::new("github.com/catamorphism/test-pkg").to_str());
 
     cond.trap(|(p, e)| {
         assert!(p.filename().is_none())
-        assert!("0-length pkgid" == e);
+        assert!("0-length crate_id" == e);
         whatever.clone()
     }).inside(|| {
-        let x = PkgId::new("");
+        let x = CrateId::new("");
         assert_eq!(~"foo-0.0", x.to_str());
     });
 
     cond.trap(|(p, e)| {
         let abs = os::make_absolute(&Path::new("foo/bar/quux"));
         assert_eq!(p, abs);
-        assert!("absolute pkgid" == e);
+        assert!("absolute crate_id" == e);
         whatever.clone()
     }).inside(|| {
         let zp = os::make_absolute(&Path::new("foo/bar/quux"));
         // FIXME (#9639): This needs to handle non-utf8 paths
-        let z = PkgId::new(zp.as_str().unwrap());
+        let z = CrateId::new(zp.as_str().unwrap());
         assert_eq!(~"foo-0.0", z.to_str());
     })
 }
@@ -785,7 +786,7 @@ fn test_package_version() {
     add_git_tag(&repo_subdir, ~"0.4");
 
     // It won't pick up the 0.4 version because the dir isn't in the RUST_PATH, but...
-    let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version");
+    let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version");
     // This should look at the prefix, clone into a workspace, then build.
     command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg_version"],
                       repo);
@@ -837,7 +838,7 @@ fn test_package_request_version() {
         }
         None    => false
     });
-    let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version#0.3");
+    let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version#0.3");
     assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join(".rust"))
             == repo.join_many([".rust", "bin", "test_pkg_version"]));
 
@@ -880,7 +881,7 @@ fn rustpkg_library_target() {
 
 #[test]
 fn rustpkg_local_pkg() {
-    let dir = create_local_package(&PkgId::new("foo"));
+    let dir = create_local_package(&CrateId::new("foo"));
     command_line_test([~"install", ~"foo"], dir.path());
     assert_executable_exists(dir.path(), "foo");
 }
@@ -888,7 +889,7 @@ fn rustpkg_local_pkg() {
 #[test]
 #[ignore(reason="busted")]
 fn package_script_with_default_build() {
-    let dir = create_local_package(&PkgId::new("fancy-lib"));
+    let dir = create_local_package(&CrateId::new("fancy-lib"));
     let dir = dir.path();
     debug!("dir = {}", dir.display());
     let mut source = test_sysroot().dir_path();
@@ -945,7 +946,7 @@ fn rustpkg_clean_no_arg() {
     command_line_test([~"build"], &package_dir);
     assert_built_executable_exists(&tmp, "foo");
     command_line_test([~"clean"], &package_dir);
-    let res = built_executable_in_workspace(&PkgId::new("foo"), &tmp);
+    let res = built_executable_in_workspace(&CrateId::new("foo"), &tmp);
     assert!(!res.as_ref().map_default(false, |m| m.exists()));
 }
 
@@ -1003,11 +1004,11 @@ fn rust_path_parse() {
 fn test_list() {
     let dir = TempDir::new("test_list").expect("test_list failed");
     let dir = dir.path();
-    let foo = PkgId::new("foo");
+    let foo = CrateId::new("foo");
     create_local_package_in(&foo, dir);
-    let bar = PkgId::new("bar");
+    let bar = CrateId::new("bar");
     create_local_package_in(&bar, dir);
-    let quux = PkgId::new("quux");
+    let quux = CrateId::new("quux");
     create_local_package_in(&quux, dir);
 
 // list doesn't output very much right now...
@@ -1033,9 +1034,9 @@ fn test_list() {
 fn install_remove() {
     let dir = TempDir::new("install_remove").expect("install_remove");
     let dir = dir.path();
-    let foo = PkgId::new("foo");
-    let bar = PkgId::new("bar");
-    let quux = PkgId::new("quux");
+    let foo = CrateId::new("foo");
+    let bar = CrateId::new("bar");
+    let quux = CrateId::new("quux");
     create_local_package_in(&foo, dir);
     create_local_package_in(&bar, dir);
     create_local_package_in(&quux, dir);
@@ -1062,13 +1063,13 @@ fn install_check_duplicates() {
     // check invariant that there are no dups in the pkg database
     let dir = TempDir::new("install_remove").expect("install_remove");
     let dir = dir.path();
-    let foo = PkgId::new("foo");
+    let foo = CrateId::new("foo");
     create_local_package_in(&foo, dir);
 
     command_line_test([~"install", ~"foo"], dir);
     command_line_test([~"install", ~"foo"], dir);
     let mut contents = ~[];
-    let check_dups = |p: &PkgId| {
+    let check_dups = |p: &CrateId| {
         if contents.contains(p) {
             fail!("package {} appears in `list` output more than once", p.path.display());
         }
@@ -1082,7 +1083,7 @@ fn install_check_duplicates() {
 
 #[test]
 fn no_rebuilding() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     command_line_test([~"build", ~"foo"], workspace);
@@ -1103,7 +1104,7 @@ fn no_rebuilding() {
 #[test]
 #[ignore]
 fn no_recopying() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     command_line_test([~"install", ~"foo"], workspace);
@@ -1122,8 +1123,8 @@ fn no_recopying() {
 
 #[test]
 fn no_rebuilding_dep() {
-    let p_id = PkgId::new("foo");
-    let dep_id = PkgId::new("bar");
+    let p_id = CrateId::new("foo");
+    let dep_id = CrateId::new("bar");
     let workspace = create_local_package_with_dep(&p_id, &dep_id);
     let workspace = workspace.path();
     command_line_test([~"build", ~"foo"], workspace);
@@ -1141,8 +1142,8 @@ fn no_rebuilding_dep() {
 
 #[test]
 fn do_rebuild_dep_dates_change() {
-    let p_id = PkgId::new("foo");
-    let dep_id = PkgId::new("bar");
+    let p_id = CrateId::new("foo");
+    let dep_id = CrateId::new("bar");
     let workspace = create_local_package_with_dep(&p_id, &dep_id);
     let workspace = workspace.path();
     command_line_test([~"build", ~"foo"], workspace);
@@ -1161,8 +1162,8 @@ fn do_rebuild_dep_dates_change() {
 
 #[test]
 fn do_rebuild_dep_only_contents_change() {
-    let p_id = PkgId::new("foo");
-    let dep_id = PkgId::new("bar");
+    let p_id = CrateId::new("foo");
+    let dep_id = CrateId::new("bar");
     let workspace = create_local_package_with_dep(&p_id, &dep_id);
     let workspace = workspace.path();
     command_line_test([~"build", ~"foo"], workspace);
@@ -1182,8 +1183,8 @@ fn do_rebuild_dep_only_contents_change() {
 
 #[test]
 fn test_versions() {
-    let workspace = create_local_package(&PkgId::new("foo#0.1"));
-    let _other_workspace = create_local_package(&PkgId::new("foo#0.2"));
+    let workspace = create_local_package(&CrateId::new("foo#0.1"));
+    let _other_workspace = create_local_package(&CrateId::new("foo#0.2"));
     command_line_test([~"install", ~"foo#0.1"], workspace.path());
     let output = command_line_test_output([~"list"]);
     // make sure output includes versions
@@ -1193,7 +1194,7 @@ fn test_versions() {
 #[test]
 #[ignore(reason = "do not yet implemented")]
 fn test_build_hooks() {
-    let workspace = create_local_package_with_custom_build_hook(&PkgId::new("foo"),
+    let workspace = create_local_package_with_custom_build_hook(&CrateId::new("foo"),
                                                                 "frob");
     command_line_test([~"do", ~"foo", ~"frob"], workspace.path());
 }
@@ -1203,14 +1204,14 @@ fn test_build_hooks() {
 #[ignore(reason = "info not yet implemented")]
 fn test_info() {
     let expected_info = ~"package foo"; // fill in
-    let workspace = create_local_package(&PkgId::new("foo"));
+    let workspace = create_local_package(&CrateId::new("foo"));
     let output = command_line_test([~"info", ~"foo"], workspace.path());
     assert_eq!(str::from_utf8_owned(output.output), expected_info);
 }
 
 #[test]
 fn test_uninstall() {
-    let workspace = create_local_package(&PkgId::new("foo"));
+    let workspace = create_local_package(&CrateId::new("foo"));
     command_line_test([~"uninstall", ~"foo"], workspace.path());
     let output = command_line_test([~"list"], workspace.path());
     assert!(!str::from_utf8(output.output).contains("foo"));
@@ -1346,7 +1347,7 @@ fn test_extern_mod_simpler() {
 
 #[test]
 fn test_import_rustpkg() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
@@ -1359,7 +1360,7 @@ fn test_import_rustpkg() {
 
 #[test]
 fn test_macro_pkg_script() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
@@ -1386,7 +1387,7 @@ fn multiple_workspaces() {
     // FIXME (#9639): This needs to handle non-utf8 paths
     let env = Some(~[(~"RUST_PATH", format!("{}:{}", a_loc.as_str().unwrap(),
                                             b_loc.as_str().unwrap()))]);
-    let c_loc = create_local_package_with_dep(&PkgId::new("bar"), &PkgId::new("foo"));
+    let c_loc = create_local_package_with_dep(&CrateId::new("bar"), &CrateId::new("foo"));
     command_line_test_with_env([~"install", ~"bar"], c_loc.path(), env);
 }
 
@@ -1399,7 +1400,7 @@ fn rust_path_hack_test(hack_flag: bool) {
       make sure built files for foo are in B
       make sure nothing gets built into A or A/../build[lib,bin]
 */
-   let p_id = PkgId::new("foo");
+   let p_id = CrateId::new("foo");
    let workspace = create_local_package(&p_id);
    let workspace = workspace.path();
    let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
@@ -1524,8 +1525,8 @@ fn rust_path_hack_build_no_arg() {
 
 #[test]
 fn rust_path_hack_build_with_dependency() {
-    let foo_id = PkgId::new("foo");
-    let dep_id = PkgId::new("dep");
+    let foo_id = CrateId::new("foo");
+    let dep_id = CrateId::new("dep");
     // Tests that when --rust-path-hack is in effect, dependencies get built
     // into the destination workspace and not the source directory
     let work_dir = create_local_package(&foo_id);
@@ -1573,7 +1574,7 @@ fn rust_path_install_target() {
 
 #[test]
 fn sysroot_flag() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     // no-op sysroot setting; I'm not sure how else to test this
@@ -1589,7 +1590,7 @@ fn sysroot_flag() {
 
 #[test]
 fn compile_flag_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1606,7 +1607,7 @@ fn compile_flag_build() {
 #[test]
 fn compile_flag_fail() {
     // --no-link shouldn't be accepted for install
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1622,7 +1623,7 @@ fn compile_flag_fail() {
 
 #[test]
 fn notrans_flag_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let flags_to_test = [~"--no-trans", ~"--parse-only",
@@ -1647,7 +1648,7 @@ fn notrans_flag_build() {
 #[test]
 fn notrans_flag_fail() {
     // --no-trans shouldn't be accepted for install
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let flags_to_test = [~"--no-trans", ~"--parse-only",
@@ -1668,7 +1669,7 @@ fn notrans_flag_fail() {
 
 #[test]
 fn dash_S() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1685,7 +1686,7 @@ fn dash_S() {
 
 #[test]
 fn dash_S_fail() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1702,7 +1703,7 @@ fn dash_S_fail() {
 
 #[test]
 fn test_cfg_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     // If the cfg flag gets messed up, this won't compile
@@ -1721,7 +1722,7 @@ fn test_cfg_build() {
 
 #[test]
 fn test_cfg_fail() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     writeFile(&workspace.join_many(["src", "foo-0.0", "main.rs"]),
@@ -1740,7 +1741,7 @@ fn test_cfg_fail() {
 
 #[test]
 fn test_emit_llvm_S_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1758,7 +1759,7 @@ fn test_emit_llvm_S_build() {
 
 #[test]
 fn test_emit_llvm_S_fail() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1778,7 +1779,7 @@ fn test_emit_llvm_S_fail() {
 
 #[test]
 fn test_emit_llvm_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1797,7 +1798,7 @@ fn test_emit_llvm_build() {
 
 #[test]
 fn test_emit_llvm_fail() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1818,7 +1819,7 @@ fn test_emit_llvm_fail() {
 
 #[test]
 fn test_linker_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let matches = getopts([], optgroups());
@@ -1863,7 +1864,7 @@ fn test_build_install_flags_fail() {
 
 #[test]
 fn test_optimized_build() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1877,7 +1878,7 @@ fn test_optimized_build() {
 }
 
 #[test]
-fn pkgid_pointing_to_subdir() {
+fn crateid_pointing_to_subdir() {
     // The actual repo is mockgithub.com/mozilla/some_repo
     // rustpkg should recognize that and treat the part after some_repo/ as a subdir
     let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir");
@@ -1913,9 +1914,9 @@ fn pkgid_pointing_to_subdir() {
 
 #[test]
 fn test_recursive_deps() {
-    let a_id = PkgId::new("a");
-    let b_id = PkgId::new("b");
-    let c_id = PkgId::new("c");
+    let a_id = CrateId::new("a");
+    let b_id = CrateId::new("b");
+    let c_id = CrateId::new("c");
     let b_workspace = create_local_package_with_dep(&b_id, &c_id);
     let b_workspace = b_workspace.path();
     writeFile(&b_workspace.join_many(["src", "c-0.0", "lib.rs"]),
@@ -1939,7 +1940,7 @@ fn test_recursive_deps() {
 
 #[test]
 fn test_install_to_rust_path() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let second_workspace = create_local_package(&p_id);
     let second_workspace = second_workspace.path();
     let first_workspace = mk_empty_workspace(&Path::new("p"), &NoVersion, "dest");
@@ -1963,7 +1964,7 @@ fn test_install_to_rust_path() {
 
 #[test]
 fn test_target_specific_build_dir() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1979,7 +1980,7 @@ fn test_target_specific_build_dir() {
 
 #[test]
 fn test_target_specific_install_dir() {
-    let p_id = PkgId::new("foo");
+    let p_id = CrateId::new("foo");
     let workspace = create_local_package(&p_id);
     let workspace = workspace.path();
     let test_sys = test_sysroot();
@@ -1998,7 +1999,7 @@ fn test_target_specific_install_dir() {
 #[test]
 #[ignore(reason = "See #7240")]
 fn test_dependencies_terminate() {
-    let b_id = PkgId::new("b");
+    let b_id = CrateId::new("b");
     let workspace = create_local_package(&b_id);
     let workspace = workspace.path();
     let b_dir = workspace.join_many(["src", "b-0.0"]);
@@ -2011,7 +2012,7 @@ fn test_dependencies_terminate() {
 
 #[test]
 fn install_after_build() {
-    let b_id = PkgId::new("b");
+    let b_id = CrateId::new("b");
     let workspace = create_local_package(&b_id);
     let workspace = workspace.path();
     command_line_test([~"build", ~"b"], workspace);
@@ -2022,7 +2023,7 @@ fn install_after_build() {
 
 #[test]
 fn reinstall() {
-    let b = PkgId::new("b");
+    let b = CrateId::new("b");
     let workspace = create_local_package(&b);
     let workspace = workspace.path();
     // 1. Install, then remove executable file, then install again,
@@ -2061,8 +2062,8 @@ fn correct_package_name_with_rust_path_hack() {
     */
 
     // Set RUST_PATH to something containing only the sources for foo
-    let foo_id = PkgId::new("foo");
-    let bar_id = PkgId::new("bar");
+    let foo_id = CrateId::new("foo");
+    let bar_id = CrateId::new("bar");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
@@ -2091,7 +2092,7 @@ fn correct_package_name_with_rust_path_hack() {
 
 #[test]
 fn test_rustpkg_test_creates_exec() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
@@ -2102,7 +2103,7 @@ fn test_rustpkg_test_creates_exec() {
 
 #[test]
 fn test_rustpkg_test_output() {
-    let workspace = create_local_package_with_test(&PkgId::new("foo"));
+    let workspace = create_local_package_with_test(&CrateId::new("foo"));
     let output = command_line_test([~"test", ~"foo"], workspace.path());
     let output_str = str::from_utf8(output.output);
     // The first two assertions are separate because test output may
@@ -2114,7 +2115,7 @@ fn test_rustpkg_test_output() {
 
 #[test]
 fn test_rustpkg_test_failure_exit_status() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
@@ -2128,7 +2129,7 @@ fn test_rustpkg_test_failure_exit_status() {
 
 #[test]
 fn test_rustpkg_test_cfg() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
@@ -2141,7 +2142,7 @@ fn test_rustpkg_test_cfg() {
 
 #[test]
 fn test_rebuild_when_needed() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
@@ -2162,7 +2163,7 @@ fn test_rebuild_when_needed() {
 #[test]
 #[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute
 fn test_no_rebuilding() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
@@ -2196,7 +2197,7 @@ fn test_installed_read_only() {
     writeFile(&repo_subdir.join("lib.rs"),
               "pub fn f() { let _x = (); }");
     add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
-    // update pkgid to what will be auto-detected
+    // update crateid to what will be auto-detected
     temp_pkg_id.version = ExactRevision(~"0.1");
 
     // FIXME (#9639): This needs to handle non-utf8 paths
@@ -2281,7 +2282,7 @@ fn test_installed_local_changes() {
 
 #[test]
 fn test_7402() {
-    let dir = create_local_package(&PkgId::new("foo"));
+    let dir = create_local_package(&CrateId::new("foo"));
     let dest_workspace = TempDir::new("more_rust").expect("test_7402");
     let dest_workspace = dest_workspace.path();
     // FIXME (#9639): This needs to handle non-utf8 paths
@@ -2295,7 +2296,7 @@ fn test_7402() {
 
 #[test]
 fn test_compile_error() {
-    let foo_id = PkgId::new("foo");
+    let foo_id = CrateId::new("foo");
     let foo_workspace = create_local_package(&foo_id);
     let foo_workspace = foo_workspace.path();
     let main_crate = foo_workspace.join_many(["src", "foo-0.0", "main.rs"]);
@@ -2329,7 +2330,7 @@ fn test_c_dependency_ok() {
     // registers a hook to build it if it's not fresh
     // After running `build`, test that the C library built
 
-    let dir = create_local_package(&PkgId::new("cdep"));
+    let dir = create_local_package(&CrateId::new("cdep"));
     let dir = dir.path();
     writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
               "#[link_args = \"-lfoo\"]\nextern { fn f(); } \
@@ -2352,7 +2353,7 @@ fn test_c_dependency_ok() {
 #[test]
 #[ignore(reason="busted")]
 fn test_c_dependency_no_rebuilding() {
-    let dir = create_local_package(&PkgId::new("cdep"));
+    let dir = create_local_package(&CrateId::new("cdep"));
     let dir = dir.path();
     writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
               "#[link_args = \"-lfoo\"]\nextern { fn f(); } \
@@ -2386,7 +2387,7 @@ fn test_c_dependency_no_rebuilding() {
 #[test]
 #[ignore(reason="busted")]
 fn test_c_dependency_yes_rebuilding() {
-    let dir = create_local_package(&PkgId::new("cdep"));
+    let dir = create_local_package(&CrateId::new("cdep"));
     let dir = dir.path();
     writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
               "#[link_args = \"-lfoo\"]\nextern { fn f(); } \
@@ -2407,7 +2408,7 @@ fn test_c_dependency_yes_rebuilding() {
     assert!(c_library_path.exists());
 
     // Now, make the Rust library read-only so rebuilding will fail
-    match built_library_in_workspace(&PkgId::new("cdep"), dir) {
+    match built_library_in_workspace(&CrateId::new("cdep"), dir) {
         Some(ref pth) => assert!(chmod_read_only(pth)),
         None => assert_built_library_exists(dir, "cdep")
     }
@@ -2425,7 +2426,7 @@ fn test_c_dependency_yes_rebuilding() {
 fn correct_error_dependency() {
     // Supposing a package we're trying to install via a dependency doesn't
     // exist, we should throw a condition, and not ICE
-    let workspace_dir = create_local_package(&PkgId::new("badpkg"));
+    let workspace_dir = create_local_package(&CrateId::new("badpkg"));
 
     let dir = workspace_dir.path();
     let main_rs = dir.join_many(["src", "badpkg-0.0", "main.rs"]);
index eb7dbe4e4a8a73fb6c5f595c538dba78734d6c44..2bb252c362cabdbf90a2ce79a315987f8377107e 100644 (file)
@@ -29,7 +29,7 @@
 use rustc::back::link::output_type_exe;
 use rustc::back::link;
 use context::{in_target, StopBefore, Link, Assemble, BuildContext};
-use package_id::PkgId;
+use crate_id::CrateId;
 use package_source::PkgSrc;
 use workspace::pkg_parent_workspaces;
 use path_util::{system_library, target_build_dir};
@@ -52,7 +52,7 @@
 pub type ExitCode = int; // For now
 
 pub struct Pkg {
-    id: PkgId,
+    id: CrateId,
     bins: ~[~str],
     libs: ~[~str],
 }
@@ -170,7 +170,7 @@ pub fn ready_crate(sess: session::Session,
 
 pub fn compile_input(context: &BuildContext,
                      exec: &mut workcache::Exec,
-                     pkg_id: &PkgId,
+                     pkg_id: &CrateId,
                      in_file: &Path,
                      workspace: &Path,
                      deps: &mut DepMap,
@@ -303,17 +303,17 @@ pub fn compile_input(context: &BuildContext,
                                       addl_lib_search_paths.get().insert(p);
                                   });
 
-    // Inject the pkgid attribute so we get the right package name and version
+    // Inject the crate_id attribute so we get the right package name and version
     if !attr::contains_name(crate.attrs, "crate_id") {
         // FIXME (#9639): This needs to handle non-utf8 paths
-        let pkgid_attr =
+        let crateid_attr =
             attr::mk_name_value_item_str(@"crate_id",
                                          format!("{}\\#{}",
                                                  pkg_id.path.as_str().unwrap(),
                                                  pkg_id.version.to_str()).to_managed());
 
-        debug!("pkgid attr: {:?}", pkgid_attr);
-        crate.attrs.push(attr::mk_attr(pkgid_attr));
+        debug!("crateid attr: {:?}", crateid_attr);
+        crate.attrs.push(attr::mk_attr(crateid_attr));
     }
 
     debug!("calling compile_crate_from_input, workspace = {},
@@ -428,7 +428,7 @@ pub fn exe_suffix() -> ~str { ~"" }
 // Called by build_crates
 pub fn compile_crate(ctxt: &BuildContext,
                      exec: &mut workcache::Exec,
-                     pkg_id: &PkgId,
+                     pkg_id: &CrateId,
                      crate: &Path,
                      workspace: &Path,
                      deps: &mut DepMap,
@@ -446,7 +446,7 @@ pub fn compile_crate(ctxt: &BuildContext,
 
 struct ViewItemVisitor<'a> {
     context: &'a BuildContext,
-    parent: &'a PkgId,
+    parent: &'a CrateId,
     parent_crate: &'a Path,
     sess: session::Session,
     exec: &'a mut workcache::Exec,
@@ -491,7 +491,7 @@ fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) {
                         debug!("Trying to install library {}, rebuilding it",
                                lib_name.to_str());
                         // Try to install it
-                        let pkg_id = PkgId::new(lib_name);
+                        let pkg_id = CrateId::new(lib_name);
                         // Find all the workspaces in the RUST_PATH that contain this package.
                         let workspaces = pkg_parent_workspaces(&self.context.context,
                                                                &pkg_id);
@@ -607,7 +607,7 @@ fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) {
 /// try to install their targets, failing if any target
 /// can't be found.
 pub fn find_and_install_dependencies(context: &BuildContext,
-                                     parent: &PkgId,
+                                     parent: &CrateId,
                                      parent_crate: &Path,
                                      sess: session::Session,
                                      exec: &mut workcache::Exec,
index 95fc667727240bbb0f0fc7279e8e9220299a7eb4..d6e617d2d5071fbdc9fa1b7a042d28ab24328f6c 100644 (file)
 use std::os;
 use std::path::Path;
 use context::Context;
-use path_util::{workspace_contains_package_id, find_dir_using_rust_path_hack, default_workspace};
+use path_util::{workspace_contains_crate_id, find_dir_using_rust_path_hack, default_workspace};
 use path_util::rust_path;
 use util::option_to_vec;
-use package_id::PkgId;
+use crate_id::CrateId;
 
 pub fn each_pkg_parent_workspace(cx: &Context,
-                                 pkgid: &PkgId,
+                                 crateid: &CrateId,
                                  action: |&Path| -> bool)
                                  -> bool {
     // Using the RUST_PATH, find workspaces that contain
     // this package ID
-    let workspaces = pkg_parent_workspaces(cx, pkgid);
+    let workspaces = pkg_parent_workspaces(cx, crateid);
     if workspaces.is_empty() {
         // tjc: make this a condition
         fail!("Package {} not found in any of \
                     the following workspaces: {}",
-                   pkgid.path.display(),
+                   crateid.path.display(),
                    rust_path().map(|p| p.display().to_str()).to_str());
     }
     for ws in workspaces.iter() {
@@ -42,12 +42,12 @@ pub fn each_pkg_parent_workspace(cx: &Context,
 
 /// Given a package ID, return a vector of all of the workspaces in
 /// the RUST_PATH that contain it
-pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
+pub fn pkg_parent_workspaces(cx: &Context, crateid: &CrateId) -> ~[Path] {
     let rs: ~[Path] = rust_path().move_iter()
-        .filter(|ws| workspace_contains_package_id(pkgid, ws))
+        .filter(|ws| workspace_contains_crate_id(crateid, ws))
         .collect();
     if cx.use_rust_path_hack {
-        rs + option_to_vec(find_dir_using_rust_path_hack(pkgid))
+        rs + option_to_vec(find_dir_using_rust_path_hack(crateid))
     }
     else {
         rs
@@ -56,7 +56,7 @@ pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
 
 /// Construct a workspace and package-ID name based on the current directory.
 /// This gets used when rustpkg gets invoked without a package-ID argument.
-pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
+pub fn cwd_to_workspace() -> Option<(Path, CrateId)> {
     let cwd = os::getcwd();
     for path in rust_path().move_iter() {
         let srcpath = path.join("src");
@@ -64,7 +64,7 @@ pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
             let rel = cwd.path_relative_from(&srcpath);
             let rel_s = rel.as_ref().and_then(|p|p.as_str());
             if rel_s.is_some() {
-                return Some((path, PkgId::new(rel_s.unwrap())));
+                return Some((path, CrateId::new(rel_s.unwrap())));
             }
         }
     }
index 4ab0ac6386e4c4fe75cff9206f8f64154b3f8746..3b8eda8f78388ee69aa2ae5d251d433d5ea6b25a 100644 (file)
@@ -8,14 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub struct PkgId {
+pub struct CrateId {
     local_path: ~str,
     junk: ~str
 }
 
-impl PkgId {
-    fn new(s: &str) -> PkgId {
-        PkgId {
+impl CrateId {
+    fn new(s: &str) -> CrateId {
+        CrateId {
             local_path: s.to_owned(),
             junk: ~"wutevs"
         }
@@ -23,8 +23,8 @@ fn new(s: &str) -> PkgId {
 }
 
 pub fn remove_package_from_database() {
-    let mut lines_to_use: ~[&PkgId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
-    let push_id = |installed_id: &PkgId| {
+    let mut lines_to_use: ~[&CrateId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
+    let push_id = |installed_id: &CrateId| {
         lines_to_use.push(installed_id);
     };
     list_database(push_id);
@@ -35,11 +35,11 @@ pub fn remove_package_from_database() {
 
 }
 
-pub fn list_database(f: |&PkgId|) {
+pub fn list_database(f: |&CrateId|) {
     let stuff = ["foo", "bar"];
 
     for l in stuff.iter() {
-        f(&PkgId::new(*l));
+        f(&CrateId::new(*l));
     }
 }