Files
mtgodot-poc/script/port_gate.sh
T
shenleiandClaude Opus 5 1f1004da79 port 2D step 5a: EterPack/EterPackManager + EterBase file units against the real 40250 packs
- Mirror copies: EterPack (EterPack, EterPackManager, EterPackCursor, CSHybridCrypt policy, Inline.h)
  and EterBase logic units tea/lzo/Timer/Stl/Random, with PORT-tagged width fixes (LONG index
  fields, static_assert(sizeof(TEterPackIndex) == 192), tea_word = Win32 unsigned long).
- TEA pack keys are extracted from the reference EterPack.cpp at configure time into
  build/.../EterPackKeys.generated.h; nothing key-bearing is tracked.
- Platform EterBase: FileBase (stdio, case-insensitive fallback), MappedFile (mmap /
  MapViewOfFile), CRC32, Debug, Utils StringPath/StringLowers.
- Win32Crt: CreateDirectory/DeleteFile/_access/MAKEFOURCC; Win32MinMax.h min/max (force-included
  on MinGW, whose windows.h omits them in C++).
- tests/port_eterpack_test: registers pack/Index like PackInitialize and checks 119
  registrations / 103 packs + root / 54891 entries / 52609 paths / 2282 overrides with
  first-registered-wins, and that exactly the 4 short-layout SECURITY files fail to load.
- 2R count corrected (136 -> 119 registrations, 103 distinct packs + root).

Not runtime-reachable yet (asset_io pack backend is step 5b), so port-map statuses stay TODO.
port_gate: macos/android/ios/windows PASS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-23 00:56:39 +09:00

88 lines
3.5 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 --target port_eterpack_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 --target port_eterpack_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