Skip to content

Commit

Permalink
Codechange: upgrade Emscripten to 3.1.57 (OpenTTD#12526)
Browse files Browse the repository at this point in the history
This also upgrades liblzma to 5.4.6, and uses the new ports.contrib
system Emscripten 3.1.56 introduced.
  • Loading branch information
TrueBrain authored Apr 18, 2024
1 parent 08d05bf commit 04a3bf7
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 217 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-20.04
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:3.1.42
image: emscripten/emsdk:3.1.57

steps:
- name: Checkout
Expand All @@ -23,12 +23,11 @@ jobs:
uses: actions/cache@v4
with:
path: /emsdk/upstream/emscripten/cache
key: 3.1.42-${{ runner.os }}
key: 3.1.57-${{ runner.os }}

- name: Patch Emscripten to support LZMA
- name: Add liblzma support
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
- name: Build (host tools)
run: |
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
container:
# If you change this version, change the number in the cache step too.
image: emscripten/emsdk:3.1.42
image: emscripten/emsdk:3.1.57

steps:
- name: Checkout
Expand All @@ -38,12 +38,11 @@ jobs:
uses: actions/cache@v4
with:
path: /emsdk/upstream/emscripten/cache
key: 3.1.42-${{ runner.os }}
key: 3.1.57-${{ runner.os }}

- name: Patch Emscripten to support LZMA
- name: Add liblzma support
run: |
cd /emsdk/upstream/emscripten
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
- name: Build (host tools)
run: |
Expand Down
5 changes: 2 additions & 3 deletions os/emscripten/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM emscripten/emsdk:3.1.42
FROM emscripten/emsdk:3.1.57

COPY emsdk-liblzma.patch /
RUN cd /emsdk/upstream/emscripten && patch -p1 < /emsdk-liblzma.patch
COPY ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/liblzma.py
4 changes: 2 additions & 2 deletions os/emscripten/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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)
- Use a version of emscripten we know works.
- Add LibLZMA library under contrib ports.

First, build the docker image by navigating in the folder this `README.md` is in, and executing:
```
Expand Down
8 changes: 4 additions & 4 deletions os/emscripten/cmake/FindLibLZMA.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LibLZMA is a custom addition to the emscripten SDK, so it is possible
# someone patched their SDK. Test out if the SDK supports LibLZMA.
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "-sUSE_LIBLZMA=1")
set(CMAKE_REQUIRED_FLAGS "--use-port=contrib.liblzma")

check_cxx_source_compiles("
#include <lzma.h>
Expand All @@ -12,9 +12,9 @@ check_cxx_source_compiles("
if (LIBLZMA_FOUND)
add_library(LibLZMA::LibLZMA INTERFACE IMPORTED)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
INTERFACE_COMPILE_OPTIONS "-sUSE_LIBLZMA=1"
INTERFACE_LINK_LIBRARIES "-sUSE_LIBLZMA=1"
INTERFACE_COMPILE_OPTIONS "--use-port=contrib.liblzma"
INTERFACE_LINK_LIBRARIES "--use-port=contrib.liblzma"
)
else()
message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please apply 'emsdk-liblzma.patch' to your local emsdk installation.")
message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please copy liblzma.py to your ports/contrib folder in your local emsdk installation.")
endif()
198 changes: 0 additions & 198 deletions os/emscripten/emsdk-liblzma.patch

This file was deleted.

Loading

0 comments on commit 04a3bf7

Please sign in to comment.