forked from SuperTux/supertux
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (118 loc) · 5.19 KB
/
wasm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# SuperTux
# Copyright (C) 2020-2021 Jacob Burroughs <[email protected]>
# 2020-2022 A. Semphris <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
name: WebAssembly
on:
push:
branches:
- master
tags:
- '*'
pull_request: {}
jobs:
wasm:
strategy:
fail-fast: false
matrix:
build_type: ["Release", "Debug"]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
# Fetch the whole tree so git describe works
fetch-depth: 0
submodules: true
- name: Install emscripten tools
run: |
cd ~
sudo apt-get update
sudo apt-get install -y git cmake build-essential curl zip
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 1.40.1
./emsdk activate 1.40.1
# Fixes a bug in emscripten - see https://github.com/emscripten-core/emscripten/issues/13590
sed -i "s/\#define MALLOC_ALIGNMENT ((size_t)(2 \* sizeof(void \*)))/#define MALLOC_ALIGNMENT 16/g" upstream/emscripten/system/lib/dlmalloc.c
# Fixes a bug with the libjpeg port - see https://github.com/emscripten-core/emscripten/pull/13878
sed -i 's/2b581c60ae401a79bbbe748ff2deeda5acd50bfd2ea22e5926e36d34b9ebcffb6580b0ff48e972c1441583e30e21e1ea821ca0423f9c67ce08a31dffabdbe6b7/b2affe9a1688bd49fc033f4682c4a242d4ee612f1affaef532f5adcb4602efc4433c4a52a4b3d69e7440ff1f6413b1b041b419bc90efd6d697999961a9a6afb7/g' upstream/emscripten/tools/ports/libjpeg.py
sed -i 's/https:\/\/dl.bintray.com\/homebrew\/mirror\/jpeg-9c.tar.gz/https:\/\/storage.googleapis.com\/webassembly\/emscripten-ports\/jpegsrc.v9c.tar.gz/g' upstream/emscripten/tools/ports/libjpeg.py
- name: Install vcpkg and dependencies
run: |
source ~/emsdk/emsdk_env.sh
cd ~
git clone https://github.com/microsoft/vcpkg
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg integrate install
./vcpkg/vcpkg install boost-date-time:wasm32-emscripten
./vcpkg/vcpkg install boost-filesystem:wasm32-emscripten
./vcpkg/vcpkg install boost-format:wasm32-emscripten
./vcpkg/vcpkg install boost-locale:wasm32-emscripten
./vcpkg/vcpkg install boost-optional:wasm32-emscripten
./vcpkg/vcpkg install boost-system:wasm32-emscripten
./vcpkg/vcpkg install glbinding:wasm32-emscripten
./vcpkg/vcpkg install libpng:wasm32-emscripten
./vcpkg/vcpkg install libogg:wasm32-emscripten
./vcpkg/vcpkg install libvorbis:wasm32-emscripten
./vcpkg/vcpkg install glm:wasm32-emscripten
./vcpkg/vcpkg install zlib:wasm32-emscripten
- name: Patch SDL_ttf
working-directory: external/SDL_ttf
run: git apply ../../mk/emscripten/SDL_ttf.patch
- name: Configure build
env:
BUILD_TYPE: ${{ matrix.build_type }}
run: |
source ~/emsdk/emsdk_env.sh
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_OPENGLES2=ON \
-DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake\
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DGLBINDING_ENABLED=ON\
-DEMSCRIPTEN=1 -DWARNINGS=ON -DWERROR=ON ..
- name: Sync data folder
working-directory: build
run: |
rsync -aP ../data/ data/
- name: Build
working-directory: build
run: |
source ~/emsdk/emsdk_env.sh
emmake make -j$(nproc)
# Now you can run a local server with: `emrun supertux2.html`
# Or any traditional web server will do the job
# Note: opening the html file manually (file:///) won't work
- name: Setup files for upload
working-directory: build
env:
BUILD_TYPE: ${{ matrix.build_type }}
run: |
rm supertux2.html && cp template.html supertux2.html
mkdir upload/
mv supertux2* upload/
- uses: actions/upload-artifact@v2
with:
name: "wasm32-emscripten-${{ matrix.build_type }}-html"
path: build/upload/*
if-no-files-found: ignore
- name: Upload to server
if: ${{ github.ref == 'refs/heads/master' && matrix.build_type == 'Release' }}
env:
UPLOAD_URL: ${{ secrets.UPLOAD_URL }}
run: |
cd build/upload/
mv supertux2.html index.html
zip supertux2.zip *
curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL