Skip to content

Commit ce20880

Browse files
authored
Merge pull request #184 from rust-embedded/post-validate
post patch validate
2 parents 9537e0f + f2a55ba commit ce20880

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG-rust.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This changelog tracks the Rust `svdtools` project. See
1111
* Strip `alternateRegister` too
1212
* Add `modifiedWriteValues` and `readAction` field patch (#156)
1313
* Fix #144
14+
* Flag to check for errors after patching
1415

1516
## [v0.3.6] 2023-11-01
1617

src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ enum Command {
2929
#[clap(long)]
3030
format_config: Option<PathBuf>,
3131

32+
/// Check for errors after patching
33+
#[clap(long)]
34+
post_validate: bool,
35+
3236
/// When a patch error happens print formatted yaml with all rules included
3337
#[clap(long)]
3438
show_patch_on_error: bool,
@@ -125,10 +129,14 @@ impl Command {
125129
yaml_file,
126130
out_path,
127131
format_config,
132+
post_validate,
128133
show_patch_on_error,
129134
enum_derive,
130135
} => {
131136
let mut config = svdtools::patch::Config::default();
137+
if *post_validate {
138+
config.post_validate = svd_rs::ValidateLevel::Strict;
139+
}
132140
config.show_patch_on_error = *show_patch_on_error;
133141
if let Some(enum_derive) = enum_derive.as_ref() {
134142
config.enum_derive = *enum_derive;

src/patch/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const VAL_LVL: ValidateLevel = ValidateLevel::Weak;
3434
#[non_exhaustive]
3535
#[derive(Clone, Debug)]
3636
pub struct Config {
37+
pub post_validate: ValidateLevel,
3738
pub show_patch_on_error: bool,
3839
pub enum_derive: EnumAutoDerive,
3940
pub update_fields: bool,
@@ -56,6 +57,7 @@ pub enum EnumAutoDerive {
5657
impl Default for Config {
5758
fn default() -> Self {
5859
Self {
60+
post_validate: ValidateLevel::Disabled,
5961
show_patch_on_error: false,
6062
enum_derive: Default::default(),
6163
update_fields: true,
@@ -115,6 +117,8 @@ pub fn process_file(
115117
}
116118
})?;
117119

120+
svd.validate_all(config.post_validate)?;
121+
118122
// SVD should now be updated, write it out
119123
let config = get_encoder_config(format_config)?;
120124
let svd_out = svd_encoder::encode_with_config(&svd, &config)?;

0 commit comments

Comments
 (0)