From 8a958e92bc42e7e387b4f99af98997b3e35e95a7 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Wed, 21 Jun 2023 06:16:07 -0700 Subject: [PATCH] If the `embassy` feature is enabled, ensure that a time driver implementation is available (#608) --- esp-hal-common/build.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/esp-hal-common/build.rs b/esp-hal-common/build.rs index e74f59f76..187e6b7af 100644 --- a/esp-hal-common/build.rs +++ b/esp-hal-common/build.rs @@ -1,4 +1,8 @@ -use std::{env, fs, path::PathBuf}; +use std::{ + env, + fs, + path::{Path, PathBuf}, +}; use serde::Deserialize; @@ -144,13 +148,20 @@ fn main() { println!("cargo:rustc-cfg={peripheral}"); } - // check PSRAM features are only given if the target supports PSRAM + // Check PSRAM features are only given if the target supports PSRAM if !&device.peripherals.contains(&String::from("psram")) && (cfg!(feature = "psram_2m") || cfg!(feature = "psram_4m") || cfg!(feature = "psram_8m")) { panic!("The target does not support PSRAM"); } + // If the `embassy` feature is enabled, ensure that a time driver implementation + // is available + #[cfg(feature = "embassy")] + { + assert_unique_used_features!("embassy-time-systick", "embassy-time-timg0"); + } + // Place all linker scripts in `OUT_DIR`, and instruct Cargo how to find these // files: let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); @@ -169,10 +180,7 @@ fn main() { gen_efuse_table(device_name, out); } -fn copy_dir_all( - src: impl AsRef, - dst: impl AsRef, -) -> std::io::Result<()> { +fn copy_dir_all(src: impl AsRef, dst: impl AsRef) -> std::io::Result<()> { fs::create_dir_all(&dst)?; for entry in fs::read_dir(src)? { let entry = entry?; @@ -186,10 +194,10 @@ fn copy_dir_all( Ok(()) } -fn gen_efuse_table(device_name: &str, out_dir: impl AsRef) { +fn gen_efuse_table(device_name: &str, out_dir: impl AsRef) { use std::io::{BufRead, Write}; - let src_path = std::path::PathBuf::from(format!("src/soc/{device_name}/efuse.csv")); + let src_path = PathBuf::from(format!("src/soc/{device_name}/efuse.csv")); let out_path = out_dir.as_ref().join("efuse_fields.rs"); println!("cargo:rerun-if-changed={}", src_path.display());