~ruther/avr-device

ref: 6f0b1cc9148270b0fd4a0f1b25c0a6dd0a3c6035 avr-device/gen-intr-lut.sh -rwxr-xr-x 604 bytes
6f0b1cc9 — Rahix gen-intr-lut: Switch to /usr/bin/env bash as interpreter 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