Skip to content

Porting Godot 4: Core

c08oprkiua edited this page Jun 11, 2024 · 1 revision

Overview

When porting Godot 4 to a platform, there are several specific things to note about Godot is set up:

  • The file platform_config.h for your platform gets included very early in compilation (it's included in core/typedefs.h, which is one of the first things compiled in the core folder, the first thing to be compiled), meaning you can patch basically any part of the engine where patching may be needed without actually editing engine code to do so. Keep in mind that, since it is included in typedefs.h, due to how preprocessor parsing works, this means that the actual code (particularly macros) present in typedefs.h will not be "visible" to platform_config.h, so you may need to copy those into your platform_config.h file or any subsequent files included therein.
  • There are several folders in your platform folder that have special exemptions in their use; Unlike most platform code, which exists to sit between the engine and the platform, some folders in all platform folders get compiled regardless on the target platform being compiled, because they contain special code about that platform that needs to be compiled regardless of target:
    • platform/{your platform}/export contains code for your platform's Export Plugin. This is covered more on the dedicated page about export code, but to explain briefly, this is code for making your platform show up in the in-engine Export options.
    • platform/{your platform}/api contains code for platform specific APIs, if you would like to have those to access special features for your platform (for example, Xbox Live features, if you were to make an Xbox One/Series port, or amiibo functionality, for a Nintendo Switch port).

What Must Be Implemented

  • platform_config.h in the base of your platform's code folder.
  • It seems that Godot expects some sort of allocation header, eg. <alloca.h>, to be included in platform_config.h
  • Compile-able code in export and api, if you have code in those folders.

What Is Optional

  • api itself is optional, since not all platforms need it.
  • export may be optional (citation needed), but without it your platform will not be visible from the editor.