Extra log output + polish rough edges
authorCarl Lerche <me@carllerche.com>
Wed, 28 May 2014 00:21:28 +0000 (17:21 -0700)
committerCarl Lerche <me@carllerche.com>
Wed, 28 May 2014 00:21:36 +0000 (17:21 -0700)
src/cargo/core/manifest.rs
src/cargo/core/resolver.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/ops/cargo_rustc.rs
src/cargo/sources/path.rs
src/cargo/util/process_builder.rs

index cb188e1cdf1676955dd3ec6cc9bdd2e31d8bccb2..4ee193dcf903c7ec7f155095ea96cfb5648ca68f 100644 (file)
@@ -165,7 +165,7 @@ impl Target {
  */
 
 type TomlLibTarget = TomlTarget;
-type TomlExecTarget = TomlTarget;
+type TomlBinTarget = TomlTarget;
 
 #[deriving(Decodable,Encodable,Eq,Clone,Show)]
 pub struct Project {
@@ -182,8 +182,8 @@ pub struct Project {
 pub struct TomlManifest {
     project: Box<Project>,
     lib: Option<~[TomlLibTarget]>,
-    bin: Option<~[TomlExecTarget]>,
-    dependencies: Option<HashMap<String, String>>
+    bin: Option<~[TomlBinTarget]>,
+    dependencies: Option<HashMap<String, String>>,
 }
 
 impl TomlManifest {
@@ -228,20 +228,22 @@ impl Project {
     }
 }
 
-#[deriving(Decodable,Encodable,Eq,Clone)]
+#[deriving(Decodable,Encodable,Eq,Clone,Show)]
 struct TomlTarget {
     name: String,
     path: Option<String>
 }
 
-fn normalize(lib: &Option<~[TomlLibTarget]>, bin: &Option<~[TomlExecTarget]>) -> Vec<Target> {
+fn normalize(lib: &Option<~[TomlLibTarget]>, bin: &Option<~[TomlBinTarget]>) -> Vec<Target> {
+    log!(4, "normalizing toml targets; lib={}; bin={}", lib, bin);
+
     fn lib_targets(dst: &mut Vec<Target>, libs: &[TomlLibTarget]) {
         let l = &libs[0];
         let path = l.path.clone().unwrap_or_else(|| format!("src/{}.rs", l.name));
         dst.push(Target::lib_target(l.name.as_slice(), &Path::new(path)));
     }
 
-    fn bin_targets(dst: &mut Vec<Target>, bins: &[TomlExecTarget], default: |&TomlExecTarget| -> String) {
+    fn bin_targets(dst: &mut Vec<Target>, bins: &[TomlBinTarget], default: |&TomlBinTarget| -> String) {
         for bin in bins.iter() {
             let path = bin.path.clone().unwrap_or_else(|| default(bin));
             dst.push(Target::bin_target(bin.name.as_slice(), &Path::new(path)));
index 6523913c968680a2a08532f619ac3a3be88a4ddb..bf31e24ceb43fe613026a00c3a9b3f78368e9f2c 100644 (file)
@@ -26,7 +26,7 @@ pub fn resolve(deps: &[Dependency], registry: &Registry) -> CargoResult<Vec<Name
 
         let opts = registry.query(curr.get_name());
 
-        //assert!(!resolve.contains_key_equiv(&curr.get_name()), "already traversed {}", curr.get_name());
+        assert!(opts.len() > 0, "no matches for {}", curr.get_name());
         // Temporary, but we must have exactly one option to satisfy the dep
         assert!(opts.len() == 1, "invalid num of results {}", opts.len());
 
index 53f175fcd35fe1ea4ca37a3bdc64b33eb65b1613..ec57001bca1aef6d13eb36be2ecc96e109008ced 100644 (file)
@@ -23,5 +23,6 @@ fn load_toml(root: toml::Value) -> CargoResult<TomlManifest> {
 }
 
 fn to_cargo_err(err: toml::Error) -> CargoError {
+    debug!("toml; err={}", err);
     toml_error("Problem loading manifest", err)
 }
index dbd2441b152d6f62629035068f758f3c3519ff7f..54ca4cf8f15ac86c43fb7f0f3f697b87513d894c 100644 (file)
@@ -71,6 +71,7 @@ fn prepare_rustc(root: &Path, target: &core::Target, dest: &Path, deps: &[core::
     util::process("rustc")
         .cwd(root.clone())
         .args(args.as_slice())
+        .env("RUST_LOG", None) // rustc is way too noisy
 }
 
 fn build_base_args(into: &mut Args, target: &core::Target, dest: &Path) {
index ced38f851cdbd8e6a8bf98ef42c2c0601481900c..509072f44cf4982ea146a5b9dd4d45e382a8c673 100644 (file)
@@ -11,6 +11,7 @@ pub struct PathSource {
 
 impl PathSource {
     pub fn new(paths: Vec<Path>) -> PathSource {
+        log!(4, "new; paths={}", display(paths.as_slice()));
         PathSource { paths: paths }
     }
 }
@@ -28,7 +29,10 @@ impl Source for PathSource {
         Ok(self.paths.iter().filter_map(|path| {
             match read_manifest(path) {
                 Ok(ref pkg) => Some(pkg.get_summary().clone()),
-                Err(_) => None
+                Err(e) => {
+                    log!(4, "failed to read manifest; path={}; err={}", path.display(), e);
+                    None
+                }
             }
         }).collect())
     }
@@ -51,3 +55,7 @@ fn read_manifest(path: &Path) -> CargoResult<Package> {
     let joined = path.join("Cargo.toml");
     ops::read_manifest(joined.as_str().unwrap())
 }
+
+fn display(paths: &[Path]) -> Vec<String> {
+    paths.iter().map(|p| p.display().to_str()).collect()
+}
index 972d409493a36ed5559b27f1a784b6faefa3f4d1..5ad4a5fd5495bd4dd53309993043613b4f3d7ce9 100644 (file)
@@ -51,6 +51,19 @@ impl ProcessBuilder {
         self
     }
 
+    pub fn env(mut self, key: &str, val: Option<&str>) -> ProcessBuilder {
+        match val {
+            Some(v) => {
+                self.env.insert(key.to_strbuf(), v.to_strbuf());
+            },
+            None => {
+                self.env.remove(&key.to_strbuf());
+            }
+        }
+
+        self
+    }
+
     // TODO: should InheritFd be hardcoded?
     pub fn exec(&self) -> CargoResult<()> {
         let mut command = self.build_command();