#!/bin/sh # SPDX-License-Identifier: GPL-3.0-or-later # Fetch YM2203-LLE at its pin into upstream/ (git-ignored) and build the SSG harness into # build/ssg_ref (git-ignored), with the consumer's flags (gcc -O2 -w; the warnings would quote # the model's source). Writes build/build-info.json for the manifest. # # ./build.sh fetch what is missing, build ssg_ref # CC=clang ./build.sh another compiler (CFLAGS overrides the flags) # # No patches: the harness calls what the model's header declares. Never deletes anything: a # checkout at another commit with local changes stops the script. set -eu HERE=$(cd "$(dirname "$0")" && pwd) UP=$HERE/upstream/YM2203-LLE OUT=$HERE/build URL=https://github.com/nukeykt/YM2203-LLE PIN=817387fd89affd0db5331034d6ae04d919e25a5e CC=${CC:-gcc} CFLAGS=${CFLAGS:--O2 -w} mkdir -p "$HERE/upstream" "$OUT" if [ ! -d "$UP/.git" ]; then git clone --quiet "$URL" "$UP" fi if [ "$(git -C "$UP" rev-parse HEAD)" != "$PIN" ]; then if [ -n "$(git -C "$UP" status --porcelain)" ]; then echo "build.sh: $UP has local changes and is not at $PIN; move it aside first" >&2 exit 1 fi git -C "$UP" fetch --quiet origin git -C "$UP" -c advice.detachedHead=false checkout --quiet "$PIN" fi if [ -n "$(git -C "$UP" status --porcelain)" ]; then echo "build.sh: $UP has local changes; move it aside first" >&2 exit 1 fi $CC --version | head -n 1 $CC $CFLAGS -I "$UP" -o "$OUT/ssg_ref" "$HERE/ssg_ref.c" "$UP/fmopn.c" echo "built $OUT/ssg_ref (YM2203-LLE @ ${PIN%"${PIN#???????}"})" printf '{"compiler": "%s", "cflags": "%s", "built": "%s", "upstream": "%s", "patches": []}\n' \ "$($CC --version | head -n 1)" "$CFLAGS" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ "$(git -C "$UP" rev-parse HEAD)" > "$OUT/build-info.json"