Integrate native OBW editor and three submenu themes (by Codex)
# Conflicts: # tools/public_release/check_public_tree.py
This commit is contained in:
commit
6636308cad
55 files changed
+5879
-8
No files matched your search
@@ -0,0 +1,121 @@
|
||||
#!/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 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()
|
||||
name = 'OpenBMHEditor-poc-' + 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')
|
||||
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,
|
||||
'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:
|
||||
stage = Path(td) / 'OpenBMHEditor-poc-source'; stage.mkdir()
|
||||
project = [Path(f.decode()) for f in git(source, 'ls-files', '-z').split(b'\0') if f]
|
||||
manifest = {'project_commit': commit, '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\n'
|
||||
'ctest --test-dir build -R ^editor_core_tests$ --output-on-failure\n'
|
||||
'Native compiler, CMake and OS development libraries: see project/docs/EDITOR.md.\n')
|
||||
zip_tree(stage, args.out / 'OpenBMHEditor-poc-source.zip')
|
||||
print(args.out / 'OpenBMHEditor-poc-source.zip')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -16,7 +16,9 @@ def validate(directory, windows):
|
||||
'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'}
|
||||
'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')}
|
||||
present = set()
|
||||
|
||||
@@ -41,14 +41,56 @@ PRIVATE_DOCUMENTS = {
|
||||
}
|
||||
SOURCE_SUFFIXES = {".cpp", ".hpp", ".h", ".c", ".inc"}
|
||||
SKIP_DIRECTORIES = {".git", "__pycache__", ".cache", "_deps", "node_modules"}
|
||||
# Independently generated launcher artwork already published on the launcher
|
||||
# branch, with provenance in its assets/launcher/provenance.json. History checks
|
||||
# include those branches too. Approve only these exact reviewed bytes and path.
|
||||
# Exact independently generated artwork and synthetic native-editor captures.
|
||||
# The latter are reviewed against docs/qa/editor-poc/README.md; no game material.
|
||||
# Keep prior reviewed hashes if an asset is intentionally revised in history.
|
||||
PROJECT_ARTWORK = {
|
||||
"docs/qa/editor-poc/clubs-midnight-de.png": {
|
||||
"2921aa67a870633c96f46328a82bc3022e5489b38d551c5314f13c7e59446070",
|
||||
"aa53e9cdd9ac8f6bf18b514862ac704ff9003bd1b62466cad2ebc329b09703dc",
|
||||
},
|
||||
"docs/qa/editor-poc/gui-search.png": {
|
||||
"48dc00d03c01d5bbec35683ff65672c12af4be6aecc8a84e5fece243c56643f4",
|
||||
"ef1780e91034dab96a7b23c638cdc8476f09be701b892f77e94e2fc2874cbd19",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-midnight-de.png": {
|
||||
"44a89dfd84d7ee5b2acb54ae749e69051ae71ce192885dbe1a9311aba778c8ca",
|
||||
"eb01bd8fd8eaadfbc8e2b3f634bcdafbbb084dc4592d849e102a6f8c70ab0ad4",
|
||||
},
|
||||
"docs/qa/editor-poc/options-midnight-de.png": {
|
||||
"7075957db2d5f5a166bb71adb97d8208cb051a72b555202c212fae4f7e5c402c",
|
||||
"be483ad35a8912766611fd63dcc7cde6f820ed9a78441ad49554102a096633ab",
|
||||
},
|
||||
"docs/qa/editor-poc/players-silver-en.png": {
|
||||
"0d463d74a78072dda5b830c1d8c5e12d7e4588f6a743a95cc2ca4a327278928c",
|
||||
"d965a904663f3a30e5410f5d33539f6247737293625039fb9e3028337bbc088c",
|
||||
},
|
||||
"docs/qa/editor-poc/roster-matchday-de.png": {
|
||||
"547acb1b03ee68a3cee217fc5c96f4b960c64a5e48d1074e4f19045d98559647",
|
||||
"937829bb31b7452aa15d4a54cd03ad5de6a42d630b83cce279f22da09dfe180b",
|
||||
},
|
||||
"assets/launcher/stadium.tga": {
|
||||
"08f82783a357d5b0722f3737de54844150bc14d98036845f1aaee3211608e1c8",
|
||||
"fb8e5f1f86afe60de87b70a2f533690d1ef470241fa24ee4384ff000149edaab",
|
||||
},
|
||||
"docs/qa/editor-poc/clubs-silver-de.png": {
|
||||
"4f5dbe76b86097d306d2c982ce48093cce0fc95e9f35853493779b3116399239",
|
||||
},
|
||||
"docs/qa/editor-poc/options-silver-de.png": {
|
||||
"e406dca9058569f91fb314f0ff548ff349190c13ef1ed90c0051e44899634493",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-silver-de.png": {
|
||||
"8d6ead6fd0e2fddc8e23de0a71abe519fa4f19ede0676823892d2568481bf68c",
|
||||
},
|
||||
"docs/qa/editor-poc/clubs-matchday-de.png": {
|
||||
"e74d0b9acd07f6a48537616c28d74e53b8f69e20bb15fc3f6fcd0c10484b4f58",
|
||||
},
|
||||
"docs/qa/editor-poc/options-matchday-de.png": {
|
||||
"c0b2a8b936dccdcbac72169e2985ca91221ec605dd4ad96a624be23f225b608a",
|
||||
},
|
||||
"docs/qa/editor-poc/image-editor-matchday-de.png": {
|
||||
"e0f5fb9f986d01c27ce04da8bd8ac7623ee3b2afcbf8a8677c3580dcb0465c36",
|
||||
},
|
||||
}
|
||||
|
||||
LEGACY_SYMBOLS = re.compile(
|
||||
@@ -244,11 +286,12 @@ def scan_tree(root: Path):
|
||||
return findings, len(names)
|
||||
|
||||
|
||||
def scan_history(root: Path):
|
||||
def scan_history(root: Path, revision=None):
|
||||
findings = []
|
||||
references = subprocess.check_output(["git", "-C", str(root), "for-each-ref", "--format=%(refname)"])
|
||||
findings.extend(scan_blob("ref-names", references))
|
||||
refs = subprocess.check_output(["git", "-C", str(root), "rev-list", "--all"], text=True).splitlines()
|
||||
selection = [revision] if revision else ["--all"]
|
||||
refs = subprocess.check_output(["git", "-C", str(root), "rev-list", *selection], text=True).splitlines()
|
||||
seen = set()
|
||||
checked = 0
|
||||
for revision in refs:
|
||||
@@ -280,15 +323,18 @@ def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--root", type=Path, default=Path.cwd())
|
||||
parser.add_argument("--history", action="store_true", help="also check all reachable commits and their blobs")
|
||||
parser.add_argument("--revision", help="with --history, inspect this revision's ancestry instead of unrelated refs")
|
||||
parser.add_argument("--json", type=Path, help="write a report containing rule names and locations only")
|
||||
args = parser.parse_args(argv)
|
||||
if args.revision and (not args.history or args.revision.startswith('-')):
|
||||
parser.error("--revision requires --history and a revision, not an option")
|
||||
if args.history and shutil.which("git") is None:
|
||||
parser.error("Git is required for history checks")
|
||||
root = args.root.resolve(strict=True)
|
||||
findings, files = scan_tree(root)
|
||||
commits = blobs = 0
|
||||
if args.history:
|
||||
extra, commits, blobs = scan_history(root)
|
||||
extra, commits, blobs = scan_history(root, args.revision)
|
||||
findings.extend(extra)
|
||||
findings = sorted(set(findings))
|
||||
def display_path(name):
|
||||
|
||||
Reference in new issue
Block a user