diff options
author | Patric Stout <truebrain@openttd.org> | 2020-12-05 21:57:47 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2020-12-15 15:46:39 +0100 |
commit | d15dc9f40f5a20bff452547a2dcb15231f9f969d (patch) | |
tree | 7b8d88635c048d906cbb6358007fb26055e24410 /os/emscripten/README.md | |
parent | 2da07f76154d841bcfe9aaff4833144550186deb (diff) | |
download | openttd-d15dc9f40f5a20bff452547a2dcb15231f9f969d.tar.xz |
Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.
Co-authored-by: milek7 <me@milek7.pl>
Diffstat (limited to 'os/emscripten/README.md')
-rw-r--r-- | os/emscripten/README.md | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/os/emscripten/README.md b/os/emscripten/README.md new file mode 100644 index 000000000..4c5d7508c --- /dev/null +++ b/os/emscripten/README.md @@ -0,0 +1,40 @@ +## How to build with Emscripten + +Building with Emscripten works with emsdk 2.0.10 and above. + +Currently there is no LibLZMA support upstream; for this we suggest to apply +the provided patch in this folder to your emsdk installation. + +For convenience, a Dockerfile is supplied that does this patches for you +against upstream emsdk docker. Best way to use it: + +Build the docker image: +``` + docker build -t emsdk-lzma . +``` + +Build the host tools first: +``` + mkdir build-host + docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma cmake .. -DOPTION_TOOLS_ONLY=ON + docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma make -j5 tools +``` + +Next, build the game with emscripten: + +``` + mkdir build + docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emcmake cmake .. -DHOST_BINARY_DIR=$(pwd)/build-host -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF + docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emmake make -j5 +``` + +And now you have in your build folder files like "openttd.html". + +To run it locally, you would have to start a local webserver, like: + +``` + cd build + python3 -m http.server +```` + +Now you can play the game via http://127.0.0.1:8000/openttd.html . |