use std::io::prelude::*;
fn main() {
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH variable");
let os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS variable");
match (arch.as_str(), os.as_str()) {
("arm", "none") => {
setup_cortexm_linker();
}
_ => {
}
}
}
fn setup_cortexm_linker() {
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
std::fs::File::create(out.join("neotron-cortex-m.ld"))
.unwrap()
.write_all(include_bytes!("./neotron-cortex-m.ld"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=./neotron-cortex-m.ld");
}