Out-of-source build of Godot

Hi, I have a question - is it possible to build Godot out-of-source? Basing on my limited understanding of SCons, I’ve tried creating a build directory and running

scons platform=macos arch=arm64 dev_build=yes -f ../SConstruct

but it resulted in an error:

scons: Reading SConscript files ...
FileNotFoundError: [Errno 2] No such file or directory: '/Users/andrew/Dev/godot/build/gles3_builders.py':
  File "/Users/andrew/Dev/godot/SConstruct", line 45:
    _helper_module("gles3_builders", "gles3_builders.py")
  File "/Users/andrew/Dev/godot/SConstruct", line 26:
  File "<frozen importlib._bootstrap_external>", line 991:

  File "<frozen importlib._bootstrap_external>", line 1128:

  File "<frozen importlib._bootstrap_external>", line 1186:

So could you let me know if it’s possible to build out-of-source, please, and if not, what are typical workflows for the developers (like, cleaning the default in-source build every time, or having multiple repo instances, etc.)?

Thank you!

To my knowledge, SCons does not have “real” support for out-of-tree builds. Therefore, Godot currently doesn’t support them either.

What I do is:

  • Use a single repository clone for master and other 4.x-derived branches.
  • Use another repository clone in a different path for Godot 3.x and derived branches. If you don’t intend on backporting changes to 3.x, you won’t need this.
  • Install ccache and alias it to gcc/g++ to make SCons cache misses due to branch switches take less time.

It might be possible to tweak build scripts so that the builders file paths are always relative to the repository root (location of the SConstruct file), but this may not suffice to create a successful build.

Got it, thanks a lot for your help!