Skip to content

Instantly share code, notes, and snippets.

@Calinou
Last active July 8, 2023 23:22
Show Gist options
  • Save Calinou/f61ec28ffc1782dd6eb2dc1e3427c907 to your computer and use it in GitHub Desktop.
Save Calinou/f61ec28ffc1782dd6eb2dc1e3427c907 to your computer and use it in GitHub Desktop.
Compile Godot for HTML5 easily (from Windows)
:: This script must be run from a Windows system with the Emscripten SDK
:: installed and configured. 7-Zip and MinGW also need to be installed.
:: Place this script at the root of your Godot Git clone.
:: CC0 1.0 Universal
set threads=%NUMBER_OF_PROCESSORS%
:: Set MinGW path
set PATH=%PROGRAMFILES%\mingw-w64\x86_64-6.2.0-posix-seh-rt_v5-rev0\mingw64\bin\;%PATH%
:: Set Emscripten environment variables
set previous_cd=%cd%
cd "C:\Apps\Emscripten"
call "emsdk_env.bat"
cd %previous_cd%
:: This is required so that SCons sees HTML5 as a valid build option
set EMSCRIPTEN_ROOT="C:\Apps\Emscripten\emscripten\1.35.0"
:: Build Godot for HTML5 in debug and release mode
call "C:\Python27\Scripts\scons.bat" p=javascript -j%threads% verbose=no tools=no target=release
call "C:\Python27\Scripts\scons.bat" p=javascript -j%threads% verbose=no tools=no target=release_debug
cd bin
:: Copy files around to prepare the export templates
:: TODO: Check if folder exists before attempting to create it
mkdir javascript_debug
mkdir javascript_release
copy godot.javascript.opt.debug.exe.js javascript_debug\godot.js
copy godot.javascript.opt.debug.exe.html.mem javascript_debug\godot.mem
copy ..\tools\dist\html_fs\* javascript_debug
copy godot.javascript.opt.exe.js javascript_release\godot.js
copy godot.javascript.opt.exe.html.mem javascript_release\godot.mem
copy ..\tools\dist\html_fs\* javascript_release
:: Compress into .zip to make the export template
cd javascript_debug
call "%PROGRAMFILES%\7-Zip\7z.exe" a ..\javascript_debug.zip *
cd ..\javascript_release
call "%PROGRAMFILES%\7-Zip\7z.exe" a ..\javascript_release.zip *
:: Copy to Godot's templates folder
cd ..
copy javascript_debug.zip %APPDATA%\Godot\templates
copy javascript_release.zip %APPDATA%\Godot\templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment