Extra log output + polish rough edges

This commit is contained in:
Carl Lerche 2014-05-27 17:21:28 -07:00
parent 93558906d8
commit c040b89141
6 changed files with 33 additions and 8 deletions

View 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)));

View 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());

View 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)
}

View 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) {

View 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()
}

View 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();