Files
Strata/tools/packaging/ling32/engine_version.py
T
Niko1221 2d7be18840 ling32: one version source: the shared engine project version; the programs print the LING32_VERSION define, the packaging scripts read it, verify_pkg fails a disagreement
engine/src/ling32/CMakeLists.txt reads project(strata VERSION ...) of engine/CMakeLists.txt and passes LING32_VERSION to the program; ling32_main.cpp and the Metal main have no literal and stop the build without the define. tools/packaging/ling32/engine_version.py gives the same number to build_linux.sh, build_mac.sh, build_windows.py and the Metal build script (a VERSION given by hand must equal it). verify_pkg.py checks manifest, folder name, BUILD.json, the program's --version line, the source tree and the archive name. The release commit bumps one number in engine/CMakeLists.txt.
2026-12-02 15:27:44 +01:00

34 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""The ONE version of the Ling-3.2-Air engine: the shared engine project version, `project(strata VERSION x.y.z ...)` in engine/CMakeLists.txt (the line strata-engine, Inkling and Hy4 take
theirs from). Everything else reads it from there, nothing carries a literal:
- engine/src/ling32/CMakeLists.txt reads the same line and passes it to the program as the define LING32_VERSION (`strata-ling32 --version` prints it);
- the Mac build (engine/src/ling32/metal/build_mac.sh and tools/packaging/ling32/build_mac.sh) calls this script for the same define;
- the three packaging scripts (build_linux.sh, build_windows.py, build_mac.sh) take the package version from here, so the package folder, the manifest, the archive name and the program agree;
- verify_pkg.py fails a package whose manifest, folder name or `--version` line says another version.
python tools/packaging/ling32/engine_version.py # prints x.y.z
The release commit bumps the number in engine/CMakeLists.txt, in one place.
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parents[3]
PATTERN = re.compile(r"^\s*project\(\s*strata\s+VERSION\s+([0-9]+(?:\.[0-9]+)*)", re.MULTILINE)
def engine_version(repo: Path | None = None) -> str:
cmake = Path(repo or REPO) / "engine" / "CMakeLists.txt"
found = PATTERN.search(cmake.read_text(encoding="utf-8"))
if not found:
raise SystemExit(f"engine_version.py: no `project(strata VERSION x.y.z` line in {cmake}")
return found.group(1)
if __name__ == "__main__":
print(engine_version())
sys.exit(0)