Skip to content

Commit da4b29b

Browse files
committed
Make defmt a default feature
1 parent 1a6d42f commit da4b29b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

espflash/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ clap_complete = { version = "4.4.3", optional = true }
4040
comfy-table = { version = "7.0.1", optional = true }
4141
crossterm = { version = "0.25.0", optional = true } # 0.26.x causes issues on Windows
4242
ctrlc = { version = "3.4.0", optional = true }
43-
defmt-decoder = { version = "=0.3.8", features = ["unstable"] }
44-
defmt-parser = { version = "=0.3.3", features = ["unstable"] }
43+
defmt-decoder = { version = "=0.3.8", features = ["unstable"], optional = true }
44+
defmt-parser = { version = "=0.3.3", features = ["unstable"], optional = true }
4545
dialoguer = { version = "0.10.4", optional = true }
4646
directories = { version = "5.0.1", optional = true }
4747
env_logger = { version = "0.10.0", optional = true }
@@ -66,7 +66,7 @@ update-informer = { version = "1.1.0", optional = true }
6666
xmas-elf = "0.9.0"
6767

6868
[features]
69-
default = ["cli"]
69+
default = ["cli", "defmt"]
7070
cli = [
7171
"dep:addr2line",
7272
"dep:clap",
@@ -84,4 +84,8 @@ cli = [
8484
"dep:regex",
8585
"dep:update-informer",
8686
]
87+
defmt = [
88+
"dep:defmt-decoder",
89+
"dep:defmt-parser",
90+
]
8791
raspberry = ["dep:rppal"]

espflash/src/cli/monitor/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ use log::error;
2323
use miette::{IntoDiagnostic, Result};
2424

2525
use crate::{
26-
cli::monitor::parser::{esp_defmt::EspDefmt, InputParser, ResolvingPrinter},
26+
cli::monitor::parser::{InputParser, ResolvingPrinter},
2727
connection::reset_after_flash,
2828
interface::Interface,
2929
};
3030

31+
pub mod parser;
32+
3133
mod line_endings;
32-
mod parser;
3334
mod symbols;
3435

3536
/// Type that ensures that raw mode is disabled when dropped.
@@ -57,7 +58,13 @@ pub fn monitor(
5758
pid: u16,
5859
baud: u32,
5960
) -> serialport::Result<()> {
60-
monitor_with(serial, elf, pid, baud, EspDefmt::new(elf))
61+
#[cfg(feature = "defmt")]
62+
let parser = parser::esp_defmt::EspDefmt::new(elf);
63+
64+
#[cfg(not(feature = "defmt"))]
65+
let parser = parser::serial::Serial;
66+
67+
monitor_with(serial, elf, pid, baud, parser)
6168
}
6269

6370
/// Open a serial monitor on the given interface, using the given input parser.

espflash/src/cli/monitor/parser/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(feature = "defmt")]
12
pub mod esp_defmt;
23
pub mod serial;
34

0 commit comments

Comments
 (0)