This gist will demonstrate how to build the simplest example of Magnum with Emscripten, and run it in your browser, using With PowerShell for Windows, Linux and MacOS.
Translated to Alanese from Magnum Emscripten on Windows
References
# Check prerequisites
if ((get-command "cmake" -erroraction silentlycontinue) -eq $null) { write-host CMake not found! }
if ((get-command "ninja" -erroraction silentlycontinue) -eq $null) { write-host Ninja not found! }
if ((get-command "em++" -erroraction silentlycontinue) -eq $null) { write-host Emscripten not found! }
if ((get-command "corrade-rc" -erroraction silentlycontinue) -eq $null) { write-host corrade-rc not found! }
if ((get-command "python" -erroraction silentlycontinue) -eq $null) { write-host Python not found! }
Toubleshooting
I don't have Emscripten installed
Here's how to install it.
git clone https://github.com/emscripten-core/emsdk --branch 1.39.18 --single-branch
cd emsdk
./emsdk install latest
./emsdk activate latest
cd ..
Emscripten not found, but I have it installed
Then you need to activate the environment first.
. path/to/emscripten/emsdk_env.ps1
corrade-rc not found
Funnily enough, to build with Magnum for Emscripten, you need to build Corrade for Desktop first. Corrade provides an executable called corrade-rc
that you'll need accessible on PATH prior to continuing.
This is a fresh Ubuntu 18.04 Docker container
Then you'll need a few things.
apt install -y git python ninja-build cmake build-essential
$THIS_GIST="https://gist.github.com/e7078b6c646cefa7e532549963d6c2fa.git"
git clone $THIS_GIST magnum_emscripten
cd magnum_emscripten
. ./clone_magnum.ps1
. ./build_magnum.ps1
See below what these .ps1
files do.
mkdir web
cd web
cp ../index.html ./
cp $env:EMSDK/upstream/emscripten/system/share/magnum/* ./
cp ../magnum-examples/build-emc/Release/bin/* ./
python -m http.server
# Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/)
- Visit http://localhost:8000
- Profit
This gist should naturally lead to questions like..
cp
step references multiple paths, how do I change where files are installed?