forked from arti/vt1200
72 lines
2.2 KiB
Bash
Executable File
72 lines
2.2 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
|
|
# harness/mame/build.sh test # unit-test the board model (no MAME)
|
|
#
|
|
# 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"
|
|
BOARD_HDR="$HERE/vt1200_board.h"
|
|
BOARD="$HERE/vt1200_board.cpp"
|
|
TEST="$HERE/test_vt1200_board.cpp"
|
|
DEST="$MAME_SRC/src/mame/dec/vt1200.cpp"
|
|
BOARD_HDR_DEST="$MAME_SRC/src/mame/dec/vt1200_board.h"
|
|
BOARD_DEST="$MAME_SRC/src/mame/dec/vt1200_board.cpp"
|
|
LOG="$HERE/build.log"
|
|
|
|
# Unit-test the board model with plain g++ (no MAME). `build.sh test`.
|
|
if [ "$1" = test ]; then
|
|
g++ -std=c++17 -Wall -Wextra -o /tmp/vt1200_board_test "$BOARD" "$TEST"
|
|
/tmp/vt1200_board_test
|
|
exit 0
|
|
fi
|
|
|
|
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"
|
|
ln -sf "$BOARD_HDR" "$BOARD_HDR_DEST"
|
|
ln -sf "$BOARD" "$BOARD_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,src/mame/dec/vt1200_board.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"
|