]> git.lizzy.rs Git - rust.git/commitdiff
rustpkg: Address review comments from Jack
authorTim Chevalier <chevalier@alum.wellesley.edu>
Mon, 9 Sep 2013 05:00:49 +0000 (22:00 -0700)
committerTim Chevalier <chevalier@alum.wellesley.edu>
Mon, 9 Sep 2013 05:00:49 +0000 (22:00 -0700)
src/librustpkg/api.rs
src/librustpkg/context.rs
src/librustpkg/package_source.rs
src/librustpkg/path_util.rs
src/librustpkg/rustpkg.rs
src/librustpkg/tests.rs
src/librustpkg/util.rs
src/librustpkg/workspace.rs

index 42e5668489aa65a4ca37a98c1475b80a969ad045..4de2572be7d5e2ac6c0bac04197552e7c40baacd 100644 (file)
 
 use extra::arc::{Arc,RWArc};
 use extra::workcache;
-use extra::workcache::*;
-use std::os;
+use extra::workcache::{Database, Logger, FreshnessMap};
 use extra::treemap::TreeMap;
 
 /// Convenience functions intended for calling from pkg.rs
 /// p is where to put the cache file for dependencies
-pub fn default_ctxt(p: Path) -> BuildCtx {
-    new_default_ctx(new_workcache_cx(&p), p)
+pub fn default_context(p: Path) -> BuildContext {
+    new_default_context(new_workcache_context(&p), p)
 }
 
-pub fn new_default_ctx(c: Context, p: Path) -> BuildCtx {
-    BuildCtx {
-        cx: Ctx { use_rust_path_hack: false,
-                  sysroot_opt: p },
-        workcache_cx: c
+pub fn new_default_context(c: workcache::Context, p: Path) -> BuildContext {
+    BuildContext {
+        context: Context {
+            use_rust_path_hack: false,
+            sysroot: p
+        },
+        workcache_context: c
     }
 }
 
@@ -44,27 +45,27 @@ fn binary_is_fresh(path: &str, in_hash: &str) -> bool {
 }
 
 
-pub fn new_workcache_cx(p: &Path) -> Context {
+pub fn new_workcache_context(p: &Path) -> workcache::Context {
     let db_file = p.push("rustpkg_db.json"); // ??? probably wrong
     debug!("Workcache database file: %s", db_file.to_str());
     let db = RWArc::new(Database::new(db_file));
     let lg = RWArc::new(Logger::new());
     let cfg = Arc::new(TreeMap::new());
-    let mut rslt: FreshnessMap = TreeMap::new();
+    let mut freshness: FreshnessMap = TreeMap::new();
     // Set up freshness functions for every type of dependency rustpkg
     // knows about
-    rslt.insert(~"file", file_is_fresh);
-    rslt.insert(~"binary", binary_is_fresh);
-    workcache::Context::new_with_freshness(db, lg, cfg, Arc::new(rslt))
+    freshness.insert(~"file", file_is_fresh);
+    freshness.insert(~"binary", binary_is_fresh);
+    workcache::Context::new_with_freshness(db, lg, cfg, Arc::new(freshness))
 }
 
 pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
                  lib: Path) {
-    let cx = default_ctxt(sysroot);
+    let cx = default_context(sysroot);
     let subroot = root.clone();
     let subversion = version.clone();
     let sublib = lib.clone();
-    do cx.workcache_cx.with_prep(name) |prep| {
+    do cx.workcache_context.with_prep(name) |prep| {
         let pkg_src = PkgSrc {
             workspace: subroot.clone(),
             start_dir: subroot.push("src").push(name),
@@ -78,17 +79,17 @@ pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
         let subcx = cx.clone();
         let subsrc = pkg_src.clone();
         do prep.exec |exec| {
-            subsrc.clone().build(exec, &subcx.clone(), ~[]);
+            subsrc.build(exec, &subcx.clone(), ~[]);
         }
     };
 }
 
 pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
                  main: Path) {
-    let cx = default_ctxt(sysroot);
+    let cx = default_context(sysroot);
     let subroot = root.clone();
     let submain = main.clone();
-    do cx.workcache_cx.with_prep(name) |prep| {
+    do cx.workcache_context.with_prep(name) |prep| {
         let pkg_src = PkgSrc {
             workspace: subroot.clone(),
             start_dir: subroot.push("src").push(name),
@@ -107,41 +108,8 @@ pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
     }
 }
 
-pub fn install_lib(sysroot: Path,
-                   workspace: Path,
-                   name: ~str,
-                   lib_path: Path,
-                   version: Version) {
-    debug!("self_exe: %?", os::self_exe_path());
-    debug!("sysroot = %s", sysroot.to_str());
-    debug!("workspace = %s", workspace.to_str());
-    // make a PkgSrc
-    let pkg_id = PkgId{ version: version, ..PkgId::new(name)};
-    let cx = default_ctxt(sysroot);
-    let subpath = lib_path.clone();
-    do cx.workcache_cx.with_prep(pkg_id.to_str()) |prep| {
-        let pkg_src = PkgSrc {
-            workspace: workspace.clone(),
-            start_dir: subpath.push("src").push(name),
-            id: pkg_id.clone(),
-            libs: ~[mk_crate(subpath.clone())],
-            mains: ~[],
-            tests: ~[],
-            benchs: ~[]
-        };
-        pkg_src.declare_inputs(prep);
-        let subcx = cx.clone();
-        let subpkg_src = pkg_src.clone();
-        do prep.exec |exec| {
-            subpkg_src.clone().build(exec, &subcx.clone(), ~[]);
-        }
-    }
-    cx.install_no_build(&workspace, &pkg_id);
-}
-
-pub fn install_exe(sysroot: Path, workspace: Path, name: ~str, version: Version) {
-    let cx = default_ctxt(sysroot);
-    debug!("install_exe calling with_prep");
+pub fn install_pkg(sysroot: Path, workspace: Path, name: ~str, version: Version) {
+    let cx = default_context(sysroot);
     let pkgid = PkgId{ version: version, ..PkgId::new(name)};
     cx.install(PkgSrc::new(workspace, false, pkgid));
 }
index 70f1e39efec23ef6fc665211ec6093c2f74b9ed0..2c6454cd2c664f6d812adc19d3dd9cf9ae4b17b9 100644 (file)
 use extra::workcache;
 
 #[deriving(Clone)]
-pub struct Ctx {
+pub struct Context {
     // If use_rust_path_hack is true, rustpkg searches for sources
     // in *package* directories that are in the RUST_PATH (for example,
     // FOO/src/bar-0.1 instead of FOO). The flag doesn't affect where
     // rustpkg stores build artifacts.
     use_rust_path_hack: bool,
     // The root directory containing the Rust standard libraries
-    sysroot_opt: Path
+    sysroot: Path
 }
 
 #[deriving(Clone)]
-pub struct BuildCtx {
+pub struct BuildContext {
     // Context for workcache
-    workcache_cx: workcache::Context,
+    workcache_context: workcache::Context,
     // Everything else
-    cx: Ctx
+    context: Context
 }
 
-impl BuildCtx {
-    pub fn sysroot_opt(&self) -> Path {
-        self.cx.sysroot_opt.clone()
+impl BuildContext {
+    pub fn sysroot(&self) -> Path {
+        self.context.sysroot.clone()
     }
 
     pub fn sysroot_to_use(&self) -> Path {
-        self.cx.sysroot_to_use()
+        self.context.sysroot_to_use()
     }
 }
 
-impl Ctx {
-    pub fn sysroot_opt(&self) -> Path {
-        self.sysroot_opt.clone()
+impl Context {
+    pub fn sysroot(&self) -> Path {
+        self.sysroot.clone()
     }
 }
 
-impl Ctx {
+impl Context {
     /// Debugging
-    pub fn sysroot_opt_str(&self) -> ~str {
-        self.sysroot_opt.to_str()
+    pub fn sysroot_str(&self) -> ~str {
+        self.sysroot.to_str()
     }
 
     // Hack so that rustpkg can run either out of a rustc target dir,
     // or the host dir
     pub fn sysroot_to_use(&self) -> Path {
-        if !in_target(&self.sysroot_opt) {
-            self.sysroot_opt.clone()
+        if !in_target(&self.sysroot) {
+            self.sysroot.clone()
+        } else {
+            self.sysroot.pop().pop().pop()
         }
-        else {
-            self.sysroot_opt.pop().pop().pop()
-        }
-  }
+    }
 }
 
 /// We assume that if ../../rustc exists, then we're running
 /// rustpkg from a Rust target directory. This is part of a
 /// kludgy hack used to adjust the sysroot.
-pub fn in_target(sysroot_opt: &Path) -> bool {
-    debug!("Checking whether %s is in target", sysroot_opt.to_str());
-    os::path_is_dir(&sysroot_opt.pop().pop().push("rustc"))
+pub fn in_target(sysroot: &Path) -> bool {
+    debug!("Checking whether %s is in target", sysroot.to_str());
+    os::path_is_dir(&sysroot.pop().pop().push("rustc"))
 }
index 45932283081b739c50a54b623ff43d55e3ade099..946707288c43deed901a4d5f269baeeda6f4c04b 100644 (file)
 // This contains a list of files found in the source workspace.
 #[deriving(Clone)]
 pub struct PkgSrc {
-    workspace: Path, // root of where the package source code lives
-    start_dir: Path, // dir to start looking in for packages -- normally
-                     // this is workspace/src/id but it may be just workspace
+    /// Root of where the package source code lives
+    workspace: Path,
+    // Directory to start looking in for packages -- normally
+    // this is workspace/src/id but it may be just workspace
+    start_dir: Path,
     id: PkgId,
     libs: ~[Crate],
     mains: ~[Crate],
@@ -61,8 +63,7 @@ pub fn new(workspace: Path, use_rust_path_hack: bool, id: PkgId) -> PkgSrc {
         let mut to_try = ~[];
         if use_rust_path_hack {
             to_try.push(workspace.clone());
-        }
-        else {
+        } else {
             let result = workspace.push("src").push_rel(&id.path.pop()).push(fmt!("%s-%s",
                                                          id.short_name, id.version.to_str()));
             to_try.push(result);
@@ -251,7 +252,7 @@ pub fn find_crates(&mut self) {
     }
 
     fn build_crates(&self,
-                    ctx: &BuildCtx,
+                    ctx: &BuildContext,
                     exec: &mut workcache::Exec,
                     destination_dir: &Path,
                     crates: &[Crate],
@@ -263,23 +264,17 @@ fn build_crates(&self,
             let path_str = path.to_str();
             let cfgs = crate.cfgs + cfgs;
 
-            let result = {
+            let result =
                 // compile_crate should return the path of the output artifact
-                match compile_crate(ctx,
-                                  exec,
-                                  &self.id,
-                                  &path,
-                                  destination_dir,
-                                  crate.flags,
-                                  cfgs,
-                                  false,
-                                  what).map(|p| p.to_str()) {
-                    Some(p) => p,
-                    None   => build_err::cond.raise(fmt!("build failure on %s",
-                                                         path_str))
-
-                }
-            };
+                compile_crate(ctx,
+                              exec,
+                              &self.id,
+                              &path,
+                              destination_dir,
+                              crate.flags,
+                              cfgs,
+                              false,
+                              what).to_str();
             debug!("Result of compiling %s was %s", path_str, result);
         }
     }
@@ -301,7 +296,10 @@ pub fn declare_inputs(&self, prep: &mut workcache::Prep) {
 
     // It would be better if build returned a Path, but then Path would have to derive
     // Encodable.
-    pub fn build(&self, exec: &mut workcache::Exec, ctx: &BuildCtx, cfgs: ~[~str]) -> ~str {
+    pub fn build(&self,
+                 exec: &mut workcache::Exec,
+                 build_context: &BuildContext,
+                 cfgs: ~[~str]) -> ~str {
         use conditions::not_a_workspace::cond;
 
         // Determine the destination workspace (which depends on whether
@@ -309,16 +307,14 @@ pub fn build(&self, exec: &mut workcache::Exec, ctx: &BuildCtx, cfgs: ~[~str]) -
         let destination_workspace = if is_workspace(&self.workspace) {
             debug!("%s is indeed a workspace", self.workspace.to_str());
             self.workspace.clone()
-        }
-            else {
+        } else {
             // It would be nice to have only one place in the code that checks
             // for the use_rust_path_hack flag...
-            if ctx.cx.use_rust_path_hack {
+            if build_context.context.use_rust_path_hack {
                 let rs = default_workspace();
                 debug!("Using hack: %s", rs.to_str());
                 rs
-            }
-            else {
+            } else {
                 cond.raise(fmt!("Package root %s is not a workspace; pass in --rust_path_hack \
                                         if you want to treat it as a package source",
                                 self.workspace.to_str()))
@@ -331,13 +327,13 @@ pub fn build(&self, exec: &mut workcache::Exec, ctx: &BuildCtx, cfgs: ~[~str]) -
         let benchs = self.benchs.clone();
         debug!("Building libs in %s, destination = %s",
                destination_workspace.to_str(), destination_workspace.to_str());
-        self.build_crates(ctx, exec, &destination_workspace, libs, cfgs, Lib);
+        self.build_crates(build_context, exec, &destination_workspace, libs, cfgs, Lib);
         debug!("Building mains");
-        self.build_crates(ctx, exec, &destination_workspace, mains, cfgs, Main);
+        self.build_crates(build_context, exec, &destination_workspace, mains, cfgs, Main);
         debug!("Building tests");
-        self.build_crates(ctx, exec, &destination_workspace, tests, cfgs, Test);
+        self.build_crates(build_context, exec, &destination_workspace, tests, cfgs, Test);
         debug!("Building benches");
-        self.build_crates(ctx, exec, &destination_workspace, benchs, cfgs, Bench);
+        self.build_crates(build_context, exec, &destination_workspace, benchs, cfgs, Bench);
         destination_workspace.to_str()
     }
 }
index 566e75df548c0d5ec230376a5f8c4c920918a66f..1b732354f11b8c985e5272375b2bb64271480718 100644 (file)
@@ -84,8 +84,7 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
 
     if found.is_some() {
         debug!("Found %s in %s", pkgid.to_str(), workspace.to_str());
-    }
-    else {
+    } else {
         debug!("Didn't find %s in %s", pkgid.to_str(), workspace.to_str());
     }
     found
index 27bde2bca6d33c2775acb1a6e765d66355d0d4e2..331dfcd692a19d2682ac3e78e8c8d18824ff18fd 100644 (file)
@@ -40,7 +40,7 @@
 use path_util::{target_executable_in_workspace, target_library_in_workspace};
 use source_control::is_git_dir;
 use workspace::{each_pkg_parent_workspace, pkg_parent_workspaces, cwd_to_workspace};
-use context::{BuildCtx, Ctx};
+use context::{BuildContext, Context};
 use package_id::PkgId;
 use package_source::PkgSrc;
 use workcache_support::{discover_outputs, digest_only_date};
@@ -174,6 +174,8 @@ pub trait CtxMethods {
     fn build(&self, exec: &mut workcache::Exec, pkg_src: PkgSrc) -> Path;
     fn clean(&self, workspace: &Path, id: &PkgId);
     fn info(&self);
+    /// Returns a pair. First component is a list of installed paths,
+    /// second is a list of declared and discovered inputs
     fn install(&self, src: PkgSrc) -> (~[Path], ~[(~str, ~str)]);
     /// Returns a list of installed files
     fn install_no_build(&self, workspace: &Path, id: &PkgId) -> ~[Path];
@@ -183,11 +185,11 @@ pub trait CtxMethods {
     fn unprefer(&self, _id: &str, _vers: Option<~str>);
 }
 
-impl CtxMethods for BuildCtx {
+impl CtxMethods for BuildContext {
     fn build_from_src(&self, pkg_src: PkgSrc) {
         let tag = pkg_src.id.to_str();
         debug!("package source = %s", pkg_src.to_str());
-        do self.workcache_cx.with_prep(tag) |prep| {
+        do self.workcache_context.with_prep(tag) |prep| {
             let subsrc = pkg_src.clone();
             let subself = self.clone();
             declare_package_script_dependency(prep, &subsrc);
@@ -203,7 +205,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
             "build" => {
                 if args.len() < 1 {
                     match cwd_to_workspace() {
-                        None if self.cx.use_rust_path_hack => {
+                        None if self.context.use_rust_path_hack => {
                             let cwd = os::getcwd();
                             let pkgid = PkgId::new(cwd.components[cwd.components.len() - 1]);
                             self.build_from_src(PkgSrc::new(cwd, true, pkgid));
@@ -218,7 +220,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                     // The package id is presumed to be the first command-line
                     // argument
                     let pkgid = PkgId::new(args[0].clone());
-                    do each_pkg_parent_workspace(&self.cx, &pkgid) |workspace| {
+                    do each_pkg_parent_workspace(&self.context, &pkgid) |workspace| {
                         debug!("found pkg %s in workspace %s, trying to build",
                                pkgid.to_str(), workspace.to_str());
                         let pkg_src = PkgSrc::new(workspace.clone(), false, pkgid.clone());
@@ -258,7 +260,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
             "install" => {
                if args.len() < 1 {
                     match cwd_to_workspace() {
-                        None if self.cx.use_rust_path_hack => {
+                        None if self.context.use_rust_path_hack => {
                             let cwd = os::getcwd();
                             let inferred_pkgid =
                                 PkgId::new(cwd.components[cwd.components.len() - 1]);
@@ -275,7 +277,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                     // The package id is presumed to be the first command-line
                     // argument
                     let pkgid = PkgId::new(args[0]);
-                    let workspaces = pkg_parent_workspaces(&self.cx, &pkgid);
+                    let workspaces = pkg_parent_workspaces(&self.context, &pkgid);
                     debug!("package ID = %s, found it in %? workspaces",
                            pkgid.to_str(), workspaces.len());
                     if workspaces.is_empty() {
@@ -287,7 +289,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                     else {
                         for workspace in workspaces.iter() {
                             let src = PkgSrc::new(workspace.clone(),
-                                                  self.cx.use_rust_path_hack,
+                                                  self.context.use_rust_path_hack,
                                                   pkgid.clone());
                             self.install(src);
                         };
@@ -324,7 +326,7 @@ fn run(&self, cmd: &str, args: ~[~str]) {
                 else {
                     let rp = rust_path();
                     assert!(!rp.is_empty());
-                    do each_pkg_parent_workspace(&self.cx, &pkgid) |workspace| {
+                    do each_pkg_parent_workspace(&self.context, &pkgid) |workspace| {
                         path_util::uninstall_package_from(workspace, &pkgid);
                         note(fmt!("Uninstalled package %s (was installed in %s)",
                                   pkgid.to_str(), workspace.to_str()));
@@ -350,9 +352,7 @@ fn do_cmd(&self, _cmd: &str, _pkgname: &str)  {
 
     /// Returns the destination workspace
     /// In the case of a custom build, we don't know, so we just return the source workspace
-    fn build(&self, exec: &mut workcache::Exec, pkg_src: PkgSrc) -> Path {
-
-        let pkg_src = &mut pkg_src.clone(); // :-o
+    fn build(&self, exec: &mut workcache::Exec, mut pkg_src: PkgSrc) -> Path {
         let workspace = pkg_src.workspace.clone();
         let pkgid = pkg_src.id.clone();
 
@@ -438,8 +438,6 @@ fn info(&self) {
         fail!("info not yet implemented");
     }
 
-    /// Returns a pair. First component is a list of installed paths,
-    /// second is a list of declared and discovered inputs
     fn install(&self, pkg_src: PkgSrc) -> (~[Path], ~[(~str, ~str)]) {
 
         let id = &pkg_src.id;
@@ -447,7 +445,8 @@ fn install(&self, pkg_src: PkgSrc) -> (~[Path], ~[(~str, ~str)]) {
         let installed_files = RWArc::new(~[]);
         let inputs = RWArc::new(~[]);
         // FIXME #7402: Use RUST_PATH to determine target dir
-        let f: &fn(&mut workcache::Prep) = |prep| {
+        self.workcache_context.with_prep(id.to_str(), |p| pkg_src.declare_inputs(p));
+        do self.workcache_context.with_prep(id.to_str()) |prep| {
             let sub_inputs = inputs.clone();
             let sub_files  = installed_files.clone();
             let subsrc = pkg_src.clone();
@@ -473,8 +472,6 @@ fn install(&self, pkg_src: PkgSrc) -> (~[Path], ~[(~str, ~str)]) {
                 sub_inputs.write(|r| { *r = *r + exec.lookup_discovered_inputs() });
             }
         };
-        self.workcache_cx.with_prep(id.to_str(), |p| pkg_src.declare_inputs(p));
-        self.workcache_cx.with_prep(id.to_str(), f);
         (installed_files.unwrap(), inputs.unwrap())
     }
 
@@ -609,12 +606,12 @@ pub fn main_args(args: &[~str]) {
     let sroot = filesearch::get_or_default_sysroot();
     debug!("Using sysroot: %s", sroot.to_str());
     debug!("Will store workcache in %s", default_workspace().to_str());
-    BuildCtx {
-        cx: Ctx {
-           use_rust_path_hack: use_rust_path_hack,
-            sysroot_opt: sroot, // Currently, only tests override this
+    BuildContext {
+        context: Context {
+            use_rust_path_hack: use_rust_path_hack,
+            sysroot: sroot, // Currently, only tests override this
          },
-        workcache_cx: api::default_ctxt(default_workspace()).workcache_cx // ???
+        workcache_context: api::default_context(default_workspace()).workcache_context
     }.run(*cmd, remaining_args)
 }
 
index 67d8732cf32d2f687c0baf194ebcfa56837b8329..f4016d26a150e4576e2b329a6668ca653f0e3c03 100644 (file)
 
 // rustpkg unit tests
 
-use context::{BuildCtx, Ctx};
+use context::{BuildContext, Context};
 use std::{io, libc, os, run, str, task};
 use extra::arc::Arc;
 use extra::arc::RWArc;
 use extra::tempfile::mkdtemp;
-use extra::workcache::{Context, Database, Logger};
+use extra::workcache;
+use extra::workcache::{Database, Logger};
 use extra::treemap::TreeMap;
 use std::run::ProcessOutput;
 use installed_packages::list_installed_packages;
@@ -36,15 +37,16 @@ fn datestamp(p: &Path) -> Option<libc::time_t> {
     p.stat().map(|stat| stat.st_mtime)
 }
 
-fn fake_ctxt(sysroot_opt: Path, workspace: &Path) -> BuildCtx {
-    let bcx = Context::new(RWArc::new(Database::new(workspace.push("rustpkg_db.json"))),
-                           RWArc::new(Logger::new()),
-                           Arc::new(TreeMap::new()));
-    BuildCtx {
-        workcache_cx: bcx,
-        cx: Ctx {
+fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
+    let context = workcache::Context::new(
+        RWArc::new(Database::new(workspace.push("rustpkg_db.json"))),
+        RWArc::new(Logger::new()),
+        Arc::new(TreeMap::new()));
+    BuildContext {
+        workcache_context: context,
+        context: Context {
             use_rust_path_hack: false,
-            sysroot_opt: sysroot_opt
+            sysroot: sysroot
         }
     }
 }
index 769b1bdf25dfee1858621a2faee9c6148a89eeef..5e9fc6655a8ec4edcb1d3a31df59128821e3fbfc 100644 (file)
@@ -19,7 +19,7 @@
 use syntax::attr::AttrMetaMethods;
 use rustc::back::link::output_type_exe;
 use rustc::driver::session::{lib_crate, bin_crate};
-use context::{in_target, BuildCtx};
+use context::{in_target, BuildContext};
 use package_id::PkgId;
 use package_source::PkgSrc;
 use path_util::{installed_library_in_workspace, U_RWX};
@@ -153,7 +153,7 @@ pub fn ready_crate(sess: session::Session,
     @fold.fold_crate(crate)
 }
 
-pub fn compile_input(ctxt: &BuildCtx,
+pub fn compile_input(ctxt: &BuildContext,
                      exec: &mut workcache::Exec,
                      pkg_id: &PkgId,
                      in_file: &Path,
@@ -161,8 +161,7 @@ pub fn compile_input(ctxt: &BuildCtx,
                      flags: &[~str],
                      cfgs: &[~str],
                      opt: bool,
-                     what: OutputType) -> Option<Path> {
-
+                     what: OutputType) -> Path {
     assert!(in_file.components.len() > 1);
     let input = driver::file_input((*in_file).clone());
     debug!("compile_input: %s / %?", in_file.to_str(), what);
@@ -175,7 +174,7 @@ pub fn compile_input(ctxt: &BuildCtx,
 
     debug!("flags: %s", flags.connect(" "));
     debug!("cfgs: %s", cfgs.connect(" "));
-    debug!("compile_input's sysroot = %s", ctxt.sysroot_opt().to_str());
+    debug!("compile_input's sysroot = %s", ctxt.sysroot().to_str());
 
     let crate_type = match what {
         Lib => lib_crate,
@@ -193,13 +192,13 @@ pub fn compile_input(ctxt: &BuildCtx,
                           driver::optgroups()).unwrap();
     // Hack so that rustpkg can run either out of a rustc target dir,
     // or the host dir
-    let sysroot_to_use = @if !in_target(&ctxt.sysroot_opt()) {
-        ctxt.sysroot_opt()
+    let sysroot_to_use = @if !in_target(&ctxt.sysroot()) {
+        ctxt.sysroot()
     }
     else {
-        ctxt.sysroot_opt().pop().pop().pop()
+        ctxt.sysroot().pop().pop().pop()
     };
-    debug!("compile_input's sysroot = %s", ctxt.sysroot_opt().to_str());
+    debug!("compile_input's sysroot = %s", ctxt.sysroot().to_str());
     debug!("sysroot_to_use = %s", sysroot_to_use.to_str());
     let options = @session::options {
         crate_type: crate_type,
@@ -284,7 +283,7 @@ pub fn compile_crate_from_input(input: &Path,
  // should be of the form <workspace>/build/<pkg id's path>
                                 out_dir: &Path,
                                 sess: session::Session,
-                                crate: @ast::Crate) -> Option<Path> {
+                                crate: @ast::Crate) -> Path {
     debug!("Calling build_output_filenames with %s, building library? %?",
            out_dir.to_str(), sess.building_library);
 
@@ -307,13 +306,13 @@ pub fn compile_crate_from_input(input: &Path,
                                                         &analysis,
                                                         outputs);
     driver::phase_5_run_llvm_passes(sess, &translation, outputs);
-    if driver::stop_after_phase_5(sess) { return Some(outputs.out_filename); }
+    if driver::stop_after_phase_5(sess) { return outputs.out_filename; }
     driver::phase_6_link_output(sess, &translation, outputs);
 
     // Register dependency on the source file
     exec.discover_input("file", input.to_str(), digest_file_with_date(input));
 
-    Some(outputs.out_filename)
+    outputs.out_filename
 }
 
 #[cfg(windows)]
@@ -326,12 +325,12 @@ pub fn exe_suffix() -> ~str { ~".exe" }
 pub fn exe_suffix() -> ~str { ~"" }
 
 // Called by build_crates
-pub fn compile_crate(ctxt: &BuildCtx,
+pub fn compile_crate(ctxt: &BuildContext,
                      exec: &mut workcache::Exec,
                      pkg_id: &PkgId,
                      crate: &Path, workspace: &Path,
                      flags: &[~str], cfgs: &[~str], opt: bool,
-                     what: OutputType) -> Option<Path> {
+                     what: OutputType) -> Path {
     debug!("compile_crate: crate=%s, workspace=%s", crate.to_str(), workspace.to_str());
     debug!("compile_crate: short_name = %s, flags =...", pkg_id.to_str());
     for fl in flags.iter() {
@@ -344,7 +343,7 @@ pub fn compile_crate(ctxt: &BuildCtx,
 /// Collect all `extern mod` directives in `c`, then
 /// try to install their targets, failing if any target
 /// can't be found.
-pub fn find_and_install_dependencies(ctxt: &BuildCtx,
+pub fn find_and_install_dependencies(ctxt: &BuildContext,
                                  sess: session::Session,
                                  exec: &mut workcache::Exec,
                                  workspace: &Path,
@@ -358,8 +357,10 @@ pub fn find_and_install_dependencies(ctxt: &BuildCtx,
             // ignore metadata, I guess
             ast::view_item_extern_mod(lib_ident, path_opt, _, _) => {
                 let lib_name = match path_opt {
-                    Some(p) => p, None => sess.str_of(lib_ident) };
-                match installed_library_in_workspace(lib_name, &ctxt.sysroot_opt()) {
+                    Some(p) => p,
+                    None => sess.str_of(lib_ident)
+                };
+                match installed_library_in_workspace(lib_name, &ctxt.sysroot()) {
                     Some(ref installed_path) => {
                         debug!("It exists: %s", installed_path.to_str());
                         // Say that [path for c] has a discovered dependency on
index cb947b0036c665d49b765cedde8fa48055f7af98..d5dd87ee44228614a5f7636e6b948d0d19f9e17a 100644 (file)
 
 use std::{os,util};
 use std::path::Path;
-use context::Ctx;
+use context::Context;
 use path_util::{workspace_contains_package_id, find_dir_using_rust_path_hack};
 use util::option_to_vec;
 use package_id::PkgId;
 
 use path_util::rust_path;
 
-pub fn each_pkg_parent_workspace(cx: &Ctx, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool {
+pub fn each_pkg_parent_workspace(cx: &Context, pkgid: &PkgId, action: &fn(&Path) -> bool) -> bool {
     // Using the RUST_PATH, find workspaces that contain
     // this package ID
     let workspaces = pkg_parent_workspaces(cx, pkgid);
@@ -38,7 +38,7 @@ pub fn each_pkg_parent_workspace(cx: &Ctx, pkgid: &PkgId, action: &fn(&Path) ->
     return true;
 }
 
-pub fn pkg_parent_workspaces(cx: &Ctx, pkgid: &PkgId) -> ~[Path] {
+pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
     let rs: ~[Path] = rust_path().move_iter()
         .filter(|ws| workspace_contains_package_id(pkgid, ws))
         .collect();