Skip to content

Commit 731e1fe

Browse files
committed
Address review suggestions
1 parent ab77be8 commit 731e1fe

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10-
- Implement `riscv-pac` traits via experimental `riscv` element in SVD.
11-
You must use the `unstable-riscv` feature to use this.
10+
- Use standard `riscv-peripheral` peripherals via experimental `riscv.yaml` configuration file.
11+
You must compile `svd2rust` with the `unstable-riscv` feature to use this.
12+
- Implement `riscv-pac` traits via experimental `riscv.yaml` configuration file.
13+
You must compile `svd2rust` with the `unstable-riscv` feature to use this.
1214
- Fix `enumeratedValues` with `isDefault` only
1315

1416
## [v0.33.4] - 2024-06-16

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ default = ["bin", "json", "yaml"]
3535
bin = ["dep:clap", "dep:env_logger", "serde", "dep:irx-config"]
3636
json = ["dep:serde_json"]
3737
yaml = ["dep:serde_yaml"]
38-
unstable-riscv = []
38+
unstable-riscv = ["irx-config/yaml"]
3939

4040
[dependencies]
4141
clap = { version = "4.0", optional = true }

src/main.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![recursion_limit = "128"]
22

33
use log::{debug, error, info, warn};
4+
#[cfg(feature = "unstable-riscv")]
5+
use svd2rust::config::RiscvConfig;
46
use svd2rust::config::{IdentFormatError, IdentFormats, IdentFormatsTheme};
57
use svd2rust::util::IdentFormat;
68

@@ -18,6 +20,8 @@ use svd2rust::{
1820
};
1921

2022
fn parse_configs(app: Command) -> Result<Config> {
23+
#[cfg(feature = "unstable-riscv")]
24+
use irx_config::parsers::yaml;
2125
use irx_config::parsers::{cmd, toml};
2226
use irx_config::ConfigBuilder;
2327
let ident_formats = app.clone().get_matches();
@@ -29,10 +33,24 @@ fn parse_configs(app: Command) -> Result<Config> {
2933
.path_option("config")
3034
.ignore_missing_file(true)
3135
.build()?,
32-
)
33-
.load()?;
36+
);
37+
#[cfg(feature = "unstable-riscv")]
38+
let irxconfig = irxconfig.append_parser(
39+
yaml::ParserBuilder::default()
40+
.default_path("riscv.yaml")
41+
.path_option("riscv_cfg")
42+
.ignore_missing_file(true)
43+
.build()?,
44+
);
45+
let irxconfig = irxconfig.load()?;
3446

3547
let mut config: Config = irxconfig.get()?;
48+
49+
#[cfg(feature = "unstable-riscv")]
50+
if let Ok(riscv_config) = irxconfig.get::<RiscvConfig>() {
51+
config.riscv_config = Some(riscv_config);
52+
}
53+
3654
let mut idf = match config.ident_formats_theme {
3755
Some(IdentFormatsTheme::Legacy) => IdentFormats::legacy_theme(),
3856
_ => IdentFormats::default_theme(),
@@ -290,6 +308,15 @@ Ignore this option if you are not building your own FPGA based soft-cores."),
290308
env!("CARGO_PKG_VERSION"),
291309
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
292310
));
311+
#[cfg(feature = "unstable-riscv")]
312+
let app = app.arg(
313+
Arg::new("riscv_cfg")
314+
.long("riscv_config")
315+
.help("RISC-V Config YAML file")
316+
.short('r')
317+
.action(ArgAction::Set)
318+
.value_name("YAML_FILE"),
319+
);
293320

294321
let mut config = match parse_configs(app) {
295322
Ok(config) => {

0 commit comments

Comments
 (0)