aboutsummaryrefslogtreecommitdiff
path: root/cortex-m/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m/build.rs')
-rw-r--r--cortex-m/build.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/cortex-m/build.rs b/cortex-m/build.rs
new file mode 100644
index 0000000..f81072b
--- /dev/null
+++ b/cortex-m/build.rs
@@ -0,0 +1,34 @@
+use std::env;
+
+fn main() {
+ let target = env::var("TARGET").unwrap();
+ let host_triple = env::var("HOST").unwrap();
+
+ if host_triple == target {
+ println!("cargo:rustc-cfg=native");
+ }
+
+ if target.starts_with("thumbv6m-") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv6m");
+ } else if target.starts_with("thumbv7m-") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv7m");
+ } else if target.starts_with("thumbv7em-") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv7m");
+ println!("cargo:rustc-cfg=armv7em");
+ } else if target.starts_with("thumbv8m.base") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv8m");
+ println!("cargo:rustc-cfg=armv8m_base");
+ } else if target.starts_with("thumbv8m.main") {
+ println!("cargo:rustc-cfg=cortex_m");
+ println!("cargo:rustc-cfg=armv8m");
+ println!("cargo:rustc-cfg=armv8m_main");
+ }
+
+ if target.ends_with("-eabihf") {
+ println!("cargo:rustc-cfg=has_fpu");
+ }
+}