# Building from source

> What you need to build Evil Engine on Linux, the just recipes that build the Godot fork, the libraries and the game, and how to run the tests.

Part of [Source](/docs/source) in the Evil Engine docs.

Evil Engine is a C# game on its own fork of Godot 4.8, built in double precision with .NET. Building it means building the fork's editor first, then the C# solution. The repository's `justfile` holds every step, and bare `just` lists the recipes.

The engine recipes run on Linux only.

## What you need

- `git`, with the `Engine/` submodule checked out: `git submodule update --init`. It's the fork, on its `evil/master` branch.
- [just](https://github.com/casey/just).
- [uv](https://docs.astral.sh/uv/). The recipes run SCons 4.10.1 and Python 3.14 through it, so you don't install either yourself.
- Godot's own Linux build dependencies: a C++ compiler, `pkg-config` and the system libraries Godot's guide lists for [compiling for Linux](https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_for_linuxbsd.html).
- `ccache` and `mold`, which the fork's build options in `engine.py` use.
- The .NET 10 SDK. `global.json` asks for 10.0.100 or a later feature band.
- A systemd user session. `just build` and `just test` run under `systemd-run` with a memory cap.
- For `just spec`, Lean 4 through [elan](https://github.com/leanprover/elan). `Spec/lean-toolchain` pins the version.

## Building

```sh
just godot
just build
```

`just godot` builds the fork's double-precision .NET editor with SCons and ccache, generates its C# glue, and pushes the GodotSharp and Godot.NET.Sdk packages it builds to a local NuGet feed in `.cache/godot/nuget`. The repository's `NuGet.config` points at that feed, and the game project builds against those packages, so run it before the first `just build` and again whenever the fork changes. ccache keeps its files in `~/.cache/evil-engine/ccache`, up to 30 GB, and `just ccache` shows its hit rate.

`just build` builds everything in `EvilEngine.slnx`: the game's `Shared`, `Server` and `Client` projects, the libraries, every adapter and the mounts inspector. Each adapter is laid out in `.build/adapters/<id>/` as it builds.

`just compiledb` writes `Engine/compile_commands.json` for an IDE like CLion, with the same options as `just godot`, without compiling anything.

## Running

```sh
just editor
```

That opens the fork's editor on the game project in `Godot/`. Run the project from there. A run from the editor reads adapters from `.build/adapters` and Plugins from `.build/plugins`, then the player's own from `user://adapters` and `user://plugins`, and mounts whatever pointers are in `user://mounts`. On Linux, `user://` is `~/.local/share/godot/app_userdata/Evil Engine/`. [Mounting your games](/docs/playing/mounting-games) covers the menu from there.

There's no export recipe yet, so there's no standalone build to run.

## Testing

```sh
just test
```

That runs every test project in the solution through Microsoft.Testing.Platform. Anything after `just test` is passed on to `dotnet test`.

Most tests run on small files built in memory. The ones that read a real game install skip unless an environment variable points at it: `EVIL_GMOD`, `EVIL_QUAKE`, `EVIL_BUNKER`, `EVIL_KSP`, `EVIL_SUBNAUTICA` and so on, one per game. For example:

```sh
EVIL_QUAKE="$HOME/.local/share/Steam/steamapps/common/Quake" just test
```

`just fixtures` rebuilds the test fixtures the format and music tests read. It needs Blender, ffmpeg, flac and lame, and the fork's editor.

## Memory

`just build` and `just test` run as a transient systemd unit capped at 8 GB of memory and no swap, so a runaway build or test is killed on its own rather than taking the desktop with it. Set `EVIL_BUILD_MEMORY` or `EVIL_TEST_MEMORY` to change the cap, as in `EVIL_TEST_MEMORY=12G just test`.

.NET builds leave idle MSBuild worker nodes running by default. The justfile turns that off for its own recipes, and `Directory.Build.rsp` passes `-nodeReuse:false` to every MSBuild run in the repository, so a `dotnet build` you run yourself doesn't leave them either.

## The Lean spec

```sh
just spec
just spec-compare
```

`Spec/` models the engine's laws in Lean 4. `just spec` checks that every law is stated and proved, or shown broken, against the design. `just spec-compare` writes `Spec/Comparison.md` with each law as the docs state it beside its Lean, and fails when a quoted doc line has drifted.

## Other recipes

| Recipe | What it does |
| --- | --- |
| `just mounts [location]` | Builds, then probes a location through the built adapters and prints its mounts, or every pointer in `user://mounts` with no location. `--file`, `--convert` and `--out` trace a file or convert one thing. |
| `just map-shot <map>` | Renders a map to a PNG from its spawn, or from `--at` and `--look`. |
| `just map-bench [map]` | Times a map's start the way Start runs it, in a fresh game each run. |
| `just html [page]` | Opens a menu page in the HTML scratchpad, redrawing it on save. |

## Where things are

| Folder | Holds |
| --- | --- |
| `Engine/` | The Godot fork, as a submodule. |
| `Godot/` | The game project, with its C# split into `Shared`, `Server` and `Client`. |
| `Libraries/` | The engine's own libraries: `EvilEngine.Mounts`, `EvilEngine.Formats`, `EvilEngine.Conversion`, `EvilEngine.Api`, `EvilEngine.Host` and the rest, with `Adapters/`, `Tests/` and `Tools/` beside them. |
| `Spec/` | The Lean model of the laws. |
| `Documentation/` | These docs, and the design notes behind them. |

If you're here to add a game, [Writing a mount adapter](/docs/adapters/mount-adapter) is next.
