Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Fix: println without colors not printing (#53)
Browse files Browse the repository at this point in the history
* Fix conditions

* Better CI checks

* Speed-up CI
  • Loading branch information
bjoernQ authored Feb 7, 2024
1 parent 084b33b commit 5640d8e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ jobs:
check-riscv:
name: Check RISC-V
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32c2, esp32c3, esp32c6, esp32h2, esp32p4]
printer: ["esp-println/uart"]
colors: ["colors"]
method: ["println"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
Expand All @@ -28,21 +31,45 @@ jobs:
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --features=${{ matrix.chip }},panic-handler,exception-handler,println,${{ matrix.printer }}
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}

check-xtensa:
name: Check Xtensa
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32, esp32s2, esp32s3]
printer: ["esp-println/uart"]
colors: ["colors"]
method: ["println"]
steps:
- uses: actions/checkout@v3
- uses: esp-rs/xtensa-toolchain@v1.5
with:
default: true
ldproxy: false
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=xtensa-${{ matrix.chip }}-none-elf --features=${{ matrix.chip }},panic-handler,exception-handler,println,${{ matrix.printer }}
- run: cargo check -Zbuild-std=core --target=xtensa-${{ matrix.chip }}-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}

check-features:
name: Check unusual feature combinations
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32c3]
colors: ["colors", ""]
method: ["println","defmt"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imc-unknown-none-elf
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
#[cfg(nightly)]
{
if let Some(message) = info.message() {
#[cfg(not(feature = "defmt"))]
println!("{}", message);

#[cfg(feature = "defmt")]
println!("{}", defmt::Display2Format(message));
}
}

Expand All @@ -95,7 +99,7 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
#[cfg(all(feature = "colors", feature = "println"))]
println!("{}0x{:x}", RED, addr - crate::arch::RA_OFFSET);

#[cfg(not(any(feature = "colors", feature = "println")))]
#[cfg(not(all(feature = "colors", feature = "println")))]
println!("0x{:x}", addr - crate::arch::RA_OFFSET);
}
}
Expand Down Expand Up @@ -192,7 +196,11 @@ fn exception_handler(context: &arch::TrapFrame) -> ! {
}
for e in backtrace {
if let Some(addr) = e {
println!("0x{:x}", addr);
#[cfg(all(feature = "colors", feature = "println"))]
println!("{}0x{:x}", RED, addr - crate::arch::RA_OFFSET);

#[cfg(not(all(feature = "colors", feature = "println")))]
println!("0x{:x}", addr - crate::arch::RA_OFFSET);
}
}
}
Expand Down

0 comments on commit 5640d8e

Please sign in to comment.