From e180d88b9fe1a660281de586dd1a1ef67cde6b3d Mon Sep 17 00:00:00 2001
From: Philipp Oppermann <dev@phil-opp.com>
Date: Fri, 31 May 2019 13:42:09 +0200
Subject: [PATCH 1/2] Fix the new XBUILD_SYSROOT_PATH environment variable

---
 src/cargo.rs |  6 +-----
 src/xargo.rs | 10 ++++++++--
 2 files changed, 9 insertions(+), 7 deletions(-)

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<String> {
-        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<Home> {
-    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),

From 1c527dfdd1864d9896fa4e08ae7830db14d6f200 Mon Sep 17 00:00:00 2001
From: Philipp Oppermann <dev@phil-opp.com>
Date: Fri, 31 May 2019 13:45:17 +0200
Subject: [PATCH 2/2] Update changelog

---
 CHANGELOG.md | 2 ++
 1 file changed, 2 insertions(+)

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