Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,63 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: mymindstorm/setup-emsdk@v13
- uses: mymindstorm/setup-emsdk@v14

- name: Prepare web data
run: ./build-scripts/prepare-web-data.sh

- name: Install ccache
run: |
emsdk install ccache-git-emscripten-64bit
emsdk activate ccache-git-emscripten-64bit

- name: Get ccache vars
id: get-vars
run: |
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
echo "ccache-path=$(echo '~/.cache/ccache')" >> $GITHUB_OUTPUT

- name: ccache cache files
uses: actions/cache@v4
with:
path: ${{ steps.get-vars.outputs.ccache-path }}
# double-dash after compiler is not a typo, it is to disambiguate between g++-<date> and g++-11-<date> for restore key prefix matching
key: ccache-${{ github.ref_name }}-emscripten--${{ steps.get-vars.outputs.datetime }}
restore-keys: |
ccache-master-emscripten--

- name: Build with emcc (emscripten)
run: ./build-scripts/build-emscripten.sh
run: |
emsdk activate ccache-git-emscripten-64bit
# This $PATH manipulation is to work around a bug in emsdk, see
# https://github.com/emscripten-core/emsdk/pull/1345
# Once that bug is fixed, we should be able to drop this weird PATH
# stuff.
export PATH="${PATH%%:*}/../../ccache/git-emscripten_64bit/bin":$PATH
# The forked ccache seems to crash unless EM_CONFIG is defined, I'm not
# sure why this isn't figured out automatically.
export EM_CONFIG=$EMSDK/.emscripten
ccache --zero-stats
ccache -M 5G
ccache --show-stats

./build-scripts/build-emscripten.sh

- name: post-build ccache manipulation
run: |
emsdk activate ccache-git-emscripten-64bit
export PATH="${PATH%%:*}/../../ccache/git-emscripten_64bit/bin":$PATH
ccache --show-stats
ccache -M 5G
ccache -c
ccache --show-stats

- name: clear ccache on PRs
if: ${{ github.ref_name != 'master' && !failure() }}
run: |
emsdk activate ccache-git-emscripten-64bit
export PATH="${PATH%%:*}/../../ccache/git-emscripten_64bit/bin":$PATH
ccache -C

- name: Assemble web bundle
run: ./build-scripts/prepare-web.sh
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ endif
ifeq ($(NATIVE), emscripten)
CXX=emcc
LD=emcc
ifeq ($(CCACHE), 1)
CXX=$(CCACHEBIN) emcc
LD=$(CCACHEBIN) emcc
endif

# Flags that are common across compile and link phases.
EMCC_COMMON_FLAGS = -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sUSE_SDL_TTF=2 -sSDL2_IMAGE_FORMATS=['png']
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/build-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -exo pipefail

emsdk install 3.1.51
emsdk activate 3.1.51
emsdk activate 3.1.51 ccache-git-emscripten-64bit

make -j`nproc` NATIVE=emscripten BACKTRACE=0 TILES=1 TESTS=0 RUNTESTS=0 RELEASE=1 cataclysm-tiles.js
make -j`nproc` NATIVE=emscripten BACKTRACE=0 TILES=1 TESTS=0 RUNTESTS=0 RELEASE=1 CCACHE=1 LINTJSON=0 cataclysm-tiles.js