rustpkg: Preliminary work on install command

Mostly just tests (that are ignored); install command is still
stubbed out.
This commit is contained in:
Tim Chevalier 2013-04-24 17:37:59 -07:00
parent f945e57bd0
commit 4e2c8f422a
6 changed files with 175 additions and 30 deletions

View file

@ -36,14 +36,19 @@ use rustc::metadata::filesearch;
use std::{getopts};
use syntax::{ast, diagnostic};
use util::*;
use path_util::{normalize, workspace_contains_package_id};
use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace, rust_path};
use path_util::normalize;
use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace};
use workspace::pkg_parent_workspaces;
use rustc::driver::session::{lib_crate, bin_crate, crate_type};
use context::Ctx;
mod conditions;
mod context;
mod usage;
mod path_util;
mod tests;
mod util;
mod workspace;
/// A PkgScript represents user-supplied custom logic for
/// special build hooks. This only exists for packages with
@ -154,14 +159,6 @@ impl PkgScript {
}
struct Ctx {
// I'm not sure what this is for
json: bool,
// Cache of hashes of things already installed
// though I'm not sure why the value is a bool
dep_cache: @mut HashMap<~str, bool>,
}
impl Ctx {
fn run(&self, cmd: ~str, args: ~[~str]) {
@ -194,17 +191,7 @@ impl Ctx {
// The package id is presumed to be the first command-line
// argument
let pkgid = PkgId::new(args[0]);
// Using the RUST_PATH, find workspaces that contain
// this package ID
let workspaces = rust_path().filtered(|ws|
workspace_contains_package_id(pkgid, ws));
if workspaces.is_empty() {
fail!(fmt!("Package %s not found in any of \
the following workspaces: %s",
pkgid.path.to_str(),
rust_path().to_str()));
}
for workspaces.each |workspace| {
for pkg_parent_workspaces(pkgid) |workspace| {
let src_dir = pkgid_src_in_workspace(pkgid, workspace);
let build_dir = build_pkg_id_in_workspace(pkgid, workspace);
debug!("Destination dir = %s", build_dir.to_str());
@ -271,10 +258,16 @@ impl Ctx {
self.info();
}
~"install" => {
self.install(if args.len() >= 1 { Some(args[0]) }
else { None },
if args.len() >= 2 { Some(args[1]) }
else { None }, false);
if args.len() < 1 {
return usage::install();
}
// The package id is presumed to be the first command-line
// argument
let pkgid = PkgId::new(args[0]);
for pkg_parent_workspaces(pkgid) |workspace| {
self.install(workspace, pkgid);
}
}
~"prefer" => {
if args.len() < 1 {
@ -310,9 +303,9 @@ impl Ctx {
}
}
fn do_cmd(&self, cmd: ~str, pkgname: ~str) {
fn do_cmd(&self, _cmd: ~str, _pkgname: ~str) {
// stub
fail!("`do` not yet implemented");
fail!(~"`do` not yet implemented");
}
fn clean(&self, workspace: &Path, id: PkgId) {
@ -336,8 +329,7 @@ impl Ctx {
fail!(~"info not yet implemented");
}
fn install(&self, _url: Option<~str>,
_target: Option<~str>, _cache: bool) {
fn install(&self, _workspace: &Path, _id: PkgId) {
// stub
fail!(~"install not yet implemented");
}