use std::env;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if arch != "arm" {
return;
}
let cfg = autocfg::new();
let r7_available = cfg.probe_expression("unsafe { core::arch::asm!(\"\", out(\"r7\") _) }");
let r9_available = cfg.probe_expression("unsafe { core::arch::asm!(\"\", out(\"r9\") _) }");
let r11_available = cfg.probe_expression("unsafe { core::arch::asm!(\"\", out(\"r11\") _) }");
if !r9_available {
autocfg::emit("r9_reserved");
}
match (r7_available, r11_available) {
(true, false) => {}
(false, true) => autocfg::emit("fp_is_r7"),
_ => panic!("could not determine whether frame pointer is r7 or r11"),
}
let (is_thumb, has_thumb2) = if let Ok(target_features) = env::var("CARGO_CFG_TARGET_FEATURE") {
(
target_features.split(',').any(|s| s == "thumb-mode"),
target_features.split(',').any(|s| s == "thumb2"),
)
} else {
let target = env::var("TARGET").unwrap();
(target.starts_with("thumb"), !target.starts_with("thumbv6"))
};
if is_thumb {
autocfg::emit("is_thumb");
}
if has_thumb2 {
autocfg::emit("has_thumb2");
}
}