"""
// 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)];
"""
use context::*;
use crate::*;
-use package_id::*;
+use crate_id::*;
use package_source::*;
use path_util::{platform_library_name, target_build_dir};
use target::*;
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: ~[],
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)],
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 });
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()
});
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()));
}
// 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! {
--- /dev/null
+// 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()
+}
+
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 = {
match exec.filestem_str() {
None => (),
Some(exec_path) => {
- if !f(&PkgId::new(exec_path)) {
+ if !f(&CrateId::new(exec_path)) {
return false;
}
}
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 => ()
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 {
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};
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;
/// 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
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
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
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,
}
}
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,
} 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]) {
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" => {
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));
}
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 {
let src = PkgSrc::new(workspace.clone(),
dest,
self.context.use_rust_path_hack,
- pkgid.clone());
+ crateid.clone());
self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
};
}
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;
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
});
}
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
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(),
}
}
- 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
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());
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
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()));
}
}
}
+++ /dev/null
-// 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()
-}
-
extern mod extra;
use target::*;
-use package_id::PkgId;
+use crate_id::CrateId;
use std::io;
use std::io::fs;
use std::os;
// 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],
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 {}, \
// 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,
/// 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;
#[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;
// 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() {
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)
}
}
})
}
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
}
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() {
}
}
-/// 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() {
}
}
-/// 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
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;
// 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;
}
/// 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
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()));
}
}
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
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,
}
}
-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)
}
}
-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);
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
}
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);
}
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 => ()
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)
}
#[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") {
}
#[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") {
}
/// 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);
#[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);
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()
#[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();
}
#[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;
/*
*/
- 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());
})
}
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);
}
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"]));
#[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");
}
#[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();
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()));
}
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...
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);
// 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());
}
#[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);
#[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);
#[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);
#[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);
#[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);
#[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
#[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());
}
#[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"));
#[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"]),
#[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"]),
// 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);
}
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");
#[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);
#[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
#[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();
#[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();
#[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",
#[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",
#[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();
#[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();
#[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
#[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"]),
#[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();
#[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();
#[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();
#[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();
#[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());
#[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();
}
#[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");
#[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"]),
#[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");
#[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();
#[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();
#[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"]);
#[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);
#[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,
*/
// 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");
#[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"]),
#[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
#[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"]),
#[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"]),
#[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"]);
#[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"]);
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
#[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
#[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"]);
// 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(); } \
#[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(); } \
#[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(); } \
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")
}
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"]);
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};
pub type ExitCode = int; // For now
pub struct Pkg {
- id: PkgId,
+ id: CrateId,
bins: ~[~str],
libs: ~[~str],
}
pub fn compile_input(context: &BuildContext,
exec: &mut workcache::Exec,
- pkg_id: &PkgId,
+ pkg_id: &CrateId,
in_file: &Path,
workspace: &Path,
deps: &mut DepMap,
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 = {},
// 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,
struct ViewItemVisitor<'a> {
context: &'a BuildContext,
- parent: &'a PkgId,
+ parent: &'a CrateId,
parent_crate: &'a Path,
sess: session::Session,
exec: &'a mut workcache::Exec,
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);
/// 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,
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() {
/// 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
/// 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");
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())));
}
}
}
// 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"
}
}
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);
}
-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));
}
}