Files
mtgodot-poc/script/port_gate.sh
T
shenleiandClaude Opus 5 9a8e11f3dd port 2A step 4: platform skeleton + rest of the 2V3 header closure
- Mirror the remaining non-Python 2V3 closure headers (98 more, 173 total): EffectLib,
  EterGrnLib, SpeedTreeLib, SphereLib, PRTerrainLib, EterImageLib, EterBase/Poly, cipher/tea,
  EterLib Grp*/IME/Input/MSWindow/StateManager, GameLib actor/map/race headers, EterPack.
- SDK shims: granny.h, SpeedTreeRT.h, imm.h, Dimm.h (the SDK MIDL header, not mirrored),
  dinput/d3dx8 additions; D3D8 render-state enums, FVF macros and the COM resource hierarchy;
  more Win32 GDI/handle types with layout static_asserts.
- PORT edits for MSVC-permissive code (typename, friend visibility, <algorithm>, pointer→uintptr_t)
  and PRTerrainLib/StdAfx.h dropping the ScriptLib/Python include.
- port_logic links the vendored cryptopp/minilzo.
- extension/src/platform: port_platform target with 103 generated stub files (1917 function
  stubs, 146 static members) from the new platform_stub.py (clang -ast-dump-filter);
  MT_PLATFORM_STUB() marks every unimplemented body. libmtgodot links port_platform and
  port_gate.sh builds it.

Gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 21:46:24 +09:00

88 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Batch 2A gate (docs/PORT-PLAN.md): build port_logic, port_platform + the header self-containment gate per
# platform. A platform whose toolchain is missing prints BLOCKED and never counts as a pass.
#
# script/port_gate.sh [macos|android|ios|windows|linux ...] (default: all)
#
# Build trees go to $MT_PORT_GATE_DIR (default build-port-gate/). Toolchains:
# android ANDROID_NDK_HOME / ANDROID_NDK_ROOT (NDK 27.2)
# ios Xcode with the iphoneos SDK
# windows MT_WIN_CXX (default x86_64-w64-mingw32-g++); MSVC is covered on a Windows host
# linux MT_LINUX_TOOLCHAIN (a CMake toolchain file), or a Linux host
set -uo pipefail
cd "$(dirname "$0")/.."
OUT="${MT_PORT_GATE_DIR:-build-port-gate}"
PLATFORMS=("$@")
[ ${#PLATFORMS[@]} -eq 0 ] && PLATFORMS=(macos android ios windows linux)
PORT_ONLY=(-DMTGODOT_BUILD_EXTENSION=OFF -DMTGODOT_BUILD_PORT=ON)
declare -a RESULTS=()
run() { # name, build dir, configure args...
local name="$1" dir="$2"; shift 2
if cmake -S . -B "$dir" "$@" >"$dir.log" 2>&1 \
&& cmake --build "$dir" --target port_platform ${BUILD_EXTRA[@]+"${BUILD_EXTRA[@]}"} >>"$dir.log" 2>&1; then
RESULTS+=("$name PASS")
else
RESULTS+=("$name FAIL (see $dir.log)")
fi
}
mkdir -p "$OUT"
for p in "${PLATFORMS[@]}"; do
BUILD_EXTRA=()
case "$p" in
macos)
BUILD_EXTRA=(--target port_common_test)
run macos "$OUT/macos" "${PORT_ONLY[@]}" -DBUILD_TESTING=ON
last=$((${#RESULTS[@]} - 1))
if [[ "${RESULTS[$last]}" == *PASS ]] && ! ctest --test-dir "$OUT/macos" -R '^port\.' --output-on-failure >>"$OUT/macos.log" 2>&1; then
RESULTS[$last]="macos FAIL (port tests, see $OUT/macos.log)"
fi
;;
android)
NDK="${ANDROID_NDK_ROOT:-${ANDROID_NDK_HOME:-}}"
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}}"
if [ -z "$NDK" ] && [ -d "$SDK/ndk" ]; then
NDK="$SDK/ndk/$(ls -1 "$SDK/ndk" | sort -V | tail -1)"
fi
if [ -z "$NDK" ] || [ ! -f "$NDK/build/cmake/android.toolchain.cmake" ]; then
RESULTS+=("android BLOCKED (no NDK)"); continue
fi
run android "$OUT/android" "${PORT_ONLY[@]}" -DBUILD_TESTING=OFF \
-DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-24
;;
ios)
if ! xcrun --sdk iphoneos --show-sdk-path >/dev/null 2>&1; then
RESULTS+=("ios BLOCKED (no iphoneos SDK)"); continue
fi
BUILD_EXTRA=(-- -sdk iphoneos CODE_SIGNING_ALLOWED=NO)
run ios "$OUT/ios" "${PORT_ONLY[@]}" -DBUILD_TESTING=OFF -G Xcode -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
;;
windows)
CXX_W="${MT_WIN_CXX:-x86_64-w64-mingw32-g++}"
if [[ "$(uname -s)" != MINGW* ]] && ! command -v "$CXX_W" >/dev/null; then
RESULTS+=("windows BLOCKED (no $CXX_W)"); continue
fi
run windows "$OUT/windows" "${PORT_ONLY[@]}" -DBUILD_TESTING=OFF -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER="${CXX_W%g++}gcc" -DCMAKE_CXX_COMPILER="$CXX_W"
;;
linux)
if [ "$(uname -s)" = Linux ]; then
BUILD_EXTRA=(--target port_common_test)
run linux "$OUT/linux" "${PORT_ONLY[@]}" -DBUILD_TESTING=ON
elif [ -n "${MT_LINUX_TOOLCHAIN:-}" ]; then
run linux "$OUT/linux" "${PORT_ONLY[@]}" -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE="$MT_LINUX_TOOLCHAIN"
else
RESULTS+=("linux BLOCKED (not a Linux host and no MT_LINUX_TOOLCHAIN)")
fi
;;
*) RESULTS+=("$p UNKNOWN") ;;
esac
done
printf '%s\n' "${RESULTS[@]}"
! printf '%s\n' "${RESULTS[@]}" | grep -q FAIL