From 046a25ae61497c8346b5f0a33732b1966a599cfb Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 31 May 2019 13:13:53 +0200 Subject: [PATCH] Add a XBUILD_SYSROOT_PATH environment variable to override the sysroot path --- CHANGELOG.md | 1 + src/cargo.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a496e..b573fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - Error when sysroot contains spaces ([#32](https://github.com/rust-osdev/cargo-xbuild/pull/32)) +- Allow overriding the sysroot path through a `XBUILD_SYSROOT_PATH` environment variable ([#33](https://github.com/rust-osdev/cargo-xbuild/pull/33)) ## [v0.5.9] - 2019-05-24 diff --git a/src/cargo.rs b/src/cargo.rs index e7f121c..0101903 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -43,7 +43,11 @@ impl Rustflags { /// Stringifies these flags for Xargo consumption pub fn for_xargo(&self, home: &Home) -> Result { - let sysroot = format!("{}", home.display()); + let sysroot = if let Ok(path) = env::var("XBUILD_SYSROOT_PATH") { + path + } else { + 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\