Skip to content

Commit 4b44d27

Browse files
committed
build.rs: handle both RUSTUP_OVERRIDE_BUILD_TUPLE and RUSTUP_OVERRIDE_BUILD_TRIPLE
1 parent 7667fb8 commit 4b44d27

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

build.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ use std::env;
33
use platforms::Platform;
44

55
fn from_build() -> Result<String, String> {
6-
let tuple =
7-
env::var("RUSTUP_OVERRIDE_BUILD_TRIPLE").unwrap_or_else(|_| env::var("TARGET").unwrap());
6+
let tuple = {
7+
if let Ok(tuple) = env::var("RUSTUP_OVERRIDE_BUILD_TUPLE") {
8+
tuple
9+
} else if let Ok(tuple) = env::var("RUSTUP_OVERRIDE_BUILD_TRIPLE") {
10+
tuple
11+
} else if let Ok(tuple) = env::var("TARGET") {
12+
tuple
13+
} else {
14+
panic!(
15+
"Unable to get target tuple from environment; Be sure that TARGET env var is set, or its overrides"
16+
)
17+
}
18+
};
819
if Platform::ALL.iter().any(|p| p.target_triple == tuple) {
920
Ok(tuple)
1021
} else {

0 commit comments

Comments
 (0)