@@ -36,14 +36,19 @@ use rustc::metadata::filesearch;
36
36
use std::{getopts};
37
37
use syntax::{ast, diagnostic};
38
38
use util::*;
39
- use path_util::{normalize, workspace_contains_package_id};
40
- use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace, rust_path};
39
+ use path_util::normalize;
40
+ use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace};
41
+ use workspace::pkg_parent_workspaces;
41
42
use rustc::driver::session::{lib_crate, bin_crate, crate_type};
43
+ use context::Ctx;
42
44
43
45
mod conditions;
46
+ mod context;
44
47
mod usage;
45
48
mod path_util;
49
+ mod tests;
46
50
mod util;
51
+ mod workspace;
47
52
48
53
/// A PkgScript represents user-supplied custom logic for
49
54
/// special build hooks. This only exists for packages with
@@ -154,14 +159,6 @@ impl PkgScript {
154
159
155
160
}
156
161
157
- struct Ctx {
158
- // I'm not sure what this is for
159
- json: bool,
160
- // Cache of hashes of things already installed
161
- // though I'm not sure why the value is a bool
162
- dep_cache: @mut HashMap<~str, bool>,
163
- }
164
-
165
162
impl Ctx {
166
163
167
164
fn run(&self, cmd: ~str, args: ~[~str]) {
@@ -194,17 +191,7 @@ impl Ctx {
194
191
// The package id is presumed to be the first command-line
195
192
// argument
196
193
let pkgid = PkgId::new(args[0]);
197
- // Using the RUST_PATH, find workspaces that contain
198
- // this package ID
199
- let workspaces = rust_path().filtered(|ws|
200
- workspace_contains_package_id(pkgid, ws));
201
- if workspaces.is_empty() {
202
- fail!(fmt!("Package %s not found in any of \
203
- the following workspaces: %s",
204
- pkgid.path.to_str(),
205
- rust_path().to_str()));
206
- }
207
- for workspaces.each |workspace| {
194
+ for pkg_parent_workspaces(pkgid) |workspace| {
208
195
let src_dir = pkgid_src_in_workspace(pkgid, workspace);
209
196
let build_dir = build_pkg_id_in_workspace(pkgid, workspace);
210
197
debug!("Destination dir = %s", build_dir.to_str());
@@ -271,10 +258,16 @@ impl Ctx {
271
258
self.info();
272
259
}
273
260
~"install" => {
274
- self.install(if args.len() >= 1 { Some(args[0]) }
275
- else { None },
276
- if args.len() >= 2 { Some(args[1]) }
277
- else { None }, false);
261
+ if args.len() < 1 {
262
+ return usage::install();
263
+ }
264
+
265
+ // The package id is presumed to be the first command-line
266
+ // argument
267
+ let pkgid = PkgId::new(args[0]);
268
+ for pkg_parent_workspaces(pkgid) |workspace| {
269
+ self.install(workspace, pkgid);
270
+ }
278
271
}
279
272
~"prefer" => {
280
273
if args.len() < 1 {
@@ -310,9 +303,9 @@ impl Ctx {
310
303
}
311
304
}
312
305
313
- fn do_cmd(&self, cmd : ~str, pkgname : ~str) {
306
+ fn do_cmd(&self, _cmd : ~str, _pkgname : ~str) {
314
307
// stub
315
- fail!("`do` not yet implemented");
308
+ fail!(~ "`do` not yet implemented");
316
309
}
317
310
318
311
fn clean(&self, workspace: &Path, id: PkgId) {
@@ -336,8 +329,7 @@ impl Ctx {
336
329
fail!(~"info not yet implemented");
337
330
}
338
331
339
- fn install(&self, _url: Option<~str>,
340
- _target: Option<~str>, _cache: bool) {
332
+ fn install(&self, _workspace: &Path, _id: PkgId) {
341
333
// stub
342
334
fail!(~"install not yet implemented");
343
335
}
0 commit comments