[package]
name          = "esp-backtrace"
version       = "0.18.1"
edition       = "2024"
rust-version  = "1.86.0"
description   = "Bare-metal backtrace support for Espressif devices"
documentation = "https://docs.espressif.com/projects/rust/esp-backtrace/latest/"
keywords      = ["backtrace", "embedded", "esp32", "espressif"]
categories    = ["embedded", "hardware-support", "no-std"]
repository    = "https://github.com/esp-rs/esp-hal"
license       = "MIT OR Apache-2.0"

[package.metadata.espressif]
doc-config = { features = ["defmt"] }
check-configs = [
    { features = ["println", "esp-println/auto"] },
    { features = ["defmt"] },
    { features = ["defmt", "panic-handler", "custom-halt"] },
    { features = ["defmt", "panic-handler", "halt-cores"] },
    { features = ["defmt", "panic-handler", "semihosting"] }
]
clippy-configs = [
    { features = ["panic-handler", "halt-cores", "defmt"] },
]

[package.metadata.docs.rs]
default-target = "riscv32imc-unknown-none-elf"
features       = ["esp32c3", "panic-handler", "exception-handler", "println", "esp-println/uart"]

[lib]
bench = false
test  = false

[dependencies]
cfg-if      = "1"
defmt       = { version = "1", optional = true }
esp-config  = { version = "0.6.1", path = "../esp-config" }
esp-metadata-generated = { version = "0.3.0", path = "../esp-metadata-generated" }
esp-println = { version = "0.16.1", optional = true, default-features = false, path = "../esp-println" }
heapless    = "0.9"
semihosting = { version = "0.1.20", optional = true }
document-features = "0.2"

[target.'cfg(target_arch = "riscv32")'.dependencies]
riscv            = { version = "0.15.0" }

[target.'cfg(target_arch = "xtensa")'.dependencies]
xtensa-lx        = { version = "0.13.0", path = "../xtensa-lx" }

[build-dependencies]
esp-config   = { version = "0.6.1", path = "../esp-config", features = ["build"] }
esp-metadata-generated = { version = "0.3.0", path = "../esp-metadata-generated", features = ["build-script"] }

[features]
default = ["colors"]

esp32   = ["esp-println?/esp32", "esp-metadata-generated/esp32", "semihosting?/openocd-semihosting", "print-float-registers"]
esp32c2 = ["esp-println?/esp32c2", "esp-metadata-generated/esp32c2"]
esp32c3 = ["esp-println?/esp32c3", "esp-metadata-generated/esp32c3"]
esp32c6 = ["esp-println?/esp32c6", "esp-metadata-generated/esp32c6"]
esp32h2 = ["esp-println?/esp32h2", "esp-metadata-generated/esp32h2"]
esp32s2 = ["esp-println?/esp32s2", "esp-metadata-generated/esp32s2", "semihosting?/openocd-semihosting"]
esp32s3 = ["esp-println?/esp32s3", "esp-metadata-generated/esp32s3", "semihosting?/openocd-semihosting", "print-float-registers"]

## Use `esp-println`
println = ["dep:esp-println"]

## Use `defmt`
##
## Please note that `defmt` does _not_ provide MSRV guarantees with releases, and as such we are
## not able to make any MSRV guarantees when this feature is enabled. For more information refer to
## the MSRV section of `defmt`'s README: https://github.com/knurling-rs/defmt?tab=readme-ov-file#msrv
defmt = ["dep:defmt"]

print-float-registers = [] # TODO support esp32p4

# You may optionally enable one or more of the below features to provide
# additional functionality:
## Print messages in red
colors               = []
# TODO: these features assume panic-handler is enabled but they don't enforce it.
## Invoke the extern function `custom_halt()` instead of doing a loop {} in case of a panic. This feature does not imply the `halt-cores` feature.
custom-halt          = []
## Invoke the extern function `custom_pre_backtrace()` before handling a panic
custom-pre-backtrace = []
## Halt both CPUs on ESP32 / ESP32-S3 instead of doing a `loop {}` in case of a panic
halt-cores           = []
## Exit with a semihosting call in case of a panic
semihosting = ["dep:semihosting"]
## Include a panic handler
panic-handler        = []

[lints.rust]
unexpected_cfgs = "allow"
