Files
vt1200/harness/mame/build.sh
T

57 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# Build the minimal VT1200 MAME subtarget.
#
# harness/mame/build.sh # incremental
# harness/mame/build.sh clean # wipe object dir first
#
# Requires a MAME source checkout (default /home/arti/code/k-space/mame0289).
# The driver source lives in this repo and is symlinked into the MAME tree.
set -e
HERE=$(cd "$(dirname "$0")" && pwd)
MAME_SRC=${MAME_SRC:-/home/arti/code/k-space/mame0289}
JOBS=${JOBS:-8}
DRIVER="$HERE/vt1200.cpp"
DEST="$MAME_SRC/src/mame/dec/vt1200.cpp"
LOG="$HERE/build.log"
if [ ! -d "$MAME_SRC/src/mame" ]; then
echo "MAME source tree not found at $MAME_SRC (set MAME_SRC)" >&2
exit 1
fi
mkdir -p "$MAME_SRC/src/mame/dec"
ln -sf "$DRIVER" "$DEST"
# MAME's SOURCES= build only recognises source files registered in the master
# list (src/mame/mame.lst). Register ours idempotently.
if ! grep -q "@source:dec/vt1200.cpp" "$MAME_SRC/src/mame/mame.lst"; then
printf '@source:dec/vt1200.cpp\nvt1200\n' >> "$MAME_SRC/src/mame/mame.lst"
fi
cd "$MAME_SRC"
if [ "$1" = clean ]; then
rm -rf "obj/vt1200"
fi
# -j$(nproc). SUBTARGET + SOURCES gives a single-driver build; the device
# set (tms34010, screen, ...) is pulled in automatically.
# Build with a bounded parallel job count: the MAME tree is large and
# memory-hungry, and each C++ translation unit can use a lot of RAM.
# Defaults to 8; override with e.g. JOBS=4 harness/mame/build.sh
set -x
make -j"$JOBS" SUBTARGET=vt1200 SOURCES=src/mame/dec/vt1200.cpp REGENIE=1 > "$LOG" 2>&1
status=$?
set +x
if [ $status -ne 0 ]; then
echo
echo "BUILD FAILED (make exited $status); last lines of $LOG:" >&2
tail -25 "$LOG" >&2
exit 1
fi
echo
echo "built: $MAME_SRC/vt1200"