PS2 games in the browser: static recompilation to WebAssembly with a native runtime
C++
Web build: game names with spaces
Samir Nuri7b27f04230a1
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 11decaf..1420ded 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -92,7 +92,7 @@ if(PS2_GENERATED)set(PS2_WEB_BOOT_FILE "" CACHE FILEPATH "Text file holding the argv[0] the game sees, preloaded as /game/boot.txt")add_executable(ps2web host/web.cpp)if(PS2_WEB_BOOT_FILE)- target_link_options(ps2web PRIVATE "SHELL:--preload-file ${PS2_WEB_BOOT_FILE}@/game/boot.txt")+ target_link_options(ps2web PRIVATE "SHELL:--preload-file \"${PS2_WEB_BOOT_FILE}@/game/boot.txt\"")endif()target_link_libraries(ps2web PRIVATE ps2game ps2runtime)target_link_options(ps2web PRIVATE --profiling-funcs -sJSPI -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=268435456 -sPTHREAD_POOL_SIZE=2 -sALLOW_TABLE_GROWTH=1 -lidbfs.js -sSTACK_SIZE=16777216 -sENVIRONMENT=webdiff --git a/scripts/build_web.sh b/scripts/build_web.shindex 04a3cb2..a5b610f 100755--- a/scripts/build_web.sh+++ b/scripts/build_web.sh@@ -19,4 +19,4 @@ emcmake cmake -S "$here" -B "$out" -G Ninja -DCMAKE_BUILD_TYPE=Release \-DPS2_GENERATED="$here/generated/$game" -DPS2_WEB_ELF="$elf" -DPS2_WEB_BOOT_FILE="$out/boot.txt"ninja -C "$out" ps2webgzip -kf9 "$out/ps2web.wasm" "$out/ps2web.data" "$out/ps2web.js"-echo "built $out/ps2web.html; serve it with scripts/serve.py build/web-$game games/$game/disc.iso"+printf 'built %s/ps2web.html; serve it with scripts/serve.py %q %q\n' "$out" "build/web-$game" "games/$game/disc.iso"diff --git a/scripts/port.sh b/scripts/port.shindex 08f48f5..ad472bd 100755--- a/scripts/port.sh+++ b/scripts/port.sh@@ -150,8 +150,8 @@ fiecho "== [6/6] web build""$here/build_web.sh" "$name" "$EMSDK"echo-echo "Done. Serve it with: python3 scripts/serve.py build/web-$name games/$name/disc.iso"+printf 'Done. Serve it with: python3 scripts/serve.py %q %q\n' "build/web-$name" "games/$name/disc.iso"echo "and open http://localhost:8620/"if [ -x "$native/ps2run" ]; then- echo "or play it natively: build/native-$name/ps2run ${elf#$ROOT/} --disc games/$name/disc.iso --window"+ printf 'or play it natively: %q %q --disc %q --window\n' "build/native-$name/ps2run" "${elf#$ROOT/}" "games/$name/disc.iso"fi