Few days ago, I’ve decided to get out of my comfort zone and have some fun with new game engine – just to find some quick tool for game jams. After some research, I’ve found Godot. Why is it so interesting? It gives you simple scripting language with graphical editor. But, if you need to extend base features you can compile it from C++ sources.

Of course, because of my previous habits, I’ve decided to prepare Visual Studio solution :)
godot_vs
To sum up: This would be quick tutorial about how to configure Visual Studio to be able to develop C++ sources of Godot game engine.

Assumptions

  1. We want VS to start build, rebuild and clean operations.
  2. We need all VS goodness: IntelliSense, navigate through files, see build errors and debug.
  3. We want to compile with all cpu cores.

1) Create solution

First of all you have to create VS solution and project files. There are at least 3 ways to do this:

  1. If you have VS PRO, guess what ? You can use wizard… Go to: File -> New… -> Project From Existing Code… Enter path to godot main directory. Enter project name and finish.
  2. You can create empty C++ project in Godot main directory, switch to “Show All Files” in solution explorer and use “Include In Project” command for each source file.
  3. Just use CMake.

Please note that you don’t have to add all code files. Include only those, you want to edit. In this case, VS is only a text editor. Build would be controlled by SCons, this tool will scan each directory independently of what you have on a list in VS.

2) Edit project properties

Now we’ll instruct NMake to fire external scripts. Btw. UE4 does the same trick :)
Please navigate to properties window of your project, and configure as follows:

  1. Build Command Line
    $(ProjectDir)build.bat "$(VCInstallDir)vcvarsall.bat" $(NUMBER_OF_PROCESSORS)
  2. Rebuild All Command Line
    $(ProjectDir)rebuild.bat "$(VCInstallDir)vcvarsall.bat" $(NUMBER_OF_PROCESSORS)
  3. Clean Command Line
    $(ProjectDir)clean.bat "$(VCInstallDir)vcvarsall.bat"
  4. Output
    $(ProjectDir)bin\godot.windows.tools.exe

After that: build, rebuild and clean actions will start external batch scripts.

3) Create scripts

The most important part of this chain is to execute SCons. Just create these 3 files in project directory.

3.1) build.bat

@echo off
echo GODOT Build
rem Create variables
set vc_path=%1
set jobs=%2
rem Print variables
echo Working directory: %cd%
echo VC path: %vc_path%
echo Jobs: %jobs%
rem Call scons
call %vc_path% &&  scons platform=windows --jobs=%jobs%

3.2) clean.bat

@echo off
echo GODOT Clean
rem Create variables
set vc_path=%1
rem Print variables
echo Working directory: %cd%
echo VC path: %vc_path%
rem Call scons
call %vc_path% &&  scons platform=windows --clean

3.3) rebuild.bat

@echo off
echo GODOT Rebuild
rem Call scons
call clean.bat %1
call build.bat %1 %2

More informations can be found here.
Don’t forget to edit .gitignore!

Effects ?

IntelliSense:
intellisense
Menu:
menu
Debug:
debug
Build:
build2
build
Error:
error

Have fun! :)