From 0c63ac5cdcc8d6b0487e3e139d4dbafa4d8286e9 Mon Sep 17 00:00:00 2001 From: Jan Paw Date: Fri, 4 Dec 2020 22:50:25 +0100 Subject: [PATCH] Replace gen-intr-lut.sh sed hack with svdtools svdtools comes with a command to list all interrupts from an SVD file. Use this instead of fragile sed magic which parses the generated rust code. --- Makefile | 4 ++-- gen-intr-lut.sh | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4103de8..65b6a95 100644 --- a/Makefile +++ b/Makefile @@ -51,9 +51,9 @@ src/devices/%/mod.rs: src/devices/%/mod.full.rs @# to the global version @patch --no-backup-if-mismatch --quiet $@ patch/modrs.patch @echo -e "\tGEN-VECTOR\t>macros/src/vector.rs" - @./gen-intr-lut.sh src/devices/*/interrupt.rs >macros/src/vector.rs + @./gen-intr-lut.sh svd/*.patched >macros/src/vector.rs -macros/src/vector.rs: src/devices/*/interrupt.rs +macros/src/vector.rs: svd/*.patched @echo -e "\tGEN-VECTOR\t>macros/src/vector.rs" @./gen-intr-lut.sh $^ >$@ diff --git a/gen-intr-lut.sh b/gen-intr-lut.sh index 1cd83f5..3be5957 100755 --- a/gen-intr-lut.sh +++ b/gen-intr-lut.sh @@ -7,12 +7,10 @@ echo "pub fn lookup_vector(chip: &str, intr: &str) -> Option {" echo " match chip {" for intr_path in "$@"; do - chip="$(basename "$(dirname "$intr_path")")" + chip="$(basename "${intr_path%.svd.patched}")" echo " \"$chip\" => match intr {" - - sed '/=> Ok(Interrupt::.\+),$/!d - s/ \+\(.\+\) => Ok(Interrupt::\(.\+\)),$/ "\2" => Some(\1),/' "$intr_path" - + # toupper() to be compliant with svd2rust interrupts name + svd interrupts --no-gaps $intr_path | awk '{print " \""toupper(substr($2, 1, length($2)-1))"\"" " => Some(" $1"),"}' echo " _ => None," echo " }," done -- 2.49.0