Skip to content

Commit

Permalink
Merge pull request #34 from rust-osdev/fix-override-sysroot-path
Browse files Browse the repository at this point in the history
Fix the new XBUILD_SYSROOT_PATH environment variable
  • Loading branch information
Philipp Oppermann authored May 31, 2019
2 parents 0945d11 + 1c527df commit 14babe6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 1 addition & 5 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
10 changes: 8 additions & 2 deletions src/xargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 14babe6

Please sign in to comment.