esp-hal/esp-storage/build.rs
Juraj Sadel 44e7aea358
esp-storage: Clean warnings when running host-tests (#4151)
* esp-storage: Clean warnings when running host-tests

* Emit all check-cfg lines

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2025-09-22 06:22:10 +00:00

31 lines
1.1 KiB
Rust

use esp_metadata_generated::{Chip, emit_check_cfg_directives};
fn main() -> Result<(), String> {
if !cfg!(feature = "emulation") {
// Load the configuration file for the configured device:
let chip = Chip::from_cargo_feature()?;
// Define all necessary configuration symbols for the configured device:
chip.define_cfgs();
} else {
// Even though we don't have a chip, make sure we're not warned about the config symbols.
emit_check_cfg_directives();
}
if cfg!(feature = "esp32") {
match std::env::var("OPT_LEVEL") {
Ok(level) if std::env::var("CI").is_err() => {
if level != "2" && level != "3" && level != "s" {
Err(format!(
"Building esp-storage for ESP32 needs optimization level 2, 3 or s - yours is {level}. See https://github.com/esp-rs/esp-storage"
))
} else {
Ok(())
}
}
_ => Ok(()),
}
} else {
Ok(())
}
}