The config pipeline
A game built for 17 targets goes through four build systems: CMake,
Gradle, Xcode and GitHub Actions. Each of them needs the same handful of facts — what the game is
called, its identifiers on the stores, its window, which targets to build — and left to themselves
they would each keep their own copy and drift. So there is one file you write,
raylib_multiplatform.toml, one program that reads it, tools/configure.py,
and everything the build systems read is generated from the two.
One file#
The .toml is grouped by what each section is about:
[project]
name = "space_rocks"
[window]
title = "Space Rocks"
width = 960
height = 540
[app]
max_delta = 0.05
[targets]
enabled = ["desktop", "web", "android"]A key you leave out takes its default, so a game's file holds only what it changes.
Configuration lists every key with its default and
what it is for — and that page is itself generated from configure.py --print-schema
and the comments of the framework's own .toml, so it cannot describe a key that does
not exist.
Refused before anything compiles#
Before
configure.py writes a single file it checks every value: its type, its range, the
values it may take, and the combinations that cannot work together. A mistake stops there, in
well under a second, with the line of the file it is on, what is wrong, and what to write
instead. The build never sees it.
[project]
name = "my game" raylib_multiplatform.toml:2: name = "my game"
^^^^^^^^^^^^^^^^
configure: error: [project] name = 'my game' is not usable as a filename.
Use letters, digits, '_' and '-', starting with a letter. It becomes the executable name on five operating systems.The wrong type is caught the same way. An array where a number goes would otherwise reach a generator as something it cannot format:
[window]
width = [800] raylib_multiplatform.toml:2: width = [800]
^^^^^^^^^^^^^
configure: error: [window] width = [800] must be an integer between 16 and 16384.Every key is held
to that, not only the ones somebody remembered to check: a test walks every key the defaults
have, gives it every type it is not, and expects a refusal that names its line. The empty value
is refused the same way, except where empty is a value with a meaning — [ui] font = ""
is raylib's built-in font, [linux] glibc = "" builds against the machine's own C
library — and a test names each of those exceptions too.
[window]
title = "" raylib_multiplatform.toml:2: title = ""
^^^^^^^^^^
configure: error: [window] title is empty. It is the title bar on desktop and the name under the app's icon on Android and iOS -- give the game a name.And so are two values that are each fine on their own and wrong together. A frame cap of 15
frames per second makes every frame longer than the default
[app] max_delta, so the game
would be handed less time than really passed, every frame, forever:
[window]
fps = 15 raylib_multiplatform.toml:2: fps = 15
^^^^^^^^
configure: error: [window] fps = 15 makes every frame 0.06667 s long, but [app]
max_delta = 0.05 hands the game at most that much per frame, so the
game would run at 75% speed forever. Raise fps to 20 or
more, raise max_delta to 0.06667 or more, or set max_delta = 0.The rule behind it is strict on purpose: a configuration mistake that reaches the compiler is a
bug in configure.py, not in the configuration. A mistake found twenty minutes into a
CI run on somebody else's machine costs twenty minutes and an explanation; the same mistake found
here costs a second and points at the line. And a refusal is only kept honest by a test that feeds
it the value it refuses: those live in tests/configure_test.py.
One
more check is kept for releases. When a game is released — by
rmp deploy, or by a version tag pushed
to its repository — configure.py also refuses an Android application id or an iOS
bundle id that is still a placeholder under com.example., the kind
rmp new writes, for a platform the game is built for. A Google Play application id
can never be changed once it is published, so this is the one mistake worth stopping a release
for, and the one not worth stopping a debug build for.
Who runs it#
You
never have to. CMake runs it at the start of every configure, before project() —
the project's name comes out of it — and configures again by itself when the .toml
changes. Every rmp command that builds goes through CMake, so
rmp run after an edit to the
.toml picks the edit up.
Gradle and XcodeGen
never run the top-level CMake that calls it. Gradle builds the native code through a
CMakeLists.txt of its own, which reads what configure.py already wrote,
and it reads its own settings from raymob/generated.properties before any of that
starts. So the CI jobs for Android and iOS run python3 tools/configure.py themselves
before they build. The BSD jobs build inside
virtual machines that have no Python at all; there CI generates everything on the Linux runner
first and the files travel into the machine with the rest of the checkout. A CMake configure that
finds no Python 3.11 or newer falls back to what was generated last time, and says loudly that
edits to the .toml will not be seen.
A run writes a file only when its content changed, so configuring again after touching nothing rebuilds nothing.
What it writes#
| File | Holds | Read by |
|---|---|---|
cmake/generated/project.cmake | the project name, the pack password, the web memory settings, the windowing backend per platform | the top of CMakeLists.txt, before project() |
cmake/generated/raylib_flags.cmake | raylib's complete set of feature flags, with the modules [raylib] disabled_modules removed | CMake, and the Android build's own CMake |
cmake/generated/dev_toolchain.cmake, dev_linker.cmake and dev_sanitize.cmake | the compiler, the linker and the sanitizers from [dev] | debug builds only: a release never reads them |
cmake/generated/rmp_web_name.js | the name of the game's save database in the browser | the web build |
include/rmp/generated/config.h | every value a game can read in C or C++, as RMP_ macros | your code, through every public header — below |
raymob/generated.properties | the Android application id, minimum SDK, version, the OpenGL ES version to compile for, permissions, and whether AdMob is on and its ids | Gradle |
raymob/app/generated/AndroidManifest.xml | the manifest, with each permission and feature element kept or dropped | Gradle |
ios/project.yml | the iOS app: bundle id, deployment target, orientations, header paths, the compiler flag that refuses out-of-order initialisers, the licence notice | XcodeGen, which makes the Xcode project |
| the icons | Android's launcher icons, the iOS icon set and the Windows .ico, from [icon] source | each platform's build |
LICENSES.txt in cmake/generated/ for the desktops, and one each for the web, Android and iOS | the third-party notices that ship with the game | the release packages — see Licences |
The manifest is generated rather than templated through Gradle for a reason worth knowing: Gradle's placeholders can change the value of an attribute but cannot remove an element, and a permission is exactly an element you either ask for or do not.
The version is not in the .toml. A release takes it from its git tag —
v1.2.3 is version 1.2.3, and Android's version code is computed from it so it always
goes up — and every other build is 0.0.0-dev.
A
tag that starts with v is the release path, so one that does not read as
vMAJOR.MINOR.PATCH, in ASCII digits, is refused rather than published under a
made-up number. A pre-release or build suffix after it is accepted — v1.2.3-rc1,
v1.2.3+build — and shares the version code of v1.2.3. Minor and patch
each have to stay below 1000 for the code to keep going up.
A number
with a leading zero is refused too — v01.2.3 would be a second release name
with the version code of v1.2.3 — and so is
v0.0.0, whose code would be 0: the first release is v0.0.1. A tag
that does not start with v is not a release: it builds as 0.0.0-dev,
with a warning.
The generated header#
The values a game can use at run time — the window's size and title, the input dead zone, the
volumes the audio buses start at, the save settings, [app] max_delta — are written to
include/rmp/generated/config.h as macros. Every public header of the framework
includes it through rmp/config.h, so whichever header you were including anyway, they
are there:
const float centre_x = RMP_WINDOW_WIDTH / 2.0f;
const float centre_y = RMP_WINDOW_HEIGHT / 2.0f;
TraceLog(LOG_INFO, "%s starts at %.0f, %.0f", RMP_WINDOW_TITLE, centre_x, centre_y);They
are macros and not C++ constants because a game in plain C uses them too, and C has no namespaces
to put a constant in. Each one is named after its key: [window] width is
RMP_WINDOW_WIDTH.
Macros lists all of them, read from
configure.py --print-defines.
The values that only a build system needs — the store identifiers, the targets, the backend — never reach the header. A game cannot read what it has no use for, and a value read in two places is a value that can disagree with itself.
Questions it answers#
The same program answers the questions the CI and the tools ask, so none of them parses the
.toml on its own:
--checkvalidates and writes nothing.--print-targets,--print-familiesand--print-matrixtell the CI which targets are enabled and which jobs to run for them; a family with no enabled target is skipped whole.--onlynarrows what they print to the groups and targets it is given, separated by commas, and never adds one the.tomlswitched off: it is what a run started by hand with-f targets=hands it.--print-schemaand--print-definesdescribe every key and every generated macro, which is where this site's Configuration and Macros pages come from.--configchecks another file instead of the project's: every.tomlblock on this site goes through it, and a block that shows a refusal prints the messageconfigure.pyreally gives, as on this page.
Nothing generated is committed#
Every file in the table is ignored by git, and the framework's own CI fails if one is ever tracked. Generated files that are committed go stale the first time somebody edits the source and forgets to regenerate; files that are written on every configure cannot.
rmp clean deletes them with the build
directory, and the next configure writes them again — all but the Android launcher icons and the
iOS icon set, which it leaves in place, because making the Android ones again needs Pillow. The Windows
.ico lives in cmake/generated/ and goes with the rest.