Restore direct-installation Classic baseline for OpenBMH 1.0 (by Codex)

This commit is contained in:
Codex committed 2026-10-30 14:19:25 +01:00
1 parent c8f04d0099
commit c3704878d6
255 files changed
+311 -21131

No files matched your search

-127
View File
@@ -1,127 +0,0 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-only
"""Package the standalone editor, its native assets and corresponding source.
This deliberately includes no imported world or original game artwork.
"""
import argparse
import hashlib
import json
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import zipfile
from make_source_package import COMPONENTS, MINIZ_FILES, git, copy_files
EXTRA = {
'editor_json': ('v3.12.0', 'https://github.com/nlohmann/json'),
'editor_http': ('v0.63.0', 'https://github.com/yhirose/cpp-httplib'),
'editor_images': ('release-2.8.8', 'https://github.com/libsdl-org/SDL_image'),
'editor_svg': ('v3.5.0', 'https://github.com/sammycage/lunasvg'),
'editor_xml': ('v1.15', 'https://github.com/zeux/pugixml'),
}
def zip_tree(root, target):
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
for file in sorted(root.rglob('*')):
if file.is_file():
info = zipfile.ZipInfo.from_file(file, Path(root.name) / file.relative_to(root))
archive.writestr(info, file.read_bytes(), compress_type=zipfile.ZIP_DEFLATED)
def copy_dependency(directory, target, name, reference):
if name == 'miniz' and not (directory / '.git').exists():
for file, expected in MINIZ_FILES.items():
if hashlib.sha256((directory / file).read_bytes()).hexdigest() != expected:
raise RuntimeError('Unexpected miniz source')
copy_files(directory, target, list(map(Path, MINIZ_FILES)), required=True)
return {'archive': reference}
commit = git(directory, 'rev-parse', 'HEAD').decode().strip()
expected = git(directory, 'rev-parse', reference + '^{commit}').decode().strip()
if commit != expected or git(directory, 'diff', '--name-only', '--ignore-submodules=all').strip():
raise RuntimeError('Modified dependency: ' + name)
files, modules = [], {}
for entry in git(directory, 'ls-files', '--stage', '-z').split(b'\0'):
if not entry:
continue
meta, file = entry.split(b'\t', 1); file = Path(file.decode())
if meta.startswith(b'160000 '):
# Only this codec is enabled. Freetype's dlg is unused by CMake.
required = name == 'editor_images' and file.as_posix() == 'external/libwebp'
if required:
module_commit = meta.split()[1].decode()
modules[str(file)] = copy_dependency(directory / file, target / file, name + '/libwebp', module_commit)
else:
modules[str(file)] = {'unbuilt': True, 'commit': meta.split()[1].decode()}
else:
files.append(file)
if name == 'lzma_sdk':
files = [f for f in files if f.parts[0] == 'C' or f == Path('DOC/License.txt')]
hashes = copy_files(directory, target, files, required=True)
return {'commit': commit, 'files': hashes, 'submodules': modules}
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--source', type=Path, default=Path(__file__).resolve().parents[2])
parser.add_argument('--build', type=Path, required=True)
parser.add_argument('--out', type=Path, required=True)
parser.add_argument('--platform', required=True, choices=['linux-x64', 'windows-x64', 'macos-arm64'])
parser.add_argument('--source-package', action='store_true')
args = parser.parse_args()
source, build = args.source.resolve(), args.build.resolve()
args.out.mkdir(parents=True, exist_ok=True)
commit = git(source, 'rev-parse', 'HEAD').decode().strip()
version = json.loads((build / 'editor-version.json').read_text())['version']
if not re.fullmatch(r'\d+\.\d+\.\d+', version):
raise RuntimeError('Invalid editor version')
name = 'OpenBMHEditor-' + version + '-' + args.platform
with tempfile.TemporaryDirectory(prefix='editor-package-') as td:
stage = Path(td) / name; stage.mkdir()
exe = 'OpenBMHEditor.exe' if args.platform.startswith('windows') else 'OpenBMHEditor'
subprocess.run(['cmake', '--install', str(build), '--component', 'Editor', '--config', 'Release',
'--prefix', str(stage)], check=True)
shutil.copytree(source / 'docs/licenses', stage / 'licenses')
for file in ('LICENSE', 'THIRD_PARTY_NOTICES.md'):
shutil.copy2(source / file, stage / file)
shutil.copy2(source / 'docs/EDITOR.md', stage / 'EDITOR.md')
shutil.copy2(source / 'docs/release/editor-0.5/RELEASE_NOTES.md', stage / 'RELEASE_NOTES.md')
if args.platform.startswith('windows'):
# Uses the same app-local CRT/UCRT installation as the main game.
# A successful runner launch alone does not prove deployability.
for dll in ('vcruntime140.dll', 'msvcp140.dll'):
if not (stage / dll).is_file():
raise RuntimeError('Required Windows runtime missing: ' + dll)
(stage / 'BUILD.json').write_text(json.dumps({'commit': commit, 'platform': args.platform, 'version': version,
'editor_profile': 'editor-world-v1', 'game_data_included': False}, indent=2) + '\n')
zip_tree(stage, args.out / (name + '.zip'))
print(args.out / (name + '.zip'))
if args.source_package:
deps = {**json.loads((build / 'package-dependencies.json').read_text()),
**json.loads((build / 'editor-dependencies.json').read_text())}
components = {**{n: (v[0], v[1]) for n, v in COMPONENTS.items()}, **EXTRA}
with tempfile.TemporaryDirectory(prefix='editor-source-') as td:
source_name = 'OpenBMHEditor-' + version + '-source'
stage = Path(td) / source_name; stage.mkdir()
project = [Path(f.decode()) for f in git(source, 'ls-files', '-z').split(b'\0') if f]
manifest = {'project_commit': commit, 'editor_version': version, 'project_files': copy_files(source, stage / 'project', project, required=True), 'dependencies': {}}
cache = ['set(OPENBMH_BUILD_EDITOR ON CACHE BOOL "" FORCE)']
for name, (ref, url) in components.items():
result = copy_dependency(Path(deps[name]), stage / 'dependencies' / name, name, ref)
manifest['dependencies'][name] = {'reference': ref, 'upstream': url, **result}
cache.append('set(FETCHCONTENT_SOURCE_DIR_' + name.upper() + ' "${CMAKE_CURRENT_LIST_DIR}/dependencies/' + name + '" CACHE PATH "" FORCE)')
(stage / 'dependencies.cmake').write_text('\n'.join(cache) + '\n')
(stage / 'SOURCE_MANIFEST.json').write_text(json.dumps(manifest, indent=2) + '\n')
(stage / 'BUILD_SOURCE.txt').write_text('cmake -S project -B build -C dependencies.cmake -G Ninja -DCMAKE_BUILD_TYPE=Release\n'
'cmake --build build --target openbmh_editor editor_core_tests editor_comparison_tests editor_regulations_tests\n'
'ctest --test-dir build -R "^editor_(core_tests|comparison_tests|regulations_tests|version)$" --output-on-failure\n'
'Native compiler, CMake and OS development libraries: see project/docs/EDITOR.md.\n')
zip_tree(stage, args.out / (source_name + '.zip'))
print(args.out / (source_name + '.zip'))
if __name__ == '__main__':
main()
+4 -14
View File
@@ -10,17 +10,11 @@ import zipfile
def validate(directory, windows):
products = {name + ('.exe' if windows else '') for name in ('OpenBMH', 'openbmh_cli', 'openbmh_import')}
products = {'openbmh_play.exe', 'openbmh_cli.exe'} if windows else {'openbmh_play', 'openbmh_cli'}
documents = {'README.md', 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'ACKNOWLEDGEMENTS.md', 'CONTRIBUTING.md'}
licenses = {'README.md', 'LGPL-2.1.txt', 'Nuked-OPL3-notices.txt', 'LZMA-SDK.txt', 'SDL2-HIDAPI-BSD.txt',
'SDL2-HIDAPI-options.txt', 'SDL2-HIDAPI-original.txt', 'SDL2-yuv2rgb.txt',
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt',
'RmlUi.txt', 'RmlUi-containers.txt', 'RmlUi-fonts.txt', 'RmlUi-Khronos.txt',
'FreeType.txt', 'FreeType-FTL.txt', 'FreeType-BDF.txt', 'FreeType-PCF.txt', 'FreeType-zlib.txt',
'nlohmann-json.txt', 'cpp-httplib.txt', 'SDL2_image.txt', 'stb-image.txt',
'libwebp.txt', 'libwebp-PATENTS.txt', 'LunaSVG.txt', 'PlutoVG.txt', 'pugixml.txt'}
launcher_assets = {'assets/launcher/' + name for name in
('launcher.rml', 'theme.rcss', 'stadium.tga', 'LatoLatin-Regular.ttf', 'LatoLatin-Bold.ttf')}
'SDL2.txt', 'miniz-source-notices.txt', 'miniz.txt', 'nativefiledialog-extended.txt'}
present = set()
for file in directory.rglob('*'):
if not file.is_file():
@@ -28,22 +22,18 @@ def validate(directory, windows):
relative = file.relative_to(directory)
present.add(relative.as_posix())
allowed = (len(relative.parts) == 1 and file.name in products | documents)
allowed |= relative.as_posix() in launcher_assets
allowed |= len(relative.parts) == 3 and relative.parts[:2] == ('docs', 'licenses') and file.name in licenses
allowed |= (len(relative.parts) >= 2 and relative.parts[0] == 'docs' and
'licenses' not in relative.parts and file.suffix in {'.md', '.txt', '.csv'} and
all(part not in {'analyses', 'agents', 'manuals', 'validation'} for part in relative.parts))
# Versioned OBW schemas are authored format documentation, not game data.
allowed |= bool(re.fullmatch(r'docs/formats/obw/schema/[1-9][0-9]*\.[0-9]+/[a-z][a-z0-9_-]*\.json',
relative.as_posix()))
# App-local UCRT deployment must ship the whole redist set, core forwarders included.
allowed |= (windows and len(relative.parts) == 1 and
bool(re.fullmatch(r'(?:vcruntime\d+(?:_\d+)?|msvcp\d+(?:_\d+|_atomic_wait|_codecvt_ids)?|'
r'concrt\d+|ucrtbase|api-ms-win-(?:crt|core)-[a-z0-9-]+)\.dll', file.name, re.I)))
if not allowed:
raise RuntimeError('Unexpected package entry: ' + relative.as_posix())
required = products | documents | launcher_assets | {'docs/licenses/' + name for name in licenses}
required.add('docs/release/0.2/RELEASE_NOTES.md')
required = products | documents | {'docs/licenses/' + name for name in licenses}
required.add('docs/release/0.1/RELEASE_NOTES.md')
if required - present:
raise RuntimeError('Missing package entries: ' + ', '.join(sorted(required - present)))
if windows and not {'vcruntime140.dll', 'msvcp140.dll'} <= present:
+2 -26
View File
@@ -16,8 +16,6 @@ COMPONENTS = {
'miniz': ('3.0.2', 'https://github.com/richgel999/miniz', ['miniz.c', 'miniz.h', 'LICENSE']),
'lzma_sdk': ('24.09', 'https://github.com/ip7z/7zip', ['C/7zDec.c', 'C/7z.h', 'DOC/License.txt']),
'nfd': ('v1.2.1', 'https://github.com/btzy/nativefiledialog-extended', ['CMakeLists.txt', 'src/nfd_cocoa.m', 'LICENSE']),
'rmlui': ('6.3', 'https://github.com/mikke89/RmlUi', ['CMakeLists.txt', 'Include/RmlUi/Core.h', 'LICENSE.txt']),
'freetype': ('VER-2-13-3', 'https://github.com/freetype/freetype', ['CMakeLists.txt', 'include/ft2build.h', 'LICENSE.TXT']),
}
# Verified against the archive SHA256 pinned in CMakeLists.txt. These are free
# dependency source files, not game data. Refuse modified archive-cache inputs.
@@ -34,26 +32,6 @@ def git(directory, *arguments):
return subprocess.check_output(['git', '-C', str(directory), *arguments])
def unbuilt_submodules(component, staged):
"""Only FreeType's unused make/autotools logging dependency is omitted.
The pinned CMake font-engine target does not compile dlg. Every other
submodule, or a changed revision, still needs explicit source packaging.
"""
excluded = {}
for record in staged.split(b'\0'):
if not record.startswith(b'160000 '):
continue
metadata, path = record.split(b'\t', 1)
commit = metadata.split()[1].decode()
name = path.decode()
if (component != 'freetype' or name != 'subprojects/dlg' or
commit != '72dfcc858c040c54a6a0b88fcb7e70ee186d3167'):
raise RuntimeError('Dependency submodules require explicit packaging: ' + component)
excluded[name] = commit
return excluded
def copy_files(source, destination, files, required=False, materialized_links=None):
"""Copy only the explicit source inventory, materializing internal links.
@@ -186,16 +164,15 @@ def main():
if not dependencies.get(name) or not all((directory / marker).is_file() for marker in markers):
raise RuntimeError('Actual dependency source unavailable: ' + name)
commit = None
excluded = {}
if (directory / '.git').exists():
commit = git(directory, 'rev-parse', 'HEAD').decode().strip()
tag = git(directory, 'rev-parse', reference + '^{commit}').decode().strip()
if commit != tag or git(directory, 'status', '--porcelain', '--untracked-files=no').strip():
raise RuntimeError('Dependency differs from its pinned source: ' + name)
excluded = unbuilt_submodules(name, git(directory, 'ls-files', '--stage', '-z'))
if git(directory, 'ls-files', '--stage').find(b'160000 ') != -1:
raise RuntimeError('Dependency submodules require explicit packaging: ' + name)
if commit:
files = [Path(p.decode('utf-8')) for p in git(directory, 'ls-files', '-z').split(b'\0') if p]
files = [p for p in files if p.as_posix() not in excluded]
if name == 'lzma_sdk':
files = [p for p in files if p.parts[0] == 'C' or p == Path('DOC/License.txt')]
else:
@@ -211,7 +188,6 @@ def main():
materialized_links=dependency_links)
manifest['dependencies'][name] = {'upstream': url, 'reference': reference,
'commit': commit, 'files': hashes,
'unbuilt_submodules': excluded,
'materialized_links': dependency_links}
initial_cache.append('set(FETCHCONTENT_SOURCE_DIR_' + name.upper() +
' "${CMAKE_CURRENT_LIST_DIR}/dependencies/' + name + '" CACHE PATH "" FORCE)')