Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ jobs:
run: ./scripts/check-skills.sh
- name: scripts/check-irq-locks.sh (INV-3 / Rule 3.5.1)
run: ./scripts/check-irq-locks.sh

keyboard-layouts:
name: Keyboard layouts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# kbdcompile is a host-side std tool (no target needed).
- uses: dtolnay/rust-toolchain@stable

- name: scripts/check-keyboard-layouts.sh (#702)
run: ./scripts/check-keyboard-layouts.sh
8 changes: 5 additions & 3 deletions docs/design/neokbd-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,12 @@ Los layouts se generan desde los mismos archivos `.klc` existentes, pero convert

| Archivo | Layout | LangTag | Scancodes | Compose |
| --- | --- | --- | --- | --- |
| `US.kbd` | US | en-US | 256 | 0 |
| `Spanish.kbd` | Spanish | es-ES | 256 | 54 |
| `en-US.kbd` | en-US | en-US | 50 | 0 |
| `es-ES.kbd` | es-ES | es-ES | 50 | 54 |

La herramienta `kbdcompile` toma un `.klc` y produce un `.kbd` binario. Se invoca en el build de la imagen, no en runtime.
La herramienta `kbdcompile` toma un `.klc` y produce un `.kbd` binario. Se ejecuta
a mano con `scripts/gen-keyboard-layouts.sh` y `scripts/check-keyboard-layouts.sh`
lo valida en CI (no está enganchado al build de imagen; ver #702).

---

Expand Down
60 changes: 60 additions & 0 deletions scripts/check-keyboard-layouts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Verify that data/keyboard/<tag>.kbd are non-empty and in sync with their
# .klc sources (issue #702).
#
# Fails if a .kbd is missing, maps zero scancodes, or differs from a fresh
# kbdcompile run. Run from anywhere.
set -euo pipefail

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"

(cd tools/kbdcompile && cargo build --quiet)
bin=tools/kbdcompile/target/debug/kbdcompile

tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT

fail=0
shopt -s nullglob
found=0
for klc in data/keyboard/*.klc; do
found=1
tag="$(basename "$klc" .klc)"
kbd="data/keyboard/$tag.kbd"

if [ ! -f "$kbd" ]; then
echo "check-keyboard-layouts: missing $kbd" >&2
fail=1
continue
fi

if ! "$bin" "$klc" "$tmp/$tag.kbd" "$tag" "$tag" 2>"$tmp/$tag.err"; then
echo "check-keyboard-layouts: kbdcompile failed for $klc" >&2
fail=1
continue
fi

# Reject an empty layout (every scancode 0xFFFF).
if ! grep -qE '\([1-9][0-9]* scancodes' "$tmp/$tag.err"; then
echo "check-keyboard-layouts: $klc produces an empty layout" >&2
fail=1
fi

# Reject a stale committed artifact.
if ! cmp -s "$tmp/$tag.kbd" "$kbd"; then
echo "check-keyboard-layouts: $kbd is stale (differs from a fresh compile)" >&2
fail=1
fi
done

if [ "$found" -eq 0 ]; then
echo "check-keyboard-layouts: no .klc sources found under data/keyboard/" >&2
exit 1
fi

if [ "$fail" -ne 0 ]; then
echo "check-keyboard-layouts: FAILED — regenerate with scripts/gen-keyboard-layouts.sh" >&2
exit 1
fi
echo "check-keyboard-layouts: OK"
26 changes: 26 additions & 0 deletions scripts/gen-keyboard-layouts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Regenerate data/keyboard/<tag>.kbd from data/keyboard/<tag>.klc with kbdcompile.
#
# The layout files are committed artifacts, so this is run by hand when a .klc
# changes (see issue #702). `check-keyboard-layouts.sh` guards against drift.
set -euo pipefail

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"

(cd tools/kbdcompile && cargo build --quiet)
bin=tools/kbdcompile/target/debug/kbdcompile

shopt -s nullglob
found=0
for klc in data/keyboard/*.klc; do
found=1
tag="$(basename "$klc" .klc)"
"$bin" "$klc" "data/keyboard/$tag.kbd" "$tag" "$tag"
done

if [ "$found" -eq 0 ]; then
echo "gen-keyboard-layouts: no .klc sources found under data/keyboard/" >&2
exit 1
fi
echo "gen-keyboard-layouts: done"