build.rs: Convert to functions

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
Alistair Francis 2020-09-22 12:06:47 -07:00
parent 18ab92ffe6
commit 5334a7ecee

View File

@ -20,24 +20,13 @@ fn main() {
None => return,
};
match &target[..] {
"thumbv6m-none-eabi"
| "msp430-none-elf"
| "riscv32i-unknown-none-elf"
| "riscv32imc-unknown-none-elf" => {}
_ => {
if target_has_atomic_cas(&target) {
println!("cargo:rustc-cfg=atomic_cas");
}
};
match &target[..] {
"msp430-none-elf" | "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => {}
_ => {
if target_has_atomics(&target) {
println!("cargo:rustc-cfg=has_atomics");
}
};
// If the Rust version is at least 1.46.0 then we can use type ids at compile time
if minor >= 47 {
@ -52,6 +41,23 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
}
fn target_has_atomic_cas(target: &str) -> bool {
match &target[..] {
"thumbv6m-none-eabi"
| "msp430-none-elf"
| "riscv32i-unknown-none-elf"
| "riscv32imc-unknown-none-elf" => false,
_ => true,
}
}
fn target_has_atomics(target: &str) -> bool {
match &target[..] {
"msp430-none-elf" | "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => false,
_ => true,
}
}
fn rustc_target() -> Option<String> {
env::var("TARGET").ok()
}