Skip to content

Commit ca07fbc

Browse files
authored
Make esp-config structs de-serialization friendly (#3455)
* Make esp-config's structs de-serialization friendly * Simplify ConfigOption's constructor * CHANGELOG.md * Make sure `esp-wifi/build.rs` formats correctly * Typo * Run tests, again * Tests
1 parent d0eb59d commit ca07fbc

File tree

13 files changed

+566
-540
lines changed

13 files changed

+566
-540
lines changed

esp-backtrace/build.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use esp_build::assert_unique_used_features;
2-
use esp_config::{ConfigOption, Stability, Value, generate_config};
2+
use esp_config::{ConfigOption, generate_config};
33

44
fn main() {
55
// Ensure that only a single chip is specified:
@@ -15,14 +15,11 @@ fn main() {
1515
// emit config
1616
generate_config(
1717
"esp_backtrace",
18-
&[ConfigOption {
19-
name: "backtrace-frames",
20-
description: "The maximum number of frames that will be printed in a backtrace",
21-
default_value: Value::Integer(10),
22-
constraint: None,
23-
stability: Stability::Unstable,
24-
active: true,
25-
}],
18+
&[ConfigOption::new(
19+
"backtrace-frames",
20+
"The maximum number of frames that will be printed in a backtrace",
21+
10,
22+
)],
2623
true,
2724
true,
2825
);

esp-bootloader-esp-idf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ default-target = "riscv32imac-unknown-none-elf"
1515

1616
[lib]
1717
bench = false
18-
test = false
18+
test = true
1919

2020
[dependencies]
2121
defmt = { version = "1.0.1", optional = true }

esp-bootloader-esp-idf/build.rs

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::env;
22

33
use chrono::{TimeZone, Utc};
4-
use esp_config::{ConfigOption, Stability, Validator, Value, generate_config};
4+
use esp_config::{ConfigOption, Validator, generate_config};
55

66
fn main() {
77
let build_time = match env::var("SOURCE_DATE_EPOCH") {
@@ -19,40 +19,33 @@ fn main() {
1919
generate_config(
2020
"esp-bootloader-esp-idf",
2121
&[
22-
ConfigOption {
23-
name: "mmu_page_size",
24-
description: "ESP32-C2, ESP32-C6 and ESP32-H2 support configurable page sizes. \
22+
ConfigOption::new(
23+
"mmu_page_size",
24+
"ESP32-C2, ESP32-C6 and ESP32-H2 support configurable page sizes. \
2525
This is currently only used to populate the app descriptor.",
26-
default_value: Value::String(String::from("64k")),
27-
constraint: Some(Validator::Enumeration(vec![
28-
String::from("8k"),
29-
String::from("16k"),
30-
String::from("32k"),
31-
String::from("64k"),
32-
])),
33-
stability: Stability::Unstable,
34-
active: true, // TODO we need to know the device here
35-
},
36-
ConfigOption {
37-
name: "esp_idf_version",
38-
description: "ESP-IDF version used in the application descriptor. Currently it's \
26+
"64k",
27+
)
28+
.constraint(Validator::Enumeration(vec![
29+
String::from("8k"),
30+
String::from("16k"),
31+
String::from("32k"),
32+
String::from("64k"),
33+
])), // .active(true) TODO we need to know the device here
34+
ConfigOption::new(
35+
"esp_idf_version",
36+
"ESP-IDF version used in the application descriptor. Currently it's \
3937
not checked by the bootloader.",
40-
default_value: Value::String(String::from("0.0.0")),
41-
constraint: None,
42-
stability: Stability::Unstable,
43-
active: true,
44-
},
45-
ConfigOption {
46-
name: "partition-table-offset",
47-
description: "The address of partition table (by default 0x8000). Allows you to \
38+
"0.0.0",
39+
),
40+
ConfigOption::new(
41+
"partition-table-offset",
42+
"The address of partition table (by default 0x8000). Allows you to \
4843
move the partition table, it gives more space for the bootloader. Note that the \
49-
bootloader and app will both need to be compiled with the same |
44+
bootloader and app will both need to be compiled with the same \
5045
PARTITION_TABLE_OFFSET value.",
51-
default_value: Value::Integer(0x8000),
52-
constraint: Some(Validator::PositiveInteger),
53-
stability: Stability::Unstable,
54-
active: true,
55-
},
46+
0x8000,
47+
)
48+
.constraint(Validator::PositiveInteger),
5649
],
5750
true,
5851
true,

esp-config/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
- `generate_config` now takes a slice of `ConfigOption`s instead of tuples. (#3362)
1818
- Bump Rust edition to 2024, bump MSRV to 1.85. (#3391)
19+
- `ConfigOption` favors `String` over `&str` (#3455)
20+
- Removed the `Custom` validator (#3455)
1921

2022
### Fixed
2123

esp-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010

1111
[lib]
1212
bench = false
13-
test = false
13+
test = true
1414

1515
[dependencies]
1616
document-features = "0.2.11"

0 commit comments

Comments
 (0)