Skip to content

Commit

Permalink
Merge pull request #877 from jannic-dev-forks/issue-875
Browse files Browse the repository at this point in the history
Fix building without yaml feature
  • Loading branch information
Emilgardis authored Oct 23, 2024
2 parents 8b809ac + 224fc9d commit 4563540
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
with:
key: ${{ matrix.TARGET }}

- run: cargo check --target ${{ matrix.TARGET }} --no-default-features
env:
RUSTFLAGS: -D warnings
- run: cargo check --target ${{ matrix.TARGET }}
env:
RUSTFLAGS: -D warnings
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Fix building without `yaml` feature
- Compatibility with `riscv` 0.12 and `riscv-rt` 0.13
- Add `riscv_config` section in `settings.yaml`
It uses `riscv-pac` traits and standard `riscv-peripheral` peripherals.
Expand Down
5 changes: 5 additions & 0 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
};

let settings = match config.settings.as_ref() {
#[cfg(feature = "yaml")]
Some(settings) => {
let file = std::fs::read_to_string(settings).context("could not read settings file")?;
Some(serde_yaml::from_str(&file).context("could not parse settings file")?)
}
#[cfg(not(feature = "yaml"))]
Some(_) => {
return Err(anyhow::anyhow!("Support for yaml config files is not available because svd2rust was compiled without the yaml feature"));
}
None => None,
};

Expand Down

0 comments on commit 4563540

Please sign in to comment.