mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 18:25:35 -04:00
f9109e21c6
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Guard bezel artwork as a mod-owned presentation feature."""
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
MAIN = (ROOT / "runtime/src/main.cpp").read_text(encoding="utf-8")
|
|
HEADER = (ROOT / "runtime/include/mod_plugins.h").read_text(encoding="utf-8")
|
|
MOD_RUNTIME = (ROOT / "runtime/src/mod_runtime.cpp").read_text(encoding="utf-8")
|
|
BUILTIN = (ROOT / "runtime/src/mod_builtin_bezel.c").read_text(encoding="utf-8")
|
|
HOST_PATH = (ROOT / "recompiler/include/host_path.h").read_text(encoding="utf-8")
|
|
CONFIG_H =(ROOT / "recompiler/src/config_loader.h").read_text(encoding="utf-8")
|
|
CONFIG_CPP = (ROOT / "recompiler/src/config_loader.cpp").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
MANIFEST = (
|
|
ROOT
|
|
/ "mods/builtin/packages/psx.presentation.bezel/1.0.0/manifest.toml"
|
|
).read_text(encoding="utf-8")
|
|
|
|
assert "video_bezel" not in CONFIG_H
|
|
assert 'video.contains("bezel")' not in CONFIG_CPP
|
|
assert "psx_mod_set_bezel_artwork" in HEADER
|
|
assert "psx_mod_current_package_file" not in HEADER
|
|
assert "psx_mod_current_resource_path" in HEADER
|
|
assert "psx_mod_set_bezel_artwork" in MAIN
|
|
assert "g_video_renderer = 1;" in MAIN
|
|
assert "mod-owned OpenGL margin artwork" in MAIN
|
|
# Relative artwork paths resolve against the exe directory at load time, never
|
|
# cwd; absolute paths (the builtin resource) pass through host_resolve as-is.
|
|
LOADER = MAIN[MAIN.index("/* Bezel artwork (Mods): load after the GL context exists. */"):]
|
|
LOADER = LOADER[: LOADER.index("gl_renderer_set_bezel(")]
|
|
assert (
|
|
"PSXRecompV4::host_resolve(\n"
|
|
" exe_dir_from_argv(argv[0]), std::filesystem::path(g_bezel_path));"
|
|
) in LOADER
|
|
assert "host_path_is_absolute(path) ? path : root / path" in HOST_PATH
|
|
assert "std::fopen" not in LOADER
|
|
assert "std::filesystem::path bp(g_bezel_path)" not in MAIN
|
|
assert "resolved against the\n * executable's directory, never the current working directory" in HEADER
|
|
assert "current_plugin" in MOD_RUNTIME
|
|
assert 'psx_mod_current_resource_path("artwork"' in BUILTIN
|
|
assert 'psx_mod_register_activation_plugin("psx.bezel"' in BUILTIN
|
|
assert 'id = "psx.presentation.bezel"' in MANIFEST
|
|
assert "default_enabled = false" in MANIFEST
|
|
assert "[[resource]]" in MANIFEST
|
|
assert 'id = "artwork"' in MANIFEST
|
|
assert 'file_patterns = "*.png,*.jpg,*.jpeg,*.bmp"' in MANIFEST
|
|
assert 'id = "psx.bezel"' in MANIFEST
|
|
assert not (
|
|
ROOT
|
|
/ "mods/builtin/packages/psx.presentation.bezel/1.0.0/bezel.png"
|
|
).exists()
|
|
|
|
print("mod-owned bezel guard passed")
|