Porting Principia

This page contains notes for developers who would be interested in porting Principia to a new platform. It is far from comprehensive but should give some information for prospective porters and reduce the amount of trial and error necessary.

Dependencies

The Principia codebase as a whole is written in a mix of C and C++. The C code requires a compiler that supports C99 and the C++ code requires a compiler that supports C++14. Any relatively recent version of GCC or Clang should be fine.

Principia only supports little endian architecture targets. Big endian is completely untested and it is very likely that some parts of the code will break on a big endian target. Upstream contributions to improve big endian compatibility are appreciated.

Principia uses SDL3 which takes care of most platform-dependent behaviour. If the platform you are porting to already has support in SDL3 then things should go very smoothly. If not then you may consider using or contributing to an SDL port for your platform, if it is not available in mainline SDL it may be unofficially maintained in a fork somewhere.

The current graphics code for Principia needs OpenGL 2.1 or higher, and we use a programmable graphics pipeline with shaders rather than OpenGL's old fixed pipeline. OpenGL ES 2.0 is also available which is used for Android and other things such as the web and mobile Linux. The game can switch between the two at runtime with use_gles, but also see SHOULD_USE_GLES in the build system which determines which should be the default at compile-time. If your platform does not provide OpenGL you may want to use Zink or ANGLE for translating to other graphics APIs, or Mesa's llvmpipe software renderer in a pinch.

Principia depends on the following libraries for core functionality (in addition to the abovementioned SDL), and needs to be provided but should be portable enough to work on your platform:

In addition to this Principia has the following technically optional dependencies:

We also have some vendored libraries in the source tree that may be worth listing:

Building Principia for a new platform

Once you have all the dependencies resolved, you may start to try building Principia. If you are using a cross-compiler toolchain, it will typically provide a CMake toolchain file you can pass when configuring.

When needing to make codepaths specific to your new platform, you should typically use the define that SDL provides. See SDL_platform_defines.h in the SDL3 headers.

Some notes that may be useful:

Contributing

We welcome all patches upstream to improve the portability and platform support of Principia! We would prefer patches for new platforms to be as clean as possible, but some ifdefs to stub out or provide alternate functionality are fine given that they are not too invasive to the primary platforms that we support.