#!/bin/bash set -e # 1. Build native tools (asset_packer) echo "Building native tools..." cmake -S . -B build_native -DDEMO_BUILD_TOOLS=OFF -DDEMO_BUILD_TESTS=OFF cmake --build build_native --target asset_packer seq_compiler -j8 ASSET_PACKER_PATH=$(pwd)/build_native/asset_packer SEQ_COMPILER_PATH=$(pwd)/build_native/seq_compiler echo "Cross-compiling for Windows..." cmake -S . -B build_win \ -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-MinGW-w64.cmake \ -DDEMO_CROSS_COMPILE_WIN32=ON \ -DDEMO_STRIP_ALL=ON \ -DASSET_PACKER_PATH=$ASSET_PACKER_PATH \ -DSEQ_COMPILER_PATH=$SEQ_COMPILER_PATH cmake --build build_win -j8 # 3. Copy runtime DLLs to build_win so we can run it cp third_party/windows/lib/wgpu_native.dll build_win/ # Copy MinGW DLLs (pthread, etc.) echo "Copying MinGW DLLs..." MINGW_BIN=$(dirname $(find /opt/homebrew -name "libwinpthread-1.dll" | grep x86_64 | head -n 1)) if [ -d "$MINGW_BIN" ]; then cp "$MINGW_BIN/libwinpthread-1.dll" build_win/ cp "$MINGW_BIN/libgcc_s_seh-1.dll" build_win/ 2>/dev/null || true cp "$MINGW_BIN/libstdc++-6.dll" build_win/ 2>/dev/null || true else echo "Warning: Could not find MinGW DLLs. You might need them to run the exe." fi # 4. Crunch the binary ./scripts/crunch_win.sh echo "Build complete. Output: build_win/demo64k.exe"