2020-12-05 20:57:47 +00:00
|
|
|
## How to build with Emscripten
|
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
Please use docker with the supplied `Dockerfile` to build for emscripten.
|
|
|
|
It takes care of a few things:
|
|
|
|
- Use a version of emscripten we know works
|
|
|
|
- Patch in LibLZMA support (as this is not supported by upstream)
|
2020-12-05 20:57:47 +00:00
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
First, build the docker image by navigating in the folder this `README.md` is in, and executing:
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
2023-05-02 18:45:04 +00:00
|
|
|
docker build -t emsdk-openttd .
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
Next, navigate back to the root folder of this project.
|
|
|
|
|
|
|
|
Now we build the host tools first:
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
|
|
|
mkdir build-host
|
2023-05-02 18:45:04 +00:00
|
|
|
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-openttd cmake .. -DOPTION_TOOLS_ONLY=ON
|
|
|
|
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-openttd make -j$(nproc) tools
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
Finally, we build the actual game:
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
|
|
|
mkdir build
|
2023-05-02 18:45:04 +00:00
|
|
|
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
|
|
|
|
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-openttd emmake make -j$(nproc)
|
2020-12-05 20:57:47 +00:00
|
|
|
```
|
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
In the `build` folder you will now see `openttd.html`.
|
2020-12-05 20:57:47 +00:00
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
To run it locally, you would have to start a local webserver; something like:
|
2020-12-05 20:57:47 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
cd build
|
|
|
|
python3 -m http.server
|
|
|
|
````
|
|
|
|
|
2022-12-29 22:34:45 +00:00
|
|
|
You can now play the game via http://127.0.0.1:8000/openttd.html .
|