~ruther/avr-device

ref: 169804d17a756d847904e712d189faf51dbfbdac avr-device/gen-intr-lut.sh -rwxr-xr-x 604 bytes
169804d1 — Rahix make: Use a patchfile instead of weird sed expr 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
# Generate a lookup table function for interrupts of all supported chips
set -e

echo     "// Autogenerated.  Do not edit."
echo     "pub fn lookup_vector(chip: &str, intr: &str) -> Option<usize> {"
echo     "    match chip {"

for intr_path in "$@"; do
    chip="$(basename "$(dirname "$intr_path")")"
    echo "        \"$chip\" => match intr {"

    sed '/Interrupt::.\+ =>/!d
s/ \+Interrupt::\(.\+\) => \(.\+\),/            "\1" => Some(\2),/' "$intr_path"

    echo "            _ => None,"
    echo "        },"
done

echo     "        _ => None,"
echo     "    }"
echo     "}"
Do not follow this link