From da4b29bd3534a57bcb5f51759dcabbb6c16fa749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 15 Sep 2023 13:23:02 +0200 Subject: [PATCH] Make defmt a default feature --- espflash/Cargo.toml | 10 +++++++--- espflash/src/cli/monitor/mod.rs | 13 ++++++++++--- espflash/src/cli/monitor/parser/mod.rs | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/espflash/Cargo.toml b/espflash/Cargo.toml index 5ed527e2..b760de4c 100644 --- a/espflash/Cargo.toml +++ b/espflash/Cargo.toml @@ -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 } @@ -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", @@ -84,4 +84,8 @@ cli = [ "dep:regex", "dep:update-informer", ] +defmt = [ + "dep:defmt-decoder", + "dep:defmt-parser", +] raspberry = ["dep:rppal"] diff --git a/espflash/src/cli/monitor/mod.rs b/espflash/src/cli/monitor/mod.rs index 946d77c7..3e08b0fe 100644 --- a/espflash/src/cli/monitor/mod.rs +++ b/espflash/src/cli/monitor/mod.rs @@ -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. @@ -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. diff --git a/espflash/src/cli/monitor/parser/mod.rs b/espflash/src/cli/monitor/parser/mod.rs index 1ae9c85a..a5491764 100644 --- a/espflash/src/cli/monitor/parser/mod.rs +++ b/espflash/src/cli/monitor/parser/mod.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "defmt")] pub mod esp_defmt; pub mod serial;