aboutsummaryrefslogtreecommitdiff
path: root/rtic-monotonics/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rtic-monotonics/build.rs')
-rw-r--r--rtic-monotonics/build.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/rtic-monotonics/build.rs b/rtic-monotonics/build.rs
new file mode 100644
index 00000000..a2ed5707
--- /dev/null
+++ b/rtic-monotonics/build.rs
@@ -0,0 +1,22 @@
+fn main() {
+ // feature=["stm32g081kb"] etc.
+ let stm32_chip: Vec<_> = std::env::vars()
+ .map(|(a, _)| a)
+ .filter(|x| {
+ !x.starts_with("CARGO_FEATURE_STM32_METAPAC")
+ && !x.starts_with("CARGO_FEATURE_STM32_TIM")
+ && x.starts_with("CARGO_FEATURE_STM32")
+ })
+ .collect();
+
+ match stm32_chip.len() {
+ 0 => {
+ // Not using stm32.
+ }
+ 1 => {
+ // Allows to just use #[cfg(stm32)] if one of the stm32 chips is used.
+ println!("cargo:rustc-cfg=stm32");
+ }
+ _ => panic!("multiple stm32xx definitions {:?}", stm32_chip),
+ }
+}