#!/bin/bash # SPDX-License-Identifier: GPL-3.0-or-later # Optional private-ROM/game compatibility check; never changes input media. set -euo pipefail if [[ $# -lt 4 || $# -gt 5 ]]; then echo 'Usage: run-sdc-validation.sh SYSTEM_ROM SDC_ROM GAME_FOLDER OUTPUT_FOLDER [6809|6309|starter]' >&2 exit 2 fi repo_dir="$(cd "$(dirname "$0")/../.." && pwd)" build_dir="${VCC_SDC_BUILD_DIR:-${TMPDIR:-/tmp}/vcc-sdc-validation-build}" check_arch="${VCC_CHECK_ARCH:-$(uname -m)}" case "$check_arch" in arm64|x86_64) ;; *) echo 'VCC_CHECK_ARCH must be arm64 or x86_64' >&2; exit 2 ;; esac # Keep input/output references stable when changing to the repository. args=() for value in "$1" "$2" "$3" "$4"; do if [[ "$value" != /* ]]; then value="$PWD/$value"; fi args+=("$value") done if [[ $# == 5 ]]; then case "$5" in 6809|6309|starter) args+=("$5");; *) echo 'Mode must be 6809, 6309 or starter' >&2; exit 2;; esac fi mkdir -p "$build_dir" build_dir="$(cd "$build_dir" && pwd)" cd "$repo_dir" xcodebuild -project platforms/macos/VCC.xcodeproj -scheme VCCCoreChecks \ -configuration Release -derivedDataPath "$build_dir" \ SDK_STAT_CACHE_ENABLE=NO build > "$build_dir/build.log" 2>&1 || { tail -60 "$build_dir/build.log" >&2; exit 1; } xcrun clang++ -std=c++17 -O2 -arch "$check_arch" -mmacosx-version-min=14.0 \ -Isrc/core -Isrc -Iplatforms/windows/libcommon tests/macos/sdc-validation.cpp \ "$build_dir/Build/Products/Release/libVCCCore.a" \ -o "$build_dir/sdc-validation" exec arch "-$check_arch" "$build_dir/sdc-validation" "${args[@]}"