45 lines
2.2 KiB
Batchfile
45 lines
2.2 KiB
Batchfile
|
|
@echo off
|
||
|
|
REM Build the Web (WASM) target. Requires Emscripten 3.1+ and Ninja on PATH.
|
||
|
|
|
||
|
|
setlocal
|
||
|
|
|
||
|
|
if not exist thirdparty\leanclr\CMakeLists.txt (
|
||
|
|
git submodule update --init --recursive
|
||
|
|
)
|
||
|
|
|
||
|
|
findstr /C:"LEANCLR_FATAL_ON_RAISE_NOT_IMPLEMENTED_ERROR 1" thirdparty\leanclr\src\runtime\build_config.h >nul 2>&1
|
||
|
|
if %errorlevel% == 0 (
|
||
|
|
echo [build-web] Re-applying leanclr NotImplemented patch...
|
||
|
|
powershell -Command "(Get-Content thirdparty/leanclr/src/runtime/build_config.h) -replace 'LEANCLR_FATAL_ON_RAISE_NOT_IMPLEMENTED_ERROR 1', 'LEANCLR_FATAL_ON_RAISE_NOT_IMPLEMENTED_ERROR 0' | Set-Content thirdparty/leanclr/src/runtime/build_config.h"
|
||
|
|
)
|
||
|
|
|
||
|
|
REM Find the Emscripten toolchain. Override via EMSDK_TOOLCHAIN if needed.
|
||
|
|
if "%EMSDK_TOOLCHAIN%"=="" (
|
||
|
|
for /f "delims=" %%i in ('where emcc 2^>nul') do set "EMCC_PATH=%%i"
|
||
|
|
if not "%EMCC_PATH%"=="" (
|
||
|
|
REM <emsdk>\upstream\emscripten\emcc -> <emsdk>\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake
|
||
|
|
for %%i in ("%EMCC_PATH%") do set "EMCC_DIR=%%~dpi"
|
||
|
|
set "EMSDK_TOOLCHAIN=%EMCC_DIR%cmake\Modules\Platform\Emscripten.cmake"
|
||
|
|
)
|
||
|
|
)
|
||
|
|
if "%EMSDK_TOOLCHAIN%"=="" (
|
||
|
|
echo [build-web] Emscripten toolchain not found. Set EMSDK_TOOLCHAIN to: 1>&2
|
||
|
|
echo [build-web] ^<emsdk^>\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake 1>&2
|
||
|
|
exit /b 1
|
||
|
|
)
|
||
|
|
echo [build-web] Using toolchain: %EMSDK_TOOLCHAIN%
|
||
|
|
|
||
|
|
cmake -S . -B build-web -G Ninja -DCMAKE_TOOLCHAIN_FILE="%EMSDK_TOOLCHAIN%" -DCMAKE_BUILD_TYPE=Release || exit /b 1
|
||
|
|
python tools\binding_generator\generate_bindings.py --api build-web\_deps\godot-cpp-src\gdextension\extension_api.json
|
||
|
|
if errorlevel 1 (
|
||
|
|
py tools\binding_generator\generate_bindings.py --api build-web\_deps\godot-cpp-src\gdextension\extension_api.json
|
||
|
|
)
|
||
|
|
cmake -S . -B build-web -G Ninja -DCMAKE_TOOLCHAIN_FILE="%EMSDK_TOOLCHAIN%" -DCMAKE_BUILD_TYPE=Release || exit /b 1
|
||
|
|
cmake --build build-web --target leanclr_godot || exit /b 1
|
||
|
|
|
||
|
|
dotnet msbuild managed\GodotSharpCompat\GodotSharpCompat.csproj -p:Configuration=Debug || exit /b 1
|
||
|
|
dotnet msbuild project\Game.csproj -p:Configuration=Debug || exit /b 1
|
||
|
|
|
||
|
|
echo [build-web] Done. Output: project\bin\Release\libleanclr_godot.wasm
|
||
|
|
echo [build-web] Export the project for Web in the Godot editor to run.
|