From 955fbc878881a1b8a9f6bcdfc3ded2401bb6165d Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Wed, 12 Oct 2022 19:03:46 +0200 Subject: [PATCH] xous: Use CARGO_CFG_TARGET_OS in build scripts. This allows for a more reliable detection of target_os configuration in build scripts. The target is inconsistent between some architectures, notably armv7a is `armv7a-none-eabi` skipping the `unknown` (the vendor, I guess) part. This happen with some of the unrelated Cortex-M targets present, and others may also be. Signed-off-by: Jean-Pierre De Jesus DIAZ --- kernel/build.rs | 3 +-- services/gam/build.rs | 4 +--- services/kernel-test/build.rs | 4 +--- xous-rs/build.rs | 4 ++-- 4 files changed, 5 insertions(+), 10 deletions(-) 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.