summaryrefslogtreecommitdiff
path: root/scripts/build_win.sh
blob: c062929500b81bca839de4729ba102606826e2f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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"