Skip to content

Commit b1096f1

Browse files
committed
expand_properties
1 parent b230b2b commit b1096f1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ clap = { version = "3.0", features = ["derive"] }
2828
serde = { version = "1.0", features = ["derive"] }
2929
quick-xml = { version = "0.18", features = ["serialize"] }
3030
svd-rs = { version = "0.13.2", features = ["serde", "derive-from"] }
31-
svd-parser = { version = "0.13.2", features = ["expand"] }
31+
svd-parser = { version = "0.13.4", features = ["expand"] }
3232
svd-encoder = "0.13.1"
3333
yaml-rust = "0.4"
3434
serde_yaml = "0.8.23"

src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ enum Command {
6464
#[clap(long)]
6565
expand: bool,
6666

67+
/// Take size, access, reset_value, reset_mask from parents if absent in register
68+
#[clap(long)]
69+
expand_properties: bool,
70+
6771
/// Skip enumeratedValues and writeConstraints during parsing (XML input only)
6872
#[clap(long)]
6973
ignore_enums: bool,
@@ -88,13 +92,15 @@ impl Command {
8892
input_format,
8993
output_format,
9094
expand,
95+
expand_properties,
9196
ignore_enums,
9297
} => convert_cli::convert(
9398
in_path,
9499
out_path,
95100
*input_format,
96101
*output_format,
97102
*expand,
103+
*expand_properties,
98104
*ignore_enums,
99105
)?,
100106
}

src/convert/convert_cli.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn convert(
4949
input_format: Option<InputFormat>,
5050
output_format: Option<OutputFormat>,
5151
expand: bool,
52+
expand_properties: bool,
5253
ignore_enums: bool,
5354
) -> Result<()> {
5455
let input_format = match input_format {
@@ -69,14 +70,17 @@ pub fn convert(
6970
let mut input = String::new();
7071
File::open(in_path)?.read_to_string(&mut input)?;
7172

72-
let device = match input_format {
73+
let mut device = match input_format {
7374
InputFormat::Xml => svd_parser::parse_with_config(
7475
&input,
7576
&svd_parser::Config::default().ignore_enums(ignore_enums),
7677
)?,
7778
InputFormat::Yaml => serde_yaml::from_str(&input)?,
7879
InputFormat::Json => serde_json::from_str(&input)?,
7980
};
81+
if expand_properties {
82+
svd_parser::expand_properties(&mut device);
83+
}
8084
let device = if expand {
8185
svd_parser::expand(&device)?
8286
} else {

0 commit comments

Comments
 (0)