# Setting up

> What a machine needs to work on the framework: rmp, a clone, the pinned clang-format and clang-tidy, Python with Hypothesis, and the pinned build image CI runs in, with podman or Docker.

Source: https://omardev29.github.io/rmp-docs/framework/contributing/setup.html

Working on the framework needs what making a game needs, plus three things: the exact clang-format and clang-tidy the framework pins, Hypothesis for the Python property tests, and the build image CI runs in. The first two go on your laptop; the image is how your laptop sees what CI sees.

The commands below are for Linux, which is what the image and every Linux job of CI are. On a Mac or on Windows the image is the way to the same results.

## What a laptop needs

- **git**, and **Python 3.11** or newer: `rmp` is written in it.
- **CMake 3.30** or newer, **Ninja**, and a C++20 compiler: GCC or Clang.
- On Linux, the X11 development headers, or on a console with no desktop the DRM/KMS ones. [Install rmp](https://omardev29.github.io/rmp-docs/getting-started/install.html#what-it-needs) says how the installer lists what is missing, with the command for your system.
- **The sanitizer runtimes.** Every debug build of the framework runs under AddressSanitizer and UndefinedBehaviorSanitizer. GCC's come with most distributions; Clang's are compiler-rt, a package of its own. Without them a debug build goes on unsanitized and says so in a CMake warning, which on the framework is a reason to stop, not to read past.
- **clang-format and clang-tidy 22.1.8**, exactly: [below](https://omardev29.github.io/rmp-docs/framework/contributing/setup.html#clang-tools).
- **Hypothesis**, for the Python property tests: [below](https://omardev29.github.io/rmp-docs/framework/contributing/setup.html#clang-tools), in the same place.
- **gh**, GitHub's command line, signed in: `rmp push` asks it whether a CI run is in flight, and every command on [CI](https://omardev29.github.io/rmp-docs/framework/contributing/ci.html) uses it.
- **podman** or **Docker**, for [the image](https://omardev29.github.io/rmp-docs/framework/contributing/setup.html#the-image).

cppcheck is optional on a laptop: `rmp test` skips its stage with a message when it is not installed, and CI, which has it, fails instead of skipping. The same is true of Hypothesis, and of the locales the unit tests build with glibc's `localedef`. A skip is a stage that did not run, so say so when you report what you ran.

## rmp, and a clone to work in

Install `rmp` the way a game maker does, with the one line on [Install rmp](https://omardev29.github.io/rmp-docs/getting-started/install.html). Then clone the framework somewhere of your own to work in:

```shell
git clone https://github.com/omardev29/raylib_multiplatform ~/raylib_multiplatform
cd ~/raylib_multiplatform
rmp help
```

Inside the clone, the `rmp` on your PATH hands every command to the clone's own `tools/rmp.py`, so `rmp test` there is your working copy's `rmp test`, whichever framework the installer put on your PATH. `rmp help` run inside it lists the two commands only the framework has, `rmp lint` and `rmp example`.

Three commands are the exception: `rmp new`, `rmp install` and `rmp update` act on the framework the `rmp` you typed belongs to, wherever you type them. To make a game from your working copy — to try what a change does to a new game — run the clone's own launcher by its path:

```shell
./rmp new ~/games/try_it
```

Keep the clone up to date with git, not with `rmp update`: `rmp update` only moves a clone that sits on `main` with nothing of its own, and refuses one on a branch or with local commits, which is what a working copy is.

```shell
git switch main
git pull --ff-only
```

## clang-format, clang-tidy and Hypothesis

The framework pins clang-format and clang-tidy to 22.1.8 in `thirdparty/FROZEN_VERSIONS.md`. The version matters: a clang-format one minor version away reformats files that were already right, and every diff becomes noise; a clang-tidy of another version reports other things. The build image installs both from PyPI, and a laptop can do the same, in a virtual environment of its own, together with the Hypothesis the image carries:

```shell
python3 -m venv ~/.venvs/rmp-dev
~/.venvs/rmp-dev/bin/pip install clang-format==22.1.8 clang-tidy==22.1.8 hypothesis==6.168.5
export PATH="$HOME/.venvs/rmp-dev/bin:$PATH"
```

Put the `export` line in your shell's startup file so every terminal has it. With that folder first on your PATH, its `python3` is the one the `rmp` launcher finds first, so the Python tests import Hypothesis, and its `clang-format` and `clang-tidy` are the ones `rmp fmt` and `rmp lint` run.

Check it with the configuration stage, which compares the tools on your PATH with the pin:

```shell
rmp test config
```

A clang-format or clang-tidy of another version is a `DRIFT` line naming the version it found, and a failed stage, before it has reformatted anything.

## The build image

Every Linux job of CI runs inside one image, `ghcr.io/omardev29/raylib-build`, pinned by its digest in `thirdparty/FROZEN_VERSIONS.md`. It carries every compiler and tool those jobs use, so a job downloads nothing, and it is the one place where a few checks are exact: the e2e shots compared pixel for pixel, the coverage floors, the cost of each header, the versions against the image's own manifest, and mutation testing, whose tools only it has. Running a check in it on your machine gives the answer CI will give.

The image is public. Read its digest from the file, so it is always the pinned one, and pull it:

```shell
IMAGE=ghcr.io/omardev29/raylib-build@$(sed -nE 's/^build_image_digest +//p' thirdparty/FROZEN_VERSIONS.md)
podman pull "$IMAGE"
```

### A checkout of its own

Run the image on a second checkout, not on the one you build in. CMake remembers the folder a build directory was configured in: inside the container your checkout is `/work`, and a `build/debug` configured on your laptop at another path is refused there, and the other way round. A git worktree is a second checkout of the same repository, sharing its branches:

```shell
git worktree add --detach ../raylib_multiplatform-image main
cd ../raylib_multiplatform-image
```

Before each run, move it to the commit you want checked, detached, because a branch can be checked out in one worktree at a time and yours is in the first:

```shell
git switch --detach my-branch
```

A worktree keeps its git data in the first checkout's `.git`, so the container needs that folder too, read-only, at the same path:

```shell
IMAGE=ghcr.io/omardev29/raylib-build@$(sed -nE 's/^build_image_digest +//p' thirdparty/FROZEN_VERSIONS.md)
repo_git=$(git rev-parse --path-format=absolute --git-common-dir)
podman run --rm --init --network=none \
    -v "$PWD":/work -v "$repo_git":"$repo_git":ro -w /work "$IMAGE" \
    bash -c 'python3 tools/configure.py >/dev/null && xvfb-run -a ./rmp test'
```

Every option there has a reason:

- `--init` puts an init process first in the container. Without it, `bash -c '… && xvfb-run …'` hands its last command the place of process 1, and `xvfb-run` there waits for a signal that never comes: the run hangs instead of failing, and a timeout cannot end it. Any container that starts a game needs it.
- `--network=none` proves the run downloads nothing, which is the rule for every Linux job.
- `xvfb-run -a` gives the stages that open a window — the UI on a real GPU, and the smoke boot — a display, which the image does not have.
- Rootless podman maps your user to root inside the container, so what it writes in the checkout is yours. On a system with SELinux, add `:Z` to the first `-v`.

A plain clone instead of a worktree works the same, without the second `-v`.

With Docker, `tools/dev_shell.sh` runs a command in the pinned image, read from the same file, as your user rather than as root, with an init as the container's first process, and with no command it opens a shell there. With podman, use the command above.

```shell
tools/dev_shell.sh bash tools/versions_check.sh
tools/dev_shell.sh
```

## What only the image has

Most of the ladder runs on a laptop. What needs the image, and what each one does outside it:

| Check | In the image | Elsewhere |
|---|---|---|
| The e2e shots, `rmp test examples` | compared with the goldens exactly | played, and the differences reported, not failed |
| Recording the e2e goldens, `rmp test e2e-update` | records them | refused |
| Coverage, `rmp test coverage` | held to `tools/coverage_floor.txt` and `tools/untested_api.txt` | measured and printed, with a Clang that has compiler-rt and the llvm tools of its own release; without them it fails rather than measure nothing |
| The cost of each public header, `rmp test cost` | held to `tools/header_budget.txt` | a header with no line, or a line for a header that is gone, fails; the sizes are only reported |
| Mutation testing, `rmp test mutation` | Mull and mutmut, against every floor | fails: Mull, built for the image's LLVM, and mutmut are only there |
| Fuzzing, `rmp test fuzz` | libFuzzer | libFuzzer where Clang has compiler-rt; otherwise every input replayed, without fuzzing |
| The pinned versions, `rmp test config` | also against the image's own manifest | against the files that use them |

The image's compilers are not your laptop's either, and two versions of GCC do not refuse the same code. A change to C++ that has only been built on the laptop has not been built where CI builds it.

Next: [the repository](https://omardev29.github.io/rmp-docs/framework/contributing/repository.html).
