Skip to content

Commit b00a9b2

Browse files
committed
respect RUSTC_WRAPPER env var
1 parent 599b9e9 commit b00a9b2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,16 @@ pub fn version() -> Result<Version> {
198198
/// Returns the `rustc` SemVer version and additional metadata
199199
/// like the git short hash and build date.
200200
pub fn version_meta() -> Result<VersionMeta> {
201-
let cmd = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
201+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
202+
let cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") {
203+
let mut cmd = Command::new(wrapper);
204+
cmd.arg(rustc);
205+
cmd
206+
} else {
207+
Command::new(rustc)
208+
};
202209

203-
VersionMeta::for_command(Command::new(cmd))
210+
VersionMeta::for_command(cmd)
204211
}
205212

206213
/// Parses a "rustc -vV" output string and returns
@@ -263,7 +270,7 @@ pub fn version_meta_for(verbose_version_string: &str) -> Result<VersionMeta> {
263270

264271
fn expect_key_or_unknown(key: &str, map: &HashMap<&str, &str>) -> Result<Option<String>, Error> {
265272
match map.get(key) {
266-
Some(&v) if v == "unknown" => Ok(None),
273+
Some(&"unknown") => Ok(None),
267274
Some(&v) => Ok(Some(String::from(v))),
268275
None => Err(Error::UnexpectedVersionFormat),
269276
}

0 commit comments

Comments
 (0)