From a0e833cc556f52890b16f4f3cb1d7e989f0f28f5 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Wed, 23 Oct 2024 15:59:24 +0000 Subject: [PATCH 1/3] 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, }; From dfb10b1b2fbaab5a19ea1835b0890c9dded8869b Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Wed, 23 Oct 2024 16:12:58 +0000 Subject: [PATCH 2/3] Fix warning about unused import --- src/generate/device.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generate/device.rs b/src/generate/device.rs index 4acf6609..fdecb54b 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::{anyhow, Context, Result}; +use anyhow::{Context, Result}; use crate::generate::{interrupt, peripheral, riscv}; @@ -36,7 +36,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result { - return Err(anyhow!("Support for yaml config files is not available because svd2rust was compiled without the yaml feature")); + return Err(anyhow::anyhow!("Support for yaml config files is not available because svd2rust was compiled without the yaml feature")); } None => None, }; From 224fc9de84040b03d9b98c93125a3cbe8f67069a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Gardstr=C3=B6m?= Date: Wed, 23 Oct 2024 16:18:34 +0000 Subject: [PATCH 3/3] check compilation with no features --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6dec204..a7ec6239 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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