-
Notifications
You must be signed in to change notification settings - Fork 10
129 lines (129 loc) · 4.85 KB
/
build-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
name: build-wasm
run-name: ${{ github.actor }} is building wasm file
on:
push:
paths-ignore:
- '**/README.md'
jobs:
build-wasm-file:
env:
EMSCRIPTEN: 3.1.37
QT_VERSION: 6.6.3
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check for a cached version
uses: actions/cache@v4
id: cached_qt_emscripten
with:
path: |
/opt/hostedtoolcache
# Adding version as cache key
key: ${{ runner.os }}-qt-${{ env.QT_VERSION }}-em-${{ env.EMSCRIPTEN }}-libegl1
- name: Install dependencies
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
sudo apt-get update -yq &&
sudo apt-get install -y g++ build-essential mesa-common-dev libssl-dev \
wget lsb libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev p7zip-full \
ninja-build dos2unix libegl1
sudo snap install yq
- name: Install libraries needed for building the wasm
run: |
sudo apt-get update -yq &&
sudo apt-get install -y libegl1
- name: Set up Python 3.x
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Qt ${{env.QT_VERSION}} linux desktop
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
modules: 'qtwebsockets qtshadertools'
dir: '/opt/hostedtoolcache'
- name: Install QT ${{env.QT_VERSION}} linux wasm and cmake
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: "${{env.QT_VERSION}}"
host: 'linux'
target: 'desktop'
arch: 'wasm_singlethread'
modules: 'qtwebsockets qtshadertools'
tools: 'tools_cmake'
dir: '/opt/hostedtoolcache'
- name: patch Qt ${{env.QT_VERSION}}
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo patch Qt
./.github/patches/qt-fixes.sh
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
dos2unix ${QTDIR}/plugins/platforms/{qtloader.js,wasm_shell.html}
- name: Install emscripten ${{env.EMSCRIPTEN}}
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing emscripten ${EMSCRIPTEN}
cd /opt/hostedtoolcache/
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install ${EMSCRIPTEN}
./emsdk activate ${EMSCRIPTEN}
- name: Install QtMQTT
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true'
run: |
echo installing QtMQTT
source "/opt/hostedtoolcache/emsdk/emsdk_env.sh"
git clone https://github.com/qt/qtmqtt.git
cd qtmqtt
git checkout $QT_VERSION
mkdir build-qtmqtt && cd build-qtmqtt
export PATH=$PATH:/opt/hostedtoolcache/Qt/Tools/CMake/bin
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
${QTDIR}/bin/qt-configure-module ..
cmake --build .
cmake --install . --prefix ${QTDIR} --verbose
- name: Build webassembly GUI
run: |
source "/opt/hostedtoolcache/emsdk/emsdk_env.sh"
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/wasm_singlethread
export PATH=$PATH:/opt/hostedtoolcache/Qt/Tools/CMake/bin
mkdir build-wasm && cd build-wasm
${QTDIR}/bin/qt-cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
cmake --build .
cd -
- name: Patch and pack webassembly files
run: |
mkdir -p artifacts/wasm
mv build-wasm/venus-gui-v2.{html,js,wasm} build-wasm/qtloader.js images/victronenergy.svg artifacts/wasm/
mv artifacts/wasm/venus-gui-v2.html artifacts/wasm/index.html
patch artifacts/wasm/index.html < ./.github/patches/index.html.patch
grep -q -E '^var createQtAppInstance' artifacts/wasm/venus-gui-v2.js
sed -i "s%^var \(createQtAppInstance\)%window.\1%" artifacts/wasm/venus-gui-v2.js
cp .github/patches/Makefile artifacts/wasm/
cp LICENSE.txt artifacts/wasm/
cd artifacts
zip -r ../venus-webassembly.zip wasm
- name: Upload wasm files
uses: actions/upload-artifact@v4
with:
name: venus-webassembly
path: artifacts
retention-days: 5
- name: Release tagged wasm files
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: venus-webassembly.zip