Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building without yaml feature #877

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading