-
-
Notifications
You must be signed in to change notification settings - Fork 4
308 lines (275 loc) · 10.1 KB
/
Copy pathlinux_build.yml
File metadata and controls
308 lines (275 loc) · 10.1 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# Inspired by: https://github.com/PCSX2/pcsx2/blob/master/.github/workflows/linux_build_qt.yml
name: Linux Build Steps
on:
workflow_call:
inputs:
jobName:
required: true
type: string
artifactPrefixName:
required: true
type: string
os:
required: false
type: string
default: ubuntu-22.04
compiler:
required: false
type: string
default: clang
buildType:
required: false
type: string
default: Release
cmakeFlags:
required: false
type: string
default: ""
fetchTags:
required: false
type: boolean
default: false
platform:
required: false
type: string
default: x64
jobs:
build_linux:
name: ${{ inputs.jobName }}
runs-on: ${{ inputs.os }}
timeout-minutes: 60
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 9
CCACHE_MAXSIZE: 100M
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: recursive
# actions/checkout elides tags, fetch them primarily for releases
- name: Fetch Tags
if: ${{ inputs.fetchTags }}
run: git fetch --tags --no-recurse-submodules
- name: Prepare Artifact Metadata
id: artifact-metadata
shell: bash
env:
PREFIX: ${{ inputs.artifactPrefixName }}
EVENT_NAME: ${{ github.event_name }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUM: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
run: |
ARTIFACT_NAME="${PREFIX}"
if [ "$EVENT_NAME" == "pull_request" ]; then
PR_SHA_SHORT="${PR_SHA:0:8}"
ARTIFACT_NAME="${PREFIX}-pr${PR_NUM}-${PR_SHA_SHORT}"
fi
echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
# -- SETUP CCACHE - https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
run: echo "timestamp=$(date -u "+%Y-%m-%d-%H;%M;%S")" >> $GITHUB_OUTPUT
- name: Cache ccache
uses: actions/cache@v6.1.0
with:
path: .ccache
key: ${{ inputs.os }} ${{ inputs.platform }} ${{ inputs.compiler }} ccache ${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: ${{ inputs.os }} ${{ inputs.platform }} ${{ inputs.compiler }} ccache
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get -y install \
build-essential \
ccache \
clang \
lld \
cmake \
ninja-build \
pkg-config \
libvulkan-dev \
libgl1-mesa-dev \
libegl-dev \
libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxcb1-dev \
libxrandr-dev \
libxcursor-dev \
libxinerama-dev \
libxi-dev \
libxkbcommon-x11-dev \
libtiff5-dev \
imagemagick \
wget
- name: Install Qt (x64)
if: inputs.platform != 'arm64'
uses: jurplel/install-qt-action@v4.3.1
with:
version: '6.11.1'
host: 'linux'
target: 'desktop'
arch: 'linux_gcc_64'
modules: 'qtimageformats qtwaylandcompositor'
cache: true
use-official: true
- name: Install Qt (ARM64)
if: inputs.platform == 'arm64'
uses: jurplel/install-qt-action@v4.3.1
with:
version: '6.11.1'
host: 'linux_arm64'
target: 'desktop'
arch: 'linux_gcc_arm64'
modules: 'qtimageformats qtwaylandcompositor'
cache: true
use-official: true
- name: Configure CMake (Clang)
if: inputs.compiler == 'clang'
run: |
if [ "${{ inputs.buildType }}" = "Debug" ]; then
if [ "${{ inputs.platform }}" = "arm64" ]; then
PRESET="linux-arm64-dbg"
else
PRESET="linux-x64-dbg"
fi
else
if [ "${{ inputs.platform }}" = "arm64" ]; then
PRESET="linux-arm64-rel"
else
PRESET="linux-x64-rel"
fi
fi
echo "PRESET=$PRESET" >> $GITHUB_ENV
cmake --preset $PRESET \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
${{ inputs.cmakeFlags }}
- name: Configure CMake (GCC)
if: inputs.compiler == 'gcc'
run: |
if [ "${{ inputs.buildType }}" = "Debug" ]; then
if [ "${{ inputs.platform }}" = "arm64" ]; then
PRESET="linux-arm64-gcc-dbg"
else
PRESET="linux-x64-gcc-dbg"
fi
else
if [ "${{ inputs.platform }}" = "arm64" ]; then
PRESET="linux-arm64-gcc-rel"
else
PRESET="linux-x64-gcc-rel"
fi
fi
echo "PRESET=$PRESET" >> $GITHUB_ENV
cmake --preset $PRESET \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
${{ inputs.cmakeFlags }}
- name: Build
run: |
ccache -p
ccache -z
cmake --build --preset ${{ env.PRESET }}
ccache -s
- name: Create AppImage
id: create-appimage
shell: bash
run: |
set -e
if [ "${{ inputs.buildType }}" = "Debug" ]; then
CONF="Debug"
else
CONF="MinSizeRel"
fi
APPIMAGE_NAME="${{ steps.artifact-metadata.outputs.artifact-name }}.AppImage"
BUILD_DIR="build/${{ env.PRESET }}/bin/$CONF"
APPDIRNAME="myMCpp.AppDir"
if [ ! -f "${BUILD_DIR}/myMCpp" ]; then
echo "Error: Binary not found at ${BUILD_DIR}/myMCpp"
exit 1
fi
export ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
APPIMAGE_ARCH="aarch64"
else
APPIMAGE_ARCH="x86_64"
fi
LINUXDEPLOY=./linuxdeploy-${APPIMAGE_ARCH}.AppImage
LINUXDEPLOY_PLUGIN_QT=./linuxdeploy-plugin-qt-${APPIMAGE_ARCH}.AppImage
APPIMAGETOOL=./appimagetool-${APPIMAGE_ARCH}.AppImage
echo "Downloading linuxdeploy..."
if [ ! -f "$LINUXDEPLOY" ]; then
wget -q -O "$LINUXDEPLOY" https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${APPIMAGE_ARCH}.AppImage
chmod +x "$LINUXDEPLOY"
fi
echo "Downloading linuxdeploy Qt plugin..."
if [ ! -f "$LINUXDEPLOY_PLUGIN_QT" ]; then
wget -q -O "$LINUXDEPLOY_PLUGIN_QT" https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-${APPIMAGE_ARCH}.AppImage
chmod +x "$LINUXDEPLOY_PLUGIN_QT"
fi
echo "Downloading appimagetool..."
if [ ! -f "$APPIMAGETOOL" ]; then
wget -q -O "$APPIMAGETOOL" https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${APPIMAGE_ARCH}.AppImage
chmod +x "$APPIMAGETOOL"
fi
OUTDIR=$(realpath "./$APPDIRNAME")
rm -fr "$OUTDIR"
echo "Copying desktop file..."
cat > myMCpp.desktop << 'EOF'
[Desktop Entry]
Type=Application
Name=myMCpp
Comment=PlayStation 2 memory card manager
Exec=myMCpp
Icon=myMCpp
Categories=Utility;
EOF
echo "Resizing icon to 256x256..."
convert resources/icons/AppIcon.png -resize 256x256 myMCpp.png
QMAKE_PATH=$(which qmake 2>/dev/null || which qmake6 2>/dev/null || echo "")
if [ -z "$QMAKE_PATH" ]; then
QMAKE_PATH=$(find /opt/qt -name qmake 2>/dev/null | head -n 1 || echo "")
fi
if [ -z "$QMAKE_PATH" ]; then
QMAKE_PATH=$(find /usr/lib/qt6 -name qmake 2>/dev/null | head -n 1 || echo "")
fi
if [ -z "$QMAKE_PATH" ]; then
echo "Error: qmake not found"
exit 1
fi
echo "Using QMAKE: $QMAKE_PATH"
echo "Running linuxdeploy to create AppDir..."
EXTRA_QT_MODULES="core;gui;svg;widgets;waylandclient;waylandcompositor;xcbqpa" \
EXTRA_PLATFORM_PLUGINS="libqwayland.so" \
DEPLOY_PLATFORM_THEMES="1" \
QMAKE="$QMAKE_PATH" \
NO_STRIP="1" \
$LINUXDEPLOY --plugin qt --appdir="$OUTDIR" --executable="${BUILD_DIR}/myMCpp" \
--desktop-file="myMCpp.desktop" --icon-file="myMCpp.png"
echo "Copying resources into AppDir..."
if [ -d "${BUILD_DIR}/resources" ]; then
cp -a "${BUILD_DIR}/resources" "$OUTDIR/usr/bin"
fi
echo "Copying translations into AppDir..."
if [ -d "${BUILD_DIR}/translations" ]; then
rm -fr "$OUTDIR/usr/bin/translations" "$OUTDIR/usr/translations"
cp -a "${BUILD_DIR}/translations" "$OUTDIR/usr/bin"
fi
echo "Generating AppImage..."
rm -f "$APPIMAGE_NAME"
$APPIMAGETOOL -v "$OUTDIR" "$APPIMAGE_NAME"
echo "AppImage created: ${APPIMAGE_NAME}"
echo "appimage-path=${APPIMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Upload AppImage artifact
uses: actions/upload-artifact@v7
with:
name: ${{ steps.artifact-metadata.outputs.artifact-name }}-AppImage
path: ${{ steps.create-appimage.outputs.appimage-path }}
if-no-files-found: error
retention-days: 30