Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Last active January 16, 2023 04:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdimalev/3872c9fec2535645060a2e8396e1fb37 to your computer and use it in GitHub Desktop.
Save acdimalev/3872c9fec2535645060a2e8396e1fb37 to your computer and use it in GitHub Desktop.

set a base directory (just to make things easier)

$ basedir="$(pwd)"

set up Emscripten https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html

$ cd "$basedir"
$ git clone https://github.com/juj/emsdk.git
$ cd "$basedir"/emsdk
$ ./emsdk install latest
$ ./emsdk activate latest
$ . emsdk_env.sh
$ ./emcc -v

build a sample libretro core

$ cd "$basedir"
$ git clone https://github.com/libretro/libretro-samples.git
$ cd "$basedir"/libretro-samples/video/software/rendering
$ . "$basedir"/emsdk/emsdk_env.sh
$ emmake make
$ file testsw_libretro.so

build and link against Retro Arch

$ cd "$basedir"
$ git clone https://github.com/libretro/RetroArch.git
$ cd "$basedir"/RetroArch/dist-scripts
$ . "$basedir"/emsdk/emsdk_env.sh
$ cp -a "$basedir"/libretro-samples/video/software/rendering/testsw_libretro.so \
> testsw_emscripten.bc
$ emmake sh dist-cores.sh emscripten
$ file ../pkg/emscripten/testsw_emscripten_libretro.*

make the web player just happy enough to run mostly based on https://github.com/libretro/RetroArch/blob/master/pkg/emscripten/README.md

$ cd "$basedir"/RetroArch/pkg/emscripten/libretro
$ # link core binaries to correct location
$ ln -s ../testsw_emscripten_libretro.* .
$ # add core to drop-down menu
$ patch << EOD
--- index.html.orig     2018-08-08 06:40:34.972472742 +0000
+++ index.html  2018-08-08 07:06:06.785513134 +0000
@@ -27,6 +27,7 @@
                   <li class="nav-item dropdown">
                         <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Core Selection</button>
                         <div class="dropdown-menu dropdown-primary" aria-labelledby="dropdownMenu1" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut" id="core-selector">
+                           <a class="dropdown-item" href="." data-core="testsw_emscripten">testsw</a>
                            <a class="dropdown-item" href="." data-core="2048">2048</a>
                            <a class="dropdown-item" href="." data-core="4do">4DO</a>
                            <a class="dropdown-item" href="." data-core="bluemsx">BlueMSX</a>
EOD
$ # build bogus file indexes
$ for x in \
>   assets/frontend/bundle \
>   assets/cores \
>   ; do
>   mkdir -p "$x"
>   echo '{}' > "$x"/.index-xhr
> done
$ # run a web server
$ emrun index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment