Skip to content

Commit

Permalink
Fix building without yaml feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Oct 23, 2024
1 parent 8b809ac commit a0e833c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::Path;

use crate::config::{Config, Target};
use crate::util::{self, ident};
use anyhow::{Context, Result};
use anyhow::{anyhow, Context, Result};

use crate::generate::{interrupt, peripheral, riscv};

Expand All @@ -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!("Support for yaml config files is not available because svd2rust was compiled without the yaml feature"));
}
None => None,
};

Expand Down

0 comments on commit a0e833c

Please sign in to comment.