mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 04:10:28 +00:00

* Disallow multiple halt methods * Warn for nonsense config * Use DRAM range from metadata
52 lines
1.6 KiB
Rust
52 lines
1.6 KiB
Rust
use esp_config::generate_config_from_yaml_definition;
|
|
|
|
#[macro_export]
|
|
macro_rules! assert_unique_features {
|
|
($($feature:literal),+ $(,)?) => {
|
|
assert!(
|
|
(0 $(+ cfg!(feature = $feature) as usize)+ ) <= 1,
|
|
"At most one of the following features must be enabled: {}",
|
|
[$($feature),+].join(", ")
|
|
);
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! assert_unique_used_features {
|
|
($($feature:literal),+ $(,)?) => {
|
|
assert!(
|
|
(0 $(+ cfg!(feature = $feature) as usize)+ ) == 1,
|
|
"Exactly one of the following features must be enabled: {}",
|
|
[$($feature),+].join(", ")
|
|
);
|
|
};
|
|
}
|
|
|
|
fn main() {
|
|
// Ensure that exactly a backend is selected:
|
|
assert_unique_used_features!("defmt", "println");
|
|
|
|
// Ensure that there aren't multiple halt methods selected:
|
|
assert_unique_features!("custom-halt", "halt-cores", "semihosting");
|
|
|
|
if !cfg!(feature = "panic-handler")
|
|
&& cfg!(any(
|
|
feature = "custom-halt",
|
|
feature = "halt-cores",
|
|
feature = "semihosting"
|
|
))
|
|
{
|
|
print_warning("A halt method is selected, but esp-backtrace is not the panic handler.")
|
|
}
|
|
|
|
// emit config
|
|
println!("cargo:rerun-if-changed=./esp_config.yml");
|
|
let cfg_yaml = std::fs::read_to_string("./esp_config.yml")
|
|
.expect("Failed to read esp_config.yml for esp-backtrace");
|
|
generate_config_from_yaml_definition(&cfg_yaml, true, true, None).unwrap();
|
|
}
|
|
|
|
fn print_warning(message: impl core::fmt::Display) {
|
|
println!("cargo:warning={message}");
|
|
}
|