Skip to content

Commit

Permalink
Extra log output + polish rough edges
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche committed May 28, 2014
1 parent 9355890 commit c040b89
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl Target {
*/

type TomlLibTarget = TomlTarget;
type TomlExecTarget = TomlTarget;
type TomlBinTarget = TomlTarget;

#[deriving(Decodable,Encodable,Eq,Clone,Show)]
pub struct Project {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions src/cargo/ops/cargo_rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 9 additions & 1 deletion src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand All @@ -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())
}
Expand All @@ -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()
}
13 changes: 13 additions & 0 deletions src/cargo/util/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c040b89

Please sign in to comment.