Skip to content

Commit ef4e933

Browse files
committed
build: Use newly factored out triple.rs in build script
Signed-off-by: Daniel Silverstone <[email protected]>
1 parent ae8048a commit ef4e933

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ version = "0.3"
100100
[dev-dependencies]
101101
walkdir = "2"
102102

103+
[build-dependencies]
104+
lazy_static = "1"
105+
regex = "1"
106+
103107
[workspace]
104108
members = ["download"]
105109

build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
use std::env;
22

3+
include!("src/dist/triple.rs");
4+
5+
pub fn from_build() -> Result<PartialTargetTriple, String> {
6+
let triple = if let Ok(triple) = env::var("RUSTUP_OVERRIDE_BUILD_TRIPLE") {
7+
triple
8+
} else {
9+
env::var("TARGET").unwrap()
10+
};
11+
PartialTargetTriple::new(&triple).ok_or(triple)
12+
}
13+
314
fn main() {
15+
println!("cargo:rerun-if-env-changed=RUSTUP_OVERRIDE_BUILD_TRIPLE");
16+
println!("cargo:rerun-if-env-changed=TARGET");
17+
match from_build() {
18+
Ok(triple) => eprintln!("Computed build based partial target triple: {:#?}", triple),
19+
Err(s) => {
20+
eprintln!("Unable to parse target '{}' as a PartialTargetTriple", s);
21+
eprintln!(
22+
"If you are attempting to bootstrap a new target you may need to adjust the\n\
23+
permitted values found in src/dist/triple.rs"
24+
);
25+
std::process::abort();
26+
}
27+
}
428
let target = env::var("TARGET").unwrap();
529
println!("cargo:rustc-env=TARGET={}", target);
630
}

0 commit comments

Comments
 (0)