diff --git a/kernel/build.rs b/kernel/build.rs index 32ddd191c..0985ab864 100644 --- a/kernel/build.rs +++ b/kernel/build.rs @@ -10,10 +10,9 @@ use std::path::PathBuf; fn main() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let target = env::var("TARGET").unwrap(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); let name = env::var("CARGO_PKG_NAME").unwrap(); - let target_os = target.split('-').nth(2).unwrap_or("none"); - // If we're not running on a desktop-class operating system, emit the "baremetal" // config setting. This will enable software to do tasks such as // managing memory. diff --git a/services/gam/build.rs b/services/gam/build.rs index 43c3deb4f..2db940193 100644 --- a/services/gam/build.rs +++ b/services/gam/build.rs @@ -2,9 +2,7 @@ use std::env; fn main() { - let target = env::var("TARGET").unwrap(); - - let target_os = target.split('-').nth(2).unwrap_or("none"); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); // If we're not running on a desktop-class operating system, emit the "baremetal" // config setting. This will enable software to do tasks such as diff --git a/services/kernel-test/build.rs b/services/kernel-test/build.rs index 43c3deb4f..2db940193 100644 --- a/services/kernel-test/build.rs +++ b/services/kernel-test/build.rs @@ -2,9 +2,7 @@ use std::env; fn main() { - let target = env::var("TARGET").unwrap(); - - let target_os = target.split('-').nth(2).unwrap_or("none"); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); // If we're not running on a desktop-class operating system, emit the "baremetal" // config setting. This will enable software to do tasks such as diff --git a/xous-rs/build.rs b/xous-rs/build.rs index 5af5b4b65..5373d5a9c 100644 --- a/xous-rs/build.rs +++ b/xous-rs/build.rs @@ -1,3 +1,4 @@ +use core::panic; // NOTE: Adapted from cortex-m/build.rs use std::env; use std::fs; @@ -6,10 +7,9 @@ use std::path::PathBuf; fn main() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let target = env::var("TARGET").unwrap(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); let name = env::var("CARGO_PKG_NAME").unwrap(); - let target_os = target.split('-').nth(2).unwrap_or("none"); - // If we're not running on a desktop-class operating system, emit the "baremetal" // config setting. This will enable software to do tasks such as // managing memory.