1 ## How to build with Emscripten
3 Please use docker with the supplied `Dockerfile` to build for emscripten.
4 It takes care of a few things:
5 - Use a version of emscripten we know works.
6 - Add LibLZMA library under contrib ports.
8 First, build the docker image by navigating in the folder this `README.md` is in, and executing:
10 docker build -t emsdk-openttd .
13 Next, navigate back to the root folder of this project.
15 Now we build the host tools first:
18 docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-openttd cmake .. -DOPTION_TOOLS_ONLY=ON
19 docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-openttd make -j$(nproc) tools
22 Finally, we build the actual game:
25 docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-openttd emcmake cmake .. -DHOST_BINARY_DIR=../build-host -DCMAKE_BUILD_TYPE=Release -DOPTION_USE_ASSERTS=OFF
26 docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-openttd emmake make -j$(nproc)
29 In the `build` folder you will now see `openttd.html`.
31 To run it locally, you would have to start a local webserver; something like:
35 python3 -m http.server
38 You can now play the game via http://127.0.0.1:8000/openttd.html .