Files
xteink-web-emulator/scripts/build-qemu.sh
T
2026-07-19 19:23:51 -04:00

34 lines
852 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SRC="${QEMU_SRC:-$ROOT/_scratch/qemu-src}"
TAG="esp-develop-9.2.2-20260417"
PATCH="$ROOT/qemu/patches/0001-xteink-x3-machine.patch"
JOBS="${JOBS:-2}"
if [ ! -d "$SRC/.git" ]; then
git clone --depth 1 --branch "$TAG" https://github.com/espressif/qemu "$SRC"
fi
cd "$SRC"
if git apply --check "$PATCH" 2>/dev/null; then
git apply "$PATCH"
elif ! git apply --reverse --check "$PATCH" 2>/dev/null; then
echo "QEMU source has changes that conflict with $PATCH" >&2
exit 1
fi
if [ ! -f build/build.ninja ]; then
./configure \
--target-list=riscv32-softmmu \
--enable-gcrypt \
--enable-slirp \
--disable-werror \
--disable-docs \
--disable-tools
fi
ninja -C build -j"$JOBS" qemu-system-riscv32
printf '%s\n' "$SRC/build/qemu-system-riscv32"