Skip to content

Instantly share code, notes, and snippets.

@zorgsoft
Forked from Calinou/build_windows.bat
Last active February 9, 2018 14:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorgsoft/eeaa0899790b18cb0b9e4ab05929351e to your computer and use it in GitHub Desktop.
Save zorgsoft/eeaa0899790b18cb0b9e4ab05929351e to your computer and use it in GitHub Desktop.
Compile Godot 2.x for Windows easily (with a script encryption key if necessary)
:: This script must be run from a Windows machine with
:: Visual Studio 2017, Python 2.7 and SCons installed at their
:: default locations. 7-Zip also needs to be installed (to compress editor binaries).
:: UPX: https://upx.github.io/
:: NOTE: You need Pywin32 to be installed to use multi-threaded compilation.
:: You may need to set "threads" to 1 for the first build, even if you have it installed.
:: Place this script at the root of your Godot Git clone.
:: CC0 1.0 Universal
:: Key for encrypt gdscript files while export
:: Generate key https://www.grc.com/passwords.htm
:: set SCRIPT_AES256_ENCRYPTION_KEY=INSERT_YOU_KEY_64_RANDOM_HEXADECIMAL_CHARACTERS_AND_UNCOMMENT
:: set threads=%NUMBER_OF_PROCESSORS%
set threads=1
:: Build 64-bit Godot
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=yes target=release_debug
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=no target=release
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=no target=release_debug
:: Build 32-bit Godot
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=yes target=release_debug
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=no target=release
call "E:\Python27\Scripts\scons.bat" p=windows -j%threads% verbose=no tools=no target=release_debug
:: Compress binaries and move to templates directory
cd bin\
mkdir templates
call E:\upx\upx.exe -k godot.windows.opt.debug.64.exe
call E:\upx\upx.exe -k godot.windows.opt.64.exe
call E:\upx\upx.exe -k godot.windows.opt.debug.32.exe
call E:\upx\upx.exe -k godot.windows.opt.32.exe
move /Y godot.windows.opt.debug.64.exe templates\windows_64_debug.exe
move /Y godot.windows.opt.64.exe templates\windows_64_release.exe
move /Y godot.windows.opt.debug.32.exe templates\windows_32_debug.exe
move /Y godot.windows.opt.32.exe templates\windows_32_release.exe
:: Compress editor binaries using upx and 7zip
call E:\upx\upx.exe -k godot.windows.opt.tools.64.exe
call E:\upx\upx.exe -k godot.windows.opt.tools.32.exe
rename godot.windows.opt.tools.64.exe Godot_v2.1.4-stable_win64.exe
rename godot.windows.opt.tools.32.exe Godot_v2.1.4-stable_win32.exe
call "%PROGRAMFILES%\7-Zip\7z.exe" a Godot_v2.1.4-stable_win64.zip Godot_v2.1.4-stable_win64.exe
call "%PROGRAMFILES%\7-Zip\7z.exe" a Godot_v2.1.4-stable_win32.zip Godot_v2.1.4-stable_win32.exe
:: Move editor archives and .exe in a separate folder with a cleaner name
mkdir editor
move /Y Godot_v2.1.4-stable_win64.exe editor
move /Y Godot_v2.1.4-stable_win32.exe editor
move /Y Godot_v2.1.4-stable_win64.zip editor
move /Y Godot_v2.1.4-stable_win32.zip editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment