Skip to content

Commit

Permalink
Fix host detection in toolchain-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Osspial committed Apr 21, 2020
1 parent 3acf3d8 commit 166ee83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ndk-build/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub enum NdkError {
NoPlatformFound,
PlatformNotFound(u32),
UnsupportedTarget,
UnsupportedHost(String),
Io(IoError),
InvalidSemver,
}
Expand Down Expand Up @@ -42,6 +43,7 @@ impl Display for NdkError {
return write!(f, "Platform {} is not installed.", level)
}
Self::UnsupportedTarget => "Target is not supported.",
Self::UnsupportedHost(host) => return write!(f, "Host {} is not supported.", host),
Self::Io(error) => return error.fmt(f),
Self::InvalidSemver => return write!(f, "Invalid semver"),
};
Expand Down
16 changes: 10 additions & 6 deletions ndk-build/src/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ impl Ndk {
}

pub fn toolchain_dir(&self) -> Result<PathBuf, NdkError> {
#[cfg(target_os = "linux")]
let arch = "linux-x86_64";
#[cfg(target_os = "macos")]
let arch = "darwin-x86_64";
#[cfg(target_os = "windows")]
let arch = "windows-x86_64";
let host_os = std::env::var("HOST").expect("HOST environment variable not set. `cargo build` should've set this, so *something* has gone wrong.");
let arch = if host_os.contains("linux") {
"linux-x86_64"
} else if host_os.contains("macos") {
"darwin-x86_64"
} else if host_os.contains("windows") {
"windows-x86_64"
} else {
return Err(NdkError::UnsupportedHost(host_os))
};

let toolchain_dir = self
.ndk_path
Expand Down

0 comments on commit 166ee83

Please sign in to comment.