diff --git a/CHANGELOG.md b/CHANGELOG.md index f925650..28dc8f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Fix an issue with new `XBUILD_SYSROOT_PATH` environment variable ([#34](https://github.com/rust-osdev/cargo-xbuild/pull/34)) + ## [0.5.10] - 2019-05-31 - Error when sysroot contains spaces ([#32](https://github.com/rust-osdev/cargo-xbuild/pull/32)) diff --git a/src/cargo.rs b/src/cargo.rs index 0101903..e7f121c 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -43,11 +43,7 @@ impl Rustflags { /// Stringifies these flags for Xargo consumption pub fn for_xargo(&self, home: &Home) -> Result { - let sysroot = if let Ok(path) = env::var("XBUILD_SYSROOT_PATH") { - path - } else { - format!("{}", home.display()) - }; + let sysroot = format!("{}", home.display()); if env::var_os("XBUILD_ALLOW_SYSROOT_SPACES").is_none() && sysroot.contains(" ") { return Err(format!("Sysroot must not contain spaces!\n\ See issue https://github.com/rust-lang/cargo/issues/6139\n\n\ diff --git a/src/xargo.rs b/src/xargo.rs index ea5c819..a796050 100644 --- a/src/xargo.rs +++ b/src/xargo.rs @@ -3,6 +3,7 @@ use std::mem; use std::path::Path; use std::path::{Display, PathBuf}; use std::process::{Command, ExitStatus}; +use std::env; use rustc_version::VersionMeta; @@ -72,8 +73,13 @@ impl Home { } pub fn home(root: &Path, config: &Config) -> Result { - let mut path = PathBuf::from(root); - path.push(&config.sysroot_path); + let path = if let Ok(path) = env::var("XBUILD_SYSROOT_PATH") { + PathBuf::from(path) + } else { + let mut path = PathBuf::from(root); + path.push(&config.sysroot_path); + path + }; Ok(Home { path: Filesystem::new(path),