Skip to content

Commit

Permalink
auto merge of #1075 : cmr/cargo/rustc-vverbose, r=alexcrichton
Browse files Browse the repository at this point in the history
Closes #1073
  • Loading branch information
bors committed Dec 21, 2014
2 parents 9d55078 + f184ec4 commit 10efa79
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub struct TargetConfig {
/// The second element of the tuple returned is the target triple that rustc
/// is a host for.
pub fn rustc_version() -> CargoResult<(String, String)> {
rustc_new_version().or_else(|_| rustc_old_version())
}

pub fn rustc_old_version() -> CargoResult<(String, String)> {
let output = try!(try!(util::process("rustc"))
.arg("-v")
.arg("verbose")
Expand All @@ -65,6 +69,25 @@ pub fn rustc_version() -> CargoResult<(String, String)> {
Ok((output, triple))
}

pub fn rustc_new_version() -> CargoResult<(String, String)> {
let output = try!(try!(util::process("rustc"))
.arg("-vV")
.exec_with_output());
let output = try!(String::from_utf8(output.output).map_err(|_| {
internal("rustc -v didn't return utf8 output")
}));
let triple = {
let triple = output.as_slice().lines().filter(|l| {
l.starts_with("host: ")
}).map(|l| l.slice_from(6)).next();
let triple = try!(triple.require(|| {
internal("rustc -v didn't have a line for `host:`")
}));
triple.to_string()
};
Ok((output, triple))
}

// This is a temporary assert that ensures the consistency of the arguments
// given the current limitations of Cargo. The long term fix is to have each
// Target know the absolute path to the build location.
Expand Down

0 comments on commit 10efa79

Please sign in to comment.