2 Commits

6 changed files with 83 additions and 2 deletions

View File

@@ -47,8 +47,25 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
working-directory: source_godot
run: |
python3 tools/fetch_template.py
cp ~/.local/share/godot/export_templates/${GODOT_VER}.stable/windows_release_x86_64.exe tools/template.exe
# small template without 3D/physics (tools/build_template.sh), kept in the prerelease template-<ver>;
# if it is missing or its checksum differs, fall back to the official 109 MB one
if curl -sSL --fail -o tools/template.exe "http://gitea:3000/${{ github.repository }}/releases/download/template-${GODOT_VER}/TinMerezhi-template.exe" \
&& echo "$(cat tools/template.sha256) tools/template.exe" | sha256sum -c -; then
echo "small template: $(stat -c %s tools/template.exe) bytes"
else
echo "::warning::small template not available, using the official one"
python3 tools/fetch_template.py
cp ~/.local/share/godot/export_templates/${GODOT_VER}.stable/windows_release_x86_64.exe tools/template.exe
fi
# emoji font: keep only the characters the game uses (10.6 MB -> ~0.2 MB); without fontTools the full font stays
python3 -c 'import fontTools' 2>/dev/null || python3 -m pip install -q --break-system-packages fonttools \
|| (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq python3-fonttools >/dev/null) || true
if python3 -c 'import fontTools'; then
python3 tools/subset_emoji.py fonts/NotoColorEmoji.ttf /tmp/emoji.ttf && mv /tmp/emoji.ttf fonts/NotoColorEmoji.ttf
godot --headless --path . --import
else
echo "::warning::fontTools not installed, emoji font not reduced"
fi
cp icon.ico tools/
# official Go toolchain from the Go module proxy, only to build go-winres (puts the icon into the exe)
curl -sSL --fail -o /tmp/go.zip "https://proxy.golang.org/golang.org/toolchain/@v/v0.0.1-go1.24.7.linux-amd64.zip"

View File

@@ -66,6 +66,13 @@
3. У `export_presets.cfg` встанови `custom_template/release` = повний шлях до `template.exe`, потім:
`godot --headless --path . --export-release "Windows Desktop" ../game_godot/TinMerezhi.exe`
**Малий exe (~35 МБ замість ~120 МБ).** CI бере власний шаблон без 3D, фізики, навігації, XR і зайвих модулів
(`tools/template_custom.py`) з пререлізу `template-4.7.2` у Gitea і звіряє `tools/template.sha256`; шрифт емодзі
урізається до символів, що є в коді (`tools/subset_emoji.py`, потрібен `pip install fonttools`). Новий шаблон
(інша версія Godot або інші модулі): `tools/build_template.sh` (~20–40 хв, mingw-w64 + scons), викласти exe в
пререліз `template-<версія>` як `TinMerezhi-template.exe` і оновити `tools/template.sha256`. Пререліз не бачить
автооновлення гри (`/releases/latest` віддає лише звичайні релізи). Нові класи рушія в коді: перевір, що їх не вимкнено.
## Реліз
Кожен push у `main` — тести й бот балансу в Gitea Actions (`.gitea/workflows/build.yml`).

View File

@@ -0,0 +1,13 @@
#!/bin/sh
# Builds the small Windows export template (tools/template_custom.py) from Godot sources.
# Needs: python3 + scons, mingw-w64 (posix threads). About 40 min on 4 cores, ~6 GB RAM, ~5 GB disk.
# Result: godot-<ver>-stable/bin/godot.windows.template_release.x86_64.exe -> upload it to the Gitea
# prerelease "template-<ver>" as TinMerezhi-template.exe and put its sha256 into tools/template.sha256.
set -e
VER="${GODOT_VER:-4.7.2}"
HERE="$(cd "$(dirname "$0")" && pwd)"
curl -sSL --fail -o "godot-$VER.tar.xz" "https://github.com/godotengine/godot/releases/download/$VER-stable/godot-$VER-stable.tar.xz"
tar xf "godot-$VER.tar.xz"
cd "godot-$VER-stable"
scons profile="$HERE/template_custom.py" d3d12=no vulkan=no -j"$(nproc)"
sha256sum bin/godot.windows.template_release.x86_64.exe

View File

@@ -0,0 +1,18 @@
"""Keeps in NotoColorEmoji only the glyphs whose characters occur in the game's .gd/.tscn files (both languages)."""
import glob, sys
from fontTools import subset
from fontTools.ttLib import TTFont
src, dst = sys.argv[1], sys.argv[2]
text = "".join(open(p, encoding="utf-8").read() for p in glob.glob("**/*.gd", recursive=True) + glob.glob("**/*.tscn", recursive=True))
cmap = TTFont(src).getBestCmap()
used = sorted({ord(c) for c in text if ord(c) in cmap and ord(c) > 0x7F})
opts = subset.Options()
opts.layout_features = ["*"] # ZWJ sequences, skin tones, flags (GSUB ligatures)
opts.notdef_outline = True
s = subset.Subsetter(opts)
s.populate(unicodes=used + [0x200D, 0xFE0F, 0x20E3])
f = TTFont(src)
s.subset(f)
f.save(dst)
print(len(used), "codepoints:", "".join(map(chr, used)))

View File

@@ -0,0 +1 @@
84715e06d937dd9b7e84838fa4ef8f4619e0d4f97b7887c72385189db26f67bb

View File

@@ -0,0 +1,25 @@
# TinMerezhi: Windows release template without 3D, physics, navigation, XR and unused modules.
# vulkan/d3d12 are also passed on the command line (build_template.sh): the profile alone does not switch them off.
platform = "windows"
target = "template_release"
arch = "x86_64"
production = "yes"
optimize = "size"
lto = "full"
debug_symbols = "no"
disable_3d = "yes"
disable_physics_2d = "yes"
disable_physics_3d = "yes"
disable_navigation_2d = "yes"
disable_navigation_3d = "yes"
disable_xr = "yes"
vulkan = "no"
d3d12 = "no"
openxr = "no"
modules_enabled_by_default = "no"
# GDScript, fonts (FreeType + HarfBuzz shaping), SVG for the default theme icons, mbedTLS for HTTPS in the updater
module_gdscript_enabled = "yes"
module_freetype_enabled = "yes"
module_text_server_adv_enabled = "yes"
module_svg_enabled = "yes"
module_mbedtls_enabled = "yes"