PS2 games in the browser: static recompilation to WebAssembly with a native runtime
C++
Build on macOS on Apple silicon
Adrian Gąsiorek8281f0c5a853
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 1420ded..6b67293 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -77,6 +77,9 @@ if(EMSCRIPTEN OR EXISTS "${PS2_WGPU_DIR}/lib/libwgpu_native.a")else()target_include_directories(ps2runtime PRIVATE "${PS2_WGPU_DIR}/include")target_link_libraries(ps2runtime PUBLIC "${PS2_WGPU_DIR}/lib/libwgpu_native.a" dl pthread m)+ if(APPLE)+ target_link_libraries(ps2runtime PUBLIC "-framework Metal" "-framework QuartzCore" "-framework Foundation" "-framework CoreFoundation" "-framework IOKit" "-framework IOSurface" objc)+ endif()endif()endif()diff --git a/README.md b/README.mdindex 3f1f35f..005df72 100644--- a/README.md+++ b/README.md@@ -50,7 +50,7 @@ Along the way it also needed a boot path like the BIOS gives, a module loaded fr## Port a game of your own-You need git, CMake, Ninja, a C++20 compiler (clang is preferred and picked up automatically), Python 3, and 7-Zip if your disc image is in a `.7z`. Everything has been run on Linux on x86-64. The first run installs the Emscripten SDK into `tools/emsdk`, or uses the one `EMSDK` points to, and downloads wgpu-native for the native runner. With `--native-only` the script skips the browser build and never installs the SDK; the native window then needs the SDL2 development files. Expect about 300 MB of disk space per game for the generated code and the builds; the disc image itself is linked, not copied.+You need git, CMake, Ninja, a C++20 compiler (clang is preferred and picked up automatically), Python 3, and 7-Zip if your disc image is in a `.7z`. Everything has been run on Linux on x86-64, and the scripts also build on macOS on Apple silicon, where the scripts need a newer bash than the system 3.2 (`brew install bash cmake ninja sevenzip`) and the native runner links wgpu-native against Metal. The first run installs the Emscripten SDK into `tools/emsdk`, or uses the one `EMSDK` points to, and downloads wgpu-native for the native runner. With `--native-only` the script skips the browser build and never installs the SDK; the native window then needs the SDL2 development files. Expect about 300 MB of disk space per game for the generated code and the builds; the disc image itself is linked, not copied.```bashgit clone https://github.com/snuri00/ps2-web-recomp.gitdiff --git a/scripts/fetch_wgpu.sh b/scripts/fetch_wgpu.shindex d15cfa8..146fd6a 100755--- a/scripts/fetch_wgpu.sh+++ b/scripts/fetch_wgpu.sh@@ -4,7 +4,7 @@ version=${1:-v29.0.1.1}here=$(cd "$(dirname "$0")/.." && pwd)target="$here/third_party/wgpu-native"mkdir -p "$target"-curl -L -o "$target/wgpu.zip" "https://github.com/gfx-rs/wgpu-native/releases/download/$version/wgpu-linux-x86_64-release.zip"+curl -L -o "$target/wgpu.zip" "https://github.com/gfx-rs/wgpu-native/releases/download/$version/wgpu-$(uname -s | sed "s/Darwin/macos/;s/Linux/linux/")-$(uname -m | sed "s/arm64/aarch64/")-release.zip"unzip -o -q "$target/wgpu.zip" -d "$target"rm "$target/wgpu.zip"echo "wgpu-native $version in $target"