winzik/docker/standalone/spc-registries.php
David Nurdin c8337fd01f A game as one executable: bin/jumphp export:standalone (StaticPHP micro with SDL, OpenGL, OpenAL + the game as a PHAR)
- docker/standalone: StaticPHP v3 (pinned) and JumPHP's registry: SDL2, SDL2_image, SDL2_mixer, SDL2_ttf,
  OpenAL Soft static; php-sdl, sdl_image, sdl_mixer, sdl_ttf, PHP-OpenGL (JumPHP's patch), PHP-OpenAL built in
- Linux: glibc 2.17 (Zig); X11, ALSA, PulseAudio and OpenGL loaded from the player's system (OpenGL through
  SDL_GL_GetProcAddress, nothing linked); tested with Pong and 3D Jumpball (23 MB each)
- Windows: config.w32 of the extensions and the workflow .github/workflows/standalone.yml (run by hand) that
  publishes both micros as the release standalone-<key>; export:standalone downloads them
- docs/standalone.md, README, AGENTS.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 01:52:36 +01:00

18 lines
1 KiB
PHP

<?php
// StaticPHP 3.0.0-alpha1: the packages and artifacts of a registry loaded after the core one (SPC_REGISTRIES) are
// never instantiated (the loaders build their instances once, on the first registry). Built for each registry here.
foreach (['src/StaticPHP/Registry/ArtifactLoader.php' => 'artifacts', 'src/StaticPHP/Registry/PackageLoader.php' => 'packages'] as $file => $var) {
$code = file_get_contents($file);
$old = "if (self::\${$var} !== null) {\n return;\n }";
if (!str_contains($code, $old)) {
fwrite(STDERR, "$file: not patched (StaticPHP changed)\n");
exit(1);
}
$code = str_replace($old, '', $code);
$code = preg_replace('/(foreach \((?:ArtifactConfig|PackageConfig)::getAll\(\) as \$name => \$item\) \{)/', "$1\n if (isset(self::\${$var}[\$name])) {\n continue;\n }", $code, 1, $n);
if ($n !== 1) {
fwrite(STDERR, "$file: not patched\n");
exit(1);
}
file_put_contents($file, $code);
}