Skip to content

Commit

Permalink
Make defmt a default feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 3, 2023
1 parent 1a6d42f commit da4b29b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 7 additions & 3 deletions espflash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ clap_complete = { version = "4.4.3", optional = true }
comfy-table = { version = "7.0.1", optional = true }
crossterm = { version = "0.25.0", optional = true } # 0.26.x causes issues on Windows
ctrlc = { version = "3.4.0", optional = true }
defmt-decoder = { version = "=0.3.8", features = ["unstable"] }
defmt-parser = { version = "=0.3.3", features = ["unstable"] }
defmt-decoder = { version = "=0.3.8", features = ["unstable"], optional = true }
defmt-parser = { version = "=0.3.3", features = ["unstable"], optional = true }
dialoguer = { version = "0.10.4", optional = true }
directories = { version = "5.0.1", optional = true }
env_logger = { version = "0.10.0", optional = true }
Expand All @@ -66,7 +66,7 @@ update-informer = { version = "1.1.0", optional = true }
xmas-elf = "0.9.0"

[features]
default = ["cli"]
default = ["cli", "defmt"]
cli = [
"dep:addr2line",
"dep:clap",
Expand All @@ -84,4 +84,8 @@ cli = [
"dep:regex",
"dep:update-informer",
]
defmt = [
"dep:defmt-decoder",
"dep:defmt-parser",
]
raspberry = ["dep:rppal"]
13 changes: 10 additions & 3 deletions espflash/src/cli/monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ use log::error;
use miette::{IntoDiagnostic, Result};

use crate::{
cli::monitor::parser::{esp_defmt::EspDefmt, InputParser, ResolvingPrinter},
cli::monitor::parser::{InputParser, ResolvingPrinter},
connection::reset_after_flash,
interface::Interface,
};

pub mod parser;

mod line_endings;
mod parser;
mod symbols;

/// Type that ensures that raw mode is disabled when dropped.
Expand Down Expand Up @@ -57,7 +58,13 @@ pub fn monitor(
pid: u16,
baud: u32,
) -> serialport::Result<()> {
monitor_with(serial, elf, pid, baud, EspDefmt::new(elf))
#[cfg(feature = "defmt")]
let parser = parser::esp_defmt::EspDefmt::new(elf);

#[cfg(not(feature = "defmt"))]
let parser = parser::serial::Serial;

monitor_with(serial, elf, pid, baud, parser)
}

/// Open a serial monitor on the given interface, using the given input parser.
Expand Down
1 change: 1 addition & 0 deletions espflash/src/cli/monitor/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "defmt")]
pub mod esp_defmt;
pub mod serial;

Expand Down

0 comments on commit da4b29b

Please sign in to comment.