feat(games): add Snake and Tetris X11 games with menu integration
Add two standalone X11 games (not DWM plugins) for the Nokia 8110 keypad: - src/games/snake.cpp: Nokia Snake II-style game, 240x296, built-in 5x7 font - src/games/tetris.cpp: Tetris with next-piece preview, levels, line clears Both float as dialog windows in dwm, use a self-contained bitmap font (no font-file dependency), and are controlled via the numeric keypad (2/4/6/8 directions, 5 action) with arrow-key fallbacks. - scripts/build-games.sh: Docker armv7 cross-compile (mirrors build-sxmo-x11.sh) - overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_games.sh: Games menu hook - overlay/rootfs/usr/bin/sxmo_appmenu.sh: add 'Games' entry after 'Apps' and a games submenu case Binaries committed to prebuilt/games and overlay/rootfs/usr/bin per repo convention. Deployed and verified on the live device (window maps, dwm focuses it, keypad input reaches the game).
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
# Cross-compile Bananarchy standalone X11 games (Snake, Tetris) for armv7.
|
||||
set -eu
|
||||
|
||||
BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
ROOTFS_DIR="${ROOTFS_DIR:-$BASE_DIR/rootfs}"
|
||||
if [ -e "$ROOTFS_DIR" ]; then
|
||||
ROOTFS_DIR="$(realpath "$ROOTFS_DIR")"
|
||||
fi
|
||||
|
||||
exec docker run --rm --network=host \
|
||||
-e HOST_UID="$(id -u)" \
|
||||
-e HOST_GID="$(id -g)" \
|
||||
-v "$BASE_DIR:/bananarchy" \
|
||||
-v "$ROOTFS_DIR:/target-rootfs" \
|
||||
alpine:3.24 sh -eu -c '
|
||||
cat > /etc/apk/repositories <<EOF
|
||||
https://mirror.nura.eco/postmarketos/v26.06
|
||||
https://dl-cdn.alpinelinux.org/alpine/edge/main
|
||||
https://dl-cdn.alpinelinux.org/alpine/edge/community
|
||||
https://dl-cdn.alpinelinux.org/alpine/edge/testing
|
||||
EOF
|
||||
cp /bananarchy/keys/* /etc/apk/keys/
|
||||
|
||||
echo "[1/4] Installing host cross-compilation toolchain..."
|
||||
apk add --no-cache \
|
||||
build-base \
|
||||
gcc-armv7 \
|
||||
g++-armv7 \
|
||||
binutils-armv7 \
|
||||
pkgconf >/dev/null
|
||||
|
||||
echo "[2/4] Preparing armv7 sysroot (X11)..."
|
||||
SYSROOT="/tmp/armv7-sysroot"
|
||||
mkdir -p "$SYSROOT/etc/apk/keys"
|
||||
cp /etc/apk/repositories "$SYSROOT/etc/apk/repositories"
|
||||
cp /etc/apk/keys/* "$SYSROOT/etc/apk/keys/"
|
||||
apk --root "$SYSROOT" --initdb --arch armv7 add --no-scripts \
|
||||
alpine-baselayout \
|
||||
musl-dev \
|
||||
linux-headers \
|
||||
libx11-dev >/dev/null
|
||||
|
||||
export PKG_CONFIG_SYSROOT_DIR="$SYSROOT"
|
||||
export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig"
|
||||
CC="armv7-alpine-linux-musleabihf-gcc --sysroot=$SYSROOT"
|
||||
CXX="armv7-alpine-linux-musleabihf-g++ --sysroot=$SYSROOT"
|
||||
STRIP="armv7-alpine-linux-musleabihf-strip"
|
||||
OPT_CFLAGS="-O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -fno-plt -fomit-frame-pointer"
|
||||
|
||||
mkdir -p /bananarchy/prebuilt/games/usr/bin
|
||||
|
||||
echo "[3/4] Compiling Snake and Tetris..."
|
||||
$CXX $OPT_CFLAGS -std=c++17 -Wall -Wextra \
|
||||
/bananarchy/src/games/snake.cpp $(pkgconf --libs x11) \
|
||||
-o /bananarchy/prebuilt/games/usr/bin/snake
|
||||
$CXX $OPT_CFLAGS -std=c++17 -Wall -Wextra \
|
||||
/bananarchy/src/games/tetris.cpp $(pkgconf --libs x11) \
|
||||
-o /bananarchy/prebuilt/games/usr/bin/tetris
|
||||
$STRIP --strip-unneeded /bananarchy/prebuilt/games/usr/bin/snake /bananarchy/prebuilt/games/usr/bin/tetris
|
||||
|
||||
echo "[4/4] Installing into overlay and (optional) target rootfs..."
|
||||
mkdir -p /bananarchy/overlay/rootfs/usr/bin
|
||||
cp -a /bananarchy/prebuilt/games/usr/bin/. /bananarchy/overlay/rootfs/usr/bin/
|
||||
if [ -d /target-rootfs/usr/bin ]; then
|
||||
cp -a /bananarchy/prebuilt/games/usr/bin/. /target-rootfs/usr/bin/
|
||||
fi
|
||||
|
||||
chown -R "$HOST_UID:$HOST_GID" \
|
||||
/bananarchy/prebuilt/games \
|
||||
/bananarchy/overlay/rootfs/usr/bin \
|
||||
/bananarchy/src/games
|
||||
ls -lh /bananarchy/prebuilt/games/usr/bin/snake /bananarchy/prebuilt/games/usr/bin/tetris
|
||||
'
|
||||
Reference in New Issue
Block a user