Skip to content

Commit 10efa79

Browse files
committed
auto merge of #1075 : cmr/cargo/rustc-vverbose, r=alexcrichton
Closes #1073
2 parents 9d55078 + f184ec4 commit 10efa79

File tree

1 file changed

+23
-0
lines changed
  • src/cargo/ops/cargo_rustc

1 file changed

+23
-0
lines changed

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub struct TargetConfig {
4646
/// The second element of the tuple returned is the target triple that rustc
4747
/// is a host for.
4848
pub fn rustc_version() -> CargoResult<(String, String)> {
49+
rustc_new_version().or_else(|_| rustc_old_version())
50+
}
51+
52+
pub fn rustc_old_version() -> CargoResult<(String, String)> {
4953
let output = try!(try!(util::process("rustc"))
5054
.arg("-v")
5155
.arg("verbose")
@@ -65,6 +69,25 @@ pub fn rustc_version() -> CargoResult<(String, String)> {
6569
Ok((output, triple))
6670
}
6771

72+
pub fn rustc_new_version() -> CargoResult<(String, String)> {
73+
let output = try!(try!(util::process("rustc"))
74+
.arg("-vV")
75+
.exec_with_output());
76+
let output = try!(String::from_utf8(output.output).map_err(|_| {
77+
internal("rustc -v didn't return utf8 output")
78+
}));
79+
let triple = {
80+
let triple = output.as_slice().lines().filter(|l| {
81+
l.starts_with("host: ")
82+
}).map(|l| l.slice_from(6)).next();
83+
let triple = try!(triple.require(|| {
84+
internal("rustc -v didn't have a line for `host:`")
85+
}));
86+
triple.to_string()
87+
};
88+
Ok((output, triple))
89+
}
90+
6891
// This is a temporary assert that ensures the consistency of the arguments
6992
// given the current limitations of Cargo. The long term fix is to have each
7093
// Target know the absolute path to the build location.

0 commit comments

Comments
 (0)