Skip to content

Commit

Permalink
Change the way we detect and warn about debug-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Nov 27, 2024
1 parent 60ea3ed commit e7bb3c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions esp-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ embedded-hal-nb = "1.0.0"
embedded-io = "0.6.1"
embedded-io-async = "0.6.1"
enumset = "1.1.5"
esp-build = { version = "0.1.0", path = "../esp-build" }
esp-synopsys-usb-otg = { version = "0.4.2", optional = true, features = ["fs", "esp32sx"] }
fugit = "0.3.7"
log = { version = "0.4.22", optional = true }
Expand Down
16 changes: 7 additions & 9 deletions esp-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ use esp_build::assert_unique_used_features;
use esp_config::{generate_config, Value};
use esp_metadata::{Chip, Config};

#[cfg(debug_assertions)]
esp_build::warning! {"
WARNING: use --release
We *strongly* recommend using release profile when building esp-hal.
The dev profile can potentially be one or more orders of magnitude
slower than release, and may cause issues with timing-senstive
peripherals and/or devices.
"}

fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rustc-check-cfg=cfg(is_debug_build)");
if let Ok(level) = std::env::var("OPT_LEVEL") {
if level != "2" && level != "3" {
println!("cargo:rustc-cfg=is_debug_build");
}
}

// NOTE: update when adding new device support!
// Ensure that exactly one chip has been specified:
assert_unique_used_features!(
Expand Down
9 changes: 9 additions & 0 deletions esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ pub mod trapframe {
// be directly exposed.
mod soc;

#[cfg(is_debug_build)]
esp_build::warning! {"
WARNING: use --release
We *strongly* recommend using release profile when building esp-hal.
The dev profile can potentially be one or more orders of magnitude
slower than release, and may cause issues with timing-senstive
peripherals and/or devices.
"}

#[cfg(xtensa)]
#[no_mangle]
extern "C" fn EspDefaultHandler(_level: u32, _interrupt: peripherals::Interrupt) {
Expand Down

0 comments on commit e7bb3c9

Please sign in to comment.