Skip to content

Commit dfdc200

Browse files
committed
Featurize defmt
1 parent 98d8f81 commit dfdc200

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ jobs:
4848
target: "armv7-unknown-linux-gnueabihf"
4949
arch: "armhf"
5050
features: "--features=raspberry"
51+
- os: "ubuntu-22.04"
52+
target: "x86_64-unknown-linux-gnu"
53+
arch: "x86_64"
54+
features: "--features=defmt"
5155
runs-on: ${{ matrix.platform.os }}
5256

5357
steps:
@@ -69,6 +73,9 @@ jobs:
6973
platform:
7074
- target: "x86_64-unknown-linux-gnu"
7175
arch: "x86_64"
76+
- target: "x86_64-unknown-linux-gnu"
77+
arch: "x86_64"
78+
features: "--features=defmt"
7279
- target: "aarch64-unknown-linux-gnu"
7380
arch: "arm64"
7481
features: "--features=raspberry"
@@ -96,6 +103,9 @@ jobs:
96103
platform:
97104
- target: "x86_64-unknown-linux-gnu"
98105
arch: "x86_64"
106+
- target: "x86_64-unknown-linux-gnu"
107+
arch: "x86_64"
108+
features: "--features=defmt"
99109
- target: "aarch64-unknown-linux-gnu"
100110
arch: "arm64"
101111
features: "--features=raspberry"
@@ -127,6 +137,9 @@ jobs:
127137
platform:
128138
- target: "x86_64-unknown-linux-gnu"
129139
arch: "x86_64"
140+
- target: "x86_64-unknown-linux-gnu"
141+
arch: "x86_64"
142+
features: "--features=defmt"
130143
- target: "aarch64-unknown-linux-gnu"
131144
arch: "arm64"
132145
features: "--features=raspberry"
@@ -157,6 +170,9 @@ jobs:
157170
platform:
158171
- target: "x86_64-unknown-linux-gnu"
159172
arch: "x86_64"
173+
- target: "x86_64-unknown-linux-gnu"
174+
arch: "x86_64"
175+
features: "--features=defmt"
160176
- target: "aarch64-unknown-linux-gnu"
161177
arch: "arm64"
162178
features: "--features=raspberry"

.github/workflows/release.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,34 @@ jobs:
1818
- os: "ubuntu-22.04"
1919
target: "x86_64-unknown-linux-gnu"
2020
arch: "x86_64"
21+
features: "--features=defmt"
2122
- os: "ubuntu-22.04"
2223
target: "x86_64-unknown-linux-musl"
2324
arch: "x86_64"
25+
features: "--features=defmt"
2426
- os: "ubuntu-22.04"
2527
target: "aarch64-unknown-linux-gnu"
2628
arch: "arm64"
27-
features: "--features=raspberry"
29+
features: "--features=raspberry,defmt"
2830
- os: "ubuntu-22.04"
2931
target: "armv7-unknown-linux-gnueabihf"
3032
arch: "armhf"
31-
features: "--features=raspberry"
33+
features: "--features=raspberry,defmt"
3234
# Windows
3335
- os: "windows-2022"
3436
target: "x86_64-pc-windows-msvc"
3537
arch: "x86_64"
38+
features: "--features=defmt"
3639
# macOs
3740
- os: "macos-12"
3841
target: "aarch64-apple-darwin"
3942
# This is not true, but simplifies the logic of the action.
4043
arch: "x86_64"
44+
features: "--features=defmt"
4145
- os: "macos-12"
4246
target: "x86_64-apple-darwin"
4347
arch: "x86_64"
48+
features: "--features=defmt"
4449
runs-on: ${{ matrix.platform.os }}
4550
steps:
4651

espflash/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ clap_complete = { version = "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 }
@@ -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)