Skip to content

Commit 8a8b7a7

Browse files
Merge #131
131: Remove unproven r=burrbull a=brainstorm Fixes #116 @marcoieni @burrbull Let's do what you suggest on #116, shall we? See the integration [test mostly borrowed from @marcoieni's `svd_parser`](https://github.com/rust-embedded/svd/pull/131/files#diff-eb771f54a1fdc1c330a82981d7d27d1202a5cbe3a59581ff67af5e3361f5f90e) Getting the following error for now, ~seems like getting the same capitalization (and perhaps ordering?) might be challenging for integration testing purposes~... nope, it's just `<fields />` being empty, I guess the SVD parser should tolerate that?: ```xml <peripheral> <name>RNG</name> <description>RNG register</description> <baseAddress>0x3FF20E44</baseAddress> <addressBlock> <offset>0</offset> <size>32</size> <usage>RNG register</usage> </addressBlock> <registers> <register> <name>rng</name> <fields /> <description>RNG register</description> <addressOffset>0</addressOffset> <size>32</size> <access>read-only</access> <resetValue>0</resetValue> </register> </registers> </peripheral> ``` ```rust ---- read_and_write stdout ---- thread 'read_and_write' panicked at 'Failed to parse the SVD file into Rust structs: In device `esp8266` Caused by: 0: In peripheral `RNG` 1: In register `rng` 2: Register have `fields` tag, but it is empty', tests/integration.rs:14:38 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Co-authored-by: Roman Valls Guimera <[email protected]>
2 parents 5915c96 + 799fb33 commit 8a8b7a7

30 files changed

+22
-109
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
[._]*.sw[a-p]
33
Cargo.lock
44
target
5-
tests/

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Fix: produce error on 0-width fields
1616
- Fix: error instead of panic when an array/cluster name is missing the `%s` placeholder
1717
- [breaking-change] Add support for 64 addresses, register values, enum values and writeConstraints
18+
- [breaking-change] Remove unproven flag
1819

1920
## [v0.9.0] - 2019-11-17
2021

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ readme = "README.md"
1515

1616
[features]
1717
derive-from = []
18-
unproven = []
1918

2019
[dependencies]
2120
xmltree = "0.8"
2221
anyhow = "1.0.19"
2322
thiserror = "1.0.5"
24-
rayon = "1.3.0"
25-
once_cell = "1.3.1"
23+
rayon = "1.5.0"
24+
once_cell = "1.5.2"
2625
regex = "1"
2726

2827
[dependencies.serde]

cmsis-svd

Submodule cmsis-svd updated from 25cbf47 to e5db238

src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
2525
#![deny(warnings)]
2626

27-
#[cfg(feature = "unproven")]
2827
use std::collections::HashMap;
29-
3028
use xmltree::Element;
3129

3230
// ElementExt extends XML elements with useful methods
@@ -41,9 +39,7 @@ use anyhow::Result;
4139
pub mod parse;
4240
use parse::Parse;
4341
// Encode defines encoding interfaces
44-
#[cfg(feature = "unproven")]
4542
pub mod encode;
46-
#[cfg(feature = "unproven")]
4743
use encode::Encode;
4844
// Types defines simple types and parse/encode implementations
4945
pub mod types;
@@ -61,7 +57,6 @@ pub fn parse(xml: &str) -> Result<Device> {
6157
}
6258

6359
/// Encodes a device object to an SVD (XML) string
64-
#[cfg(feature = "unproven")]
6560
pub fn encode(d: &Device) -> Result<String> {
6661
let root = d.encode()?;
6762
let mut wr = Vec::new();
@@ -79,7 +74,6 @@ fn trim_utf8_bom(s: &str) -> &str {
7974
}
8075

8176
/// Helper to create new base xml elements
82-
#[cfg(feature = "unproven")]
8377
pub(crate) fn new_element(name: &str, text: Option<String>) -> Element {
8478
Element {
8579
prefix: None,
@@ -96,7 +90,6 @@ pub(crate) fn new_element(name: &str, text: Option<String>) -> Element {
9690
/// Takes an array of (item, xml) pairs where the item implements
9791
/// Parse and Encode and tests object encoding and decoding
9892
#[cfg(test)]
99-
#[cfg(feature = "unproven")]
10093
pub fn run_test<
10194
T: Parse<Error = anyhow::Error, Object = T>
10295
+ Encode<Error = anyhow::Error>

src/svd/access.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use xmltree::Element;
22

33
use crate::elementext::ElementExt;
4-
#[cfg(feature = "unproven")]
54
use crate::encode::Encode;
65
use crate::error::*;
7-
#[cfg(feature = "unproven")]
86
use crate::new_element;
97
use crate::types::Parse;
108

@@ -36,7 +34,6 @@ impl Parse for Access {
3634
}
3735
}
3836

39-
#[cfg(feature = "unproven")]
4037
impl Encode for Access {
4138
type Error = anyhow::Error;
4239

@@ -54,7 +51,6 @@ impl Encode for Access {
5451
}
5552

5653
#[cfg(test)]
57-
#[cfg(feature = "unproven")]
5854
mod tests {
5955
use super::*;
6056
use crate::run_test;

src/svd/addressblock.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
#[cfg(feature = "unproven")]
21
use std::collections::HashMap;
32

43
use crate::elementext::ElementExt;
54
use xmltree::Element;
65

76
use crate::types::Parse;
87

9-
#[cfg(feature = "unproven")]
108
use crate::encode::Encode;
119
use crate::error::*;
12-
#[cfg(feature = "unproven")]
1310
use crate::new_element;
1411

1512
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@@ -33,7 +30,6 @@ impl Parse for AddressBlock {
3330
}
3431
}
3532

36-
#[cfg(feature = "unproven")]
3733
impl Encode for AddressBlock {
3834
type Error = anyhow::Error;
3935

@@ -55,7 +51,6 @@ impl Encode for AddressBlock {
5551
}
5652

5753
#[cfg(test)]
58-
#[cfg(feature = "unproven")]
5954
mod tests {
6055
use super::*;
6156
use crate::run_test;

src/svd/bitrange.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use xmltree::Element;
22

33
use crate::error::*;
4-
#[cfg(feature = "unproven")]
54
use crate::new_element;
65
use crate::types::Parse;
76

@@ -120,7 +119,7 @@ impl Parse for BitRange {
120119
})
121120
}
122121
}
123-
#[cfg(feature = "unproven")]
122+
124123
impl BitRange {
125124
// TODO: Encode method differs from Encode trait as it acts on a set of possible children, create an interface or decide how to better do this
126125
pub fn encode(&self) -> Result<Vec<Element>> {
@@ -142,7 +141,6 @@ impl BitRange {
142141
}
143142

144143
#[cfg(test)]
145-
#[cfg(feature = "unproven")]
146144
mod tests {
147145
use super::*;
148146

src/svd/cluster.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use xmltree::Element;
33

44
use crate::types::Parse;
55

6-
#[cfg(feature = "unproven")]
76
use crate::elementext::ElementExt;
8-
#[cfg(feature = "unproven")]
97
use crate::encode::Encode;
108
use crate::error::*;
119
use crate::svd::{clusterinfo::ClusterInfo, dimelement::DimElement};
@@ -55,7 +53,6 @@ impl Parse for Cluster {
5553
}
5654
}
5755

58-
#[cfg(feature = "unproven")]
5956
impl Encode for Cluster {
6057
type Error = anyhow::Error;
6158

src/svd/clusterinfo.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use xmltree::Element;
33

44
use crate::types::Parse;
55

6-
#[cfg(feature = "unproven")]
76
use crate::encode::{Encode, EncodeChildren};
8-
#[cfg(feature = "unproven")]
97
use crate::new_element;
108

119
use crate::error::*;
@@ -153,7 +151,6 @@ impl ClusterInfo {
153151
}
154152
}
155153

156-
#[cfg(feature = "unproven")]
157154
impl Encode for ClusterInfo {
158155
type Error = anyhow::Error;
159156

src/svd/cpu.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
#[cfg(feature = "unproven")]
21
use std::collections::HashMap;
32

43
use xmltree::Element;
54

65
use crate::elementext::ElementExt;
7-
#[cfg(feature = "unproven")]
86
use crate::encode::Encode;
97
use crate::error::*;
10-
#[cfg(feature = "unproven")]
8+
119
use crate::new_element;
1210
use crate::svd::endian::Endian;
1311
use crate::types::Parse;
@@ -137,7 +135,6 @@ impl Parse for Cpu {
137135
}
138136
}
139137

140-
#[cfg(feature = "unproven")]
141138
impl Encode for Cpu {
142139
type Error = anyhow::Error;
143140

@@ -172,7 +169,6 @@ impl Cpu {
172169
}
173170

174171
#[cfg(test)]
175-
#[cfg(feature = "unproven")]
176172
mod tests {
177173
use super::*;
178174
use crate::run_test;

src/svd/device.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::elementext::ElementExt;
2-
#[cfg(feature = "unproven")]
32
use std::collections::HashMap;
43
use xmltree::Element;
54

@@ -8,10 +7,9 @@ use rayon::prelude::*;
87
use crate::parse;
98
use crate::types::Parse;
109

11-
#[cfg(feature = "unproven")]
1210
use crate::encode::{Encode, EncodeChildren};
1311
use crate::error::*;
14-
#[cfg(feature = "unproven")]
12+
1513
use crate::new_element;
1614
use crate::svd::{cpu::Cpu, peripheral::Peripheral, registerproperties::RegisterProperties};
1715

@@ -180,7 +178,6 @@ impl Device {
180178
}
181179
}
182180

183-
#[cfg(feature = "unproven")]
184181
impl Encode for Device {
185182
type Error = anyhow::Error;
186183

src/svd/dimelement.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use xmltree::Element;
33
use crate::types::{parse_optional, DimIndex, Parse};
44

55
use crate::elementext::ElementExt;
6-
#[cfg(feature = "unproven")]
76
use crate::encode::Encode;
8-
#[cfg(feature = "unproven")]
97
use crate::new_element;
108

119
use crate::error::*;
@@ -77,7 +75,6 @@ impl Parse for DimElement {
7775
}
7876
}
7977

80-
#[cfg(feature = "unproven")]
8178
impl Encode for DimElement {
8279
type Error = anyhow::Error;
8380

@@ -100,7 +97,6 @@ impl Encode for DimElement {
10097
}
10198

10299
#[cfg(test)]
103-
#[cfg(feature = "unproven")]
104100
mod tests {
105101
use super::*;
106102
use crate::run_test;

src/svd/endian.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#[cfg(feature = "unproven")]
21
use std::collections::HashMap;
32

43
use xmltree::Element;
54

65
use crate::elementext::ElementExt;
7-
#[cfg(feature = "unproven")]
86
use crate::encode::Encode;
97
use crate::types::Parse;
108

@@ -36,7 +34,6 @@ impl Parse for Endian {
3634
}
3735
}
3836

39-
#[cfg(feature = "unproven")]
4037
impl Encode for Endian {
4138
type Error = anyhow::Error;
4239

@@ -61,7 +58,6 @@ impl Encode for Endian {
6158
}
6259

6360
#[cfg(test)]
64-
#[cfg(feature = "unproven")]
6561
mod tests {
6662
use super::*;
6763
use crate::run_test;

src/svd/enumeratedvalue.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
#[cfg(feature = "unproven")]
21
use std::collections::HashMap;
32

43
use crate::elementext::ElementExt;
54
use crate::parse;
65
use xmltree::Element;
76

8-
#[cfg(feature = "unproven")]
97
use crate::encode::Encode;
108
use crate::error::*;
11-
#[cfg(feature = "unproven")]
129
use crate::new_element;
1310
use crate::types::Parse;
1411

@@ -130,7 +127,6 @@ impl Parse for EnumeratedValue {
130127
}
131128
}
132129

133-
#[cfg(feature = "unproven")]
134130
impl Encode for EnumeratedValue {
135131
type Error = anyhow::Error;
136132

@@ -165,7 +161,6 @@ impl Encode for EnumeratedValue {
165161
}
166162

167163
#[cfg(test)]
168-
#[cfg(feature = "unproven")]
169164
mod tests {
170165
use super::*;
171166
use crate::run_test;

src/svd/enumeratedvalues.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
#[cfg(feature = "unproven")]
21
use std::collections::HashMap;
32

43
use crate::elementext::ElementExt;
54
use xmltree::Element;
65

7-
#[cfg(feature = "unproven")]
86
use crate::encode::Encode;
97
use crate::error::*;
10-
#[cfg(feature = "unproven")]
8+
119
use crate::new_element;
1210
use crate::parse;
1311
use crate::svd::{enumeratedvalue::EnumeratedValue, usage::Usage};
@@ -143,7 +141,6 @@ impl Parse for EnumeratedValues {
143141
}
144142
}
145143

146-
#[cfg(feature = "unproven")]
147144
impl Encode for EnumeratedValues {
148145
type Error = anyhow::Error;
149146

@@ -180,7 +177,6 @@ impl Encode for EnumeratedValues {
180177
}
181178

182179
#[cfg(test)]
183-
#[cfg(feature = "unproven")]
184180
mod tests {
185181
use super::*;
186182
use crate::svd::enumeratedvalue::EnumeratedValueBuilder;

src/svd/field.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use xmltree::Element;
44

55
use crate::types::Parse;
66

7-
#[cfg(feature = "unproven")]
87
use crate::elementext::ElementExt;
9-
#[cfg(feature = "unproven")]
8+
109
use crate::encode::Encode;
1110
use crate::error::*;
1211
use crate::svd::{dimelement::DimElement, fieldinfo::FieldInfo};
@@ -51,7 +50,7 @@ impl Parse for Field {
5150
}
5251
}
5352

54-
#[cfg(feature = "unproven")]
53+
5554
impl Encode for Field {
5655
type Error = anyhow::Error;
5756

@@ -69,7 +68,6 @@ impl Encode for Field {
6968
}
7069

7170
#[cfg(test)]
72-
#[cfg(feature = "unproven")]
7371
mod tests {
7472
use super::*;
7573
use crate::bitrange::{BitRange, BitRangeType};

0 commit comments

Comments
 (0)