From a0e833cc556f52890b16f4f3cb1d7e989f0f28f5 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Wed, 23 Oct 2024 15:59:24 +0000 Subject: [PATCH] Fix building without yaml feature --- CHANGELOG.md | 1 + src/generate/device.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25439d50..942676c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/generate/device.rs b/src/generate/device.rs index 9f0ff909..4acf6609 100644 --- a/src/generate/device.rs +++ b/src/generate/device.rs @@ -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}; @@ -29,10 +29,15 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result { 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, };