mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Make the backtrace feature optional
This commit is contained in:
parent
b317602c6b
commit
580afa9335
|
@ -8,7 +8,8 @@ license = "MPL-2.0"
|
|||
repository = "https://github.com/agbrs/agb"
|
||||
|
||||
[features]
|
||||
default = ["testing"]
|
||||
default = ["backtrace", "testing"]
|
||||
backtrace = ["testing", "dep:qrcodegen-no-heap"]
|
||||
testing = []
|
||||
multiboot = []
|
||||
|
||||
|
@ -20,7 +21,7 @@ agb_macros = { version = "0.19.1", path = "../agb-macros" }
|
|||
agb_fixnum = { version = "0.19.1", path = "../agb-fixnum" }
|
||||
agb_hashmap = { version = "0.19.1", path = "../agb-hashmap" }
|
||||
bilge = "0.2"
|
||||
qrcodegen-no-heap = "1.8"
|
||||
qrcodegen-no-heap = { version = "1.8", optional = true }
|
||||
portable-atomic = { version = "1.6.0", default-features = false, features = ["unsafe-assume-single-core"] }
|
||||
once_cell = { version = "1.19.0", default-features = false, features = ["critical-section"] }
|
||||
critical-section = { version = "1.1.2", features = ["restore-state-u16"] }
|
||||
|
|
|
@ -150,6 +150,7 @@ extern crate alloc;
|
|||
mod agb_alloc;
|
||||
|
||||
mod agbabi;
|
||||
#[cfg(feature = "backtrace")]
|
||||
mod backtrace;
|
||||
mod bitarray;
|
||||
/// Implements everything relating to things that are displayed on screen.
|
||||
|
@ -167,6 +168,7 @@ pub mod mgba;
|
|||
pub use agb_fixnum as fixnum;
|
||||
/// Contains an implementation of a hashmap which suits the gameboy advance's hardware.
|
||||
pub use agb_hashmap as hash_map;
|
||||
#[cfg(feature = "backtrace")]
|
||||
mod panics_render;
|
||||
/// Simple random number generator
|
||||
pub mod rng;
|
||||
|
@ -201,10 +203,8 @@ pub use {agb_alloc::ExternalAllocator, agb_alloc::InternalAllocator};
|
|||
#[panic_handler]
|
||||
#[allow(unused_must_use)]
|
||||
fn panic_implementation(info: &core::panic::PanicInfo) -> ! {
|
||||
use core::fmt::Write;
|
||||
if let Some(mut mgba) = mgba::Mgba::new() {
|
||||
write!(mgba, "{}", info);
|
||||
mgba.set_level(mgba::DebugLevel::Fatal);
|
||||
let _ = mgba.print(format_args!("{info}"), mgba::DebugLevel::Fatal);
|
||||
}
|
||||
|
||||
#[allow(clippy::empty_loop)]
|
||||
|
@ -296,8 +296,6 @@ impl Gba {
|
|||
/// You can run the tests using `cargo test`, but it will work better through `mgba-test-runner` by
|
||||
/// running something along the lines of `CARGO_TARGET_THUMBV4T_NONE_EABI_RUNNER=mgba-test-runner cargo test`.
|
||||
pub mod test_runner {
|
||||
use self::panics_render::render_backtrace;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -327,13 +325,20 @@ pub mod test_runner {
|
|||
|
||||
#[panic_handler]
|
||||
fn panic_implementation(info: &core::panic::PanicInfo) -> ! {
|
||||
#[cfg(feature = "backtrace")]
|
||||
let frames = backtrace::unwind_exception();
|
||||
|
||||
if let Some(mut mgba) = mgba::Mgba::new() {
|
||||
let _ = mgba.print(format_args!("[failed]"), mgba::DebugLevel::Error);
|
||||
}
|
||||
|
||||
render_backtrace(&frames, info);
|
||||
#[cfg(feature = "backtrace")]
|
||||
crate::panics_render::render_backtrace(&frames, info);
|
||||
|
||||
#[cfg(not(feature = "backtrace"))]
|
||||
loop {
|
||||
syscall::halt();
|
||||
}
|
||||
}
|
||||
|
||||
static mut TEST_GBA: Option<Gba> = None;
|
||||
|
|
Loading…
Reference in a new issue