Take a compiler cache in front of clang from SCCACHE

A lift rewrites every generated chunk with the same contents, so a local sccache hits all of their objects and the
compile step costs seconds instead of minutes. build_game.py writes it into the ninja file ahead of cc when the
environment names one; the build guide describes the setting.
This commit is contained in:
shenjack committed 2026-10-31 16:49:40 +08:00
1 parent adf9c768c3
commit 7508469b6e
2 files changed
+12 -1

No files matched your search

+8
View File
@@ -87,6 +87,14 @@ From the repository root, in PowerShell. Every step that depends on the game ver
```
Lifting takes about 15 s, a clean compile about 200 s on 24 threads; later builds recompile only what changed.
A compiler cache in front of clang shortens it further: with `SCCACHE` set to an sccache executable, `build_game.py`
writes it into the ninja file ahead of `cc`, and every lift rewrites the generated chunks with the same contents, so
a second build of the same version hits all of their objects:
```powershell
$env:SCCACHE = "path\to\sccache.exe"
.venv\Scripts\python tools\build_game.py --version <ver>
```
`--patches` builds in the frame-rate, resolution and other patch sets, switchable at run time. The link copies
`SDL3.dll`, `libiconv-2.dll` and `libopus-0.dll` next to the exe.
For Xbox button prompts, run `make_romfs_patches.py` once more with `--xbox-prompts`: it writes
+4 -1
View File
@@ -257,11 +257,14 @@ def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib=
imgui = cmd_path(RUNTIME / 'third_party' / 'imgui')
rt_inc = f'{inc} -I {cmd_path(out)} -I {vma} -I {imgui}' # romfs_config.h, vk_mem_alloc.h (+ deps headers), imgui.h
libs = [f'-L {cmd_path(DEPS / "lib")}'] + LLVM_LINK_LIBS if DEPS else LINK_LIBS
# A compiler cache (sccache) may front clang: every lift rewrites the generated chunks with the same contents, so
# the cached objects save the compile step on the next build.
cache = f'{cmd_arg(os.environ["SCCACHE"])} ' if os.environ.get('SCCACHE') else ''
lines = [
'# Written by tools/build_game.py; do not edit.',
'ninja_required_version = 1.10',
f'builddir = {ninja_path(out)}',
f'cc = {cmd_arg(CLANG.as_posix())}',
f'cc = {cache}{cmd_arg(CLANG.as_posix())}',
f'genflags = {" ".join(GEN_FLAGS)} {inc}',
f'rtflags = {" ".join(RT_FLAGS)} {rt_inc}',
f'ldflags = {" ".join(LINK_FLAGS)}',