forked from libsdl-org/SDL
-
Notifications
You must be signed in to change notification settings - Fork 0
384 lines (376 loc) · 17.8 KB
/
generic.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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
name: 'Build'
run-name: 'Configure, Build and Test SDL'
on:
workflow_call:
inputs:
platforms:
description: 'JSON-encoded test properties'
type: string
required: true
jobs:
build:
name: ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}
container: ${{ matrix.platform.container }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(inputs.platforms) }}
steps:
- name: 'Set up MSYS2'
if: ${{ matrix.platform.platform == 'msys2' }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.platform.msys2-msystem }}
install: >-
${{ matrix.platform.msys2-env }}-cc
${{ matrix.platform.msys2-env }}-cmake
${{ matrix.platform.msys2-env }}-ninja
${{ (!matrix.platform.msys2-no-perl && format('{0}-perl', matrix.platform.msys2-env)) || '' }}
${{ matrix.platform.msys2-env }}-pkg-config
${{ matrix.platform.msys2-env }}-clang-tools-extra
- name: 'About this job'
run: |
echo "key=${{ matrix.platform.key }}"
echo "name=${{ matrix.platform.name }}"
echo "os=${{ matrix.platform.os }}"
echo ""
echo "Add [sdl-ci-filter ${{ matrix.platform.key }}] to your commit message to reduce the number of jobs."
- uses: actions/checkout@v4
- name: 'Set up ninja'
if: ${{ matrix.platform.setup-ninja }}
uses: ./.github/actions/setup-ninja
- name: 'Set up libusb for MSVC'
if: ${{ matrix.platform.setup-libusb-arch != '' }}
uses: ./.github/actions/setup-msvc-libusb
with:
arch: ${{ matrix.platform.setup-libusb-arch }}
- uses: mymindstorm/setup-emsdk@v14
if: ${{ matrix.platform.platform == 'emscripten' }}
with:
version: 3.1.35
- uses: browser-actions/setup-chrome@v1
id: setup-chrome
if: ${{ matrix.platform.platform == 'emscripten' }}
with:
install-chromedriver: true
- name: 'Add chrome to PATH'
if: ${{ matrix.platform.platform == 'emscripten' }}
run: |
chrome_dir="$(dirname "${{ steps.setup-chrome.outputs.chrome-path }}")"
chromedriver_dir="$(dirname "${{ steps.setup-chrome.outputs.chromedriver-path }}")"
echo "CHROME_BINARY=${{ steps.setup-chrome.outputs.chrome-path }}" >>$GITHUB_ENV
echo "CHROMEDRIVER_BINARY=${{ steps.setup-chrome.outputs.chromedriver-path }}" >>$GITHUB_ENV
echo "chrome_dir=${chrome_dir}"
echo "chromedriver_dir=${chromedriver_dir}"
echo "${chrome_dir}" >>${GITHUB_PATH}
echo "${chromedriver_dir}" >>${GITHUB_PATH}
- uses: nttld/setup-ndk@v1
if: ${{ matrix.platform.android-ndk }}
id: setup-ndk
with:
local-cache: true
ndk-version: r21e
- name: 'Configure Android NDK variables'
if: ${{ matrix.platform.android-ndk }}
shell: sh
run: |
# We cannot use GitHub expressions in the controller job
echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >>$GITHUB_ENV
- uses: actions/setup-java@v4
if: ${{ matrix.platform.java }}
with:
distribution: 'temurin'
java-version: '17'
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.platform.platform == 'msvc' }}
with:
arch: ${{ matrix.platform.msvc-vcvars }}
- name: 'Set up Windows GDK Desktop'
uses: ./.github/actions/setup-gdk-desktop
if: ${{ matrix.platform.setup-gdk-folder != '' }}
with:
folder: '${{ matrix.platform.setup-gdk-folder }}'
- name: 'Set up LoongArch64 toolchain'
uses: ./.github/actions/setup-loongarch64-toolchain
id: setup-loongarch64-toolchain
if: ${{ matrix.platform.platform == 'loongarch64' }}
- name: 'Setup Intel oneAPI toolchain'
id: intel
if: ${{ matrix.platform.intel }}
run: |
# Download the key to system keyring
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
# Add signed entry to apt sources and configure the APT client to use Intel repository:
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
# Update package list
sudo apt-get update -y
# Install oneAPI
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
- name: 'Install apk packages'
if: ${{ matrix.platform.apk-packages != '' }}
run: |
${{ matrix.platform.sudo }} apk update
${{ matrix.platform.sudo }} apk add ${{ matrix.platform.apk-packages }}
- name: 'Install apt packages'
if: ${{ matrix.platform.apt-packages != '' }}
run: |
${{ matrix.platform.sudo }} apt-get update
${{ matrix.platform.sudo }} apt-get install -y ${{ matrix.platform.apt-packages }}
- name: 'Install brew packages'
if: ${{ matrix.platform.brew-packages != '' }}
run: |
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
brew update
brew install ${{ matrix.platform.brew-packages }}
- name: 'Set up GLES for VITA' # Must be after apk
if: ${{ matrix.platform.setup-vita-gles-type != '' }}
uses: ./.github/actions/setup-vita-gles
with:
type: ${{ matrix.platform.setup-vita-gles-type }}
- name: 'Pollute toolchain with "bad" SDL headers'
if: ${{ matrix.platform.pollute-directories != '' }}
#shell: ${{ matrix.platform.shell }}
run: |
# Create "bad" SDL headers in the toolchain.
# SDL sources should not use these.
for include in ${{ matrix.platform.pollute-directories }}; do
toolchain_directory="${include}/SDL3"
echo "Creating directory ${toolchain_directory}"
mkdir -p "${toolchain_directory}/SDL3"
for header in include/SDL3/*.h; do
dest="${toolchain_directory}/SDL3/$(basename "${header}")"
echo "Creating ${dest}"
echo '#error "System SDL headers must not be used by build system"' >"$dest"
done
done
- name: 'Configure (CMake)'
if: ${{ !matrix.platform.no-cmake }}
#shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -GNinja \
-Wdeprecated -Wdev -Werror \
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-DSDL_WERROR=${{ matrix.platform.werror }} \
-DSDL_EXAMPLES=${{ matrix.platform.build-tests }} \
-DSDL_TESTS=${{ matrix.platform.build-tests }} \
-DSDLTEST_TRACKMEM=ON \
-DSDL_INSTALL_TESTS=${{ matrix.platform.build-tests }} \
-DSDL_CLANG_TIDY=${{ matrix.platform.clang-tidy }} \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
-DSDL_DISABLE_INSTALL_CPACK=OFF \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
${{ matrix.platform.cmake-arguments }} \
-DSDL_SHARED=${{ matrix.platform.shared }} \
-DSDL_STATIC=${{ matrix.platform.static }} \
-DSDL_VENDOR_INFO="Github Workflow" \
-DCMAKE_INSTALL_PREFIX=prefix \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
- name: 'Build (CMake)'
id: build
if: ${{ !matrix.platform.no-cmake }}
# shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
cmake --build build --config ${{ matrix.platform.cmake-build-type }} --verbose -- ${{ matrix.platform.cmake-build-arguments }}
- name: 'Verify SDL_REVISION'
if: ${{ !matrix.platform.no-cmake }}
run: |
echo "This should show us the SDL_REVISION"
echo "Shared library:"
${{ (matrix.platform.shared-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
echo "Static library:"
${{ (matrix.platform.static-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
- name: 'Run build-time tests (CMake)'
id: tests
if: ${{ !matrix.platform.no-cmake && matrix.platform.run-tests }}
# shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
${{ matrix.platform.pretest-cmd }}
set -eu
export SDL_TESTS_QUICK=1
ctest -VV --test-dir build/ -j2
- name: "Build test apk's (CMake)"
id: apks
if: ${{ steps.build.outcome == 'success' && matrix.platform.android-apks != '' }}
# shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
cmake --build build --config ${{ matrix.platform.cmake-build-type }} \
--target \
${{ matrix.platform.android-apks }} \
--verbose \
-- ${{ matrix.platform.cmake-build-arguments }}
- name: 'Install (CMake)'
id: install
if: ${{ steps.build.outcome == 'success' }}
# shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
cmake --install build --config ${{ matrix.platform.cmake-build-type }}
echo "prefix=$(pwd)/prefix" >> $GITHUB_OUTPUT
( cd prefix; find . ) | LC_ALL=C sort -u
- name: 'Package (CPack)'
id: package
if: ${{ steps.build.outcome == 'success' }}
# shell: ${{ matrix.platform.shell }}
run: |
# DMG creation on macOS occasionally fails, so try multiple times
# https://gitlab.kitware.com/cmake/cmake/-/issues/25671
success=0
max_tries=10
for i in $(seq $max_tries); do
cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target package -- ${{ matrix.platform.cmake-build-arguments }} && success=1
if test $success = 1; then
break
fi
echo "Package creation failed. Sleep 1 second and try again."
sleep 1
done
if test $success = 0; then
echo "Package creation failed after $max_tries attempts."
exit 1
fi
- name: 'Verify CMake configuration files'
if: ${{ steps.install.outcome == 'success' }}
# shell: ${{ matrix.platform.shell }}
run: |
${{ matrix.platform.source-cmd }}
${{ matrix.platform.cmake-config-emulator }} cmake -S cmake/test -B cmake_test_build -GNinja \
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-DTEST_SHARED=${{ matrix.platform.shared }} \
-DTEST_STATIC=${{ matrix.platform.static }} \
${{ matrix.platform.cmake-arguments }} \
-DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
-DCMAKE_PREFIX_PATH="${{ steps.install.outputs.prefix }}"
cmake --build cmake_test_build --verbose --config ${{ matrix.platform.cmake-build-type }} -- ${{ matrix.platform.cmake-build-arguments }}
- name: 'Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain'
if: ${{ steps.install.outcome == 'success' && matrix.platform.cc-from-cmake }}
# shell: ${{ matrix.platform.shell }}
run: |
cmake -S .github/cmake -B /tmp/cmake_extract \
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
-DVAR_PATH=/tmp/env.txt
cat /tmp/env.txt >> $GITHUB_ENV
- name: 'Verify sdl3.pc'
# shell: ${{ matrix.platform.shell }}
if: ${{ steps.install.outcome == 'success' && matrix.platform.test-pkg-config }}
run: |
${{ matrix.platform.source-cmd }}
${{ matrix.platform.cc && format('export CC="{0}"', matrix.platform.cc) || '' }}
${{ matrix.platform.cflags && format('export CFLAGS="{0}"', matrix.platform.cflags) || '' }}
${{ matrix.platform.ldflags && format('export LDFLAGS="{0}"', matrix.platform.ldflags) || '' }}
export PKG_CONFIG_PATH=${{ steps.install.outputs.prefix }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
- name: 'Build (cross-platform-actions, BSD)'
id: cpactions
if: ${{ matrix.platform.cpactions }}
uses: cross-platform-actions/action@v0.25.0
with:
operating_system: ${{ matrix.platform.cpactions-os }}
architecture: ${{ matrix.platform.cpactions-arch }}
version: ${{ matrix.platform.cpactions-version }}
run: |
${{ matrix.platform.cpactions-setup-cmd }}
${{ matrix.platform.cpactions-install-cmd }}
cmake -S . -B build -GNinja \
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-Wdeprecated -Wdev -Werror \
-DSDL_WERROR=${{ matrix.platform.werror }} \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
${{ matrix.platform.cmake-arguments }} \
-DSDL_SHARED=${{ matrix.platform.shared }} \
-DSDL_STATIC=${{ matrix.platform.static }} \
-DSDL_VENDOR_INFO="Github Workflow" \
-DCMAKE_INSTALL_PREFIX=prefix \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --verbose
cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target package
cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target clean
rm -rf build/dist/_CPack_Packages
rm -rf build/CMakeFiles
rm -rf build/docs
- name: Add msbuild to PATH
id: setup-msbuild
if: ${{ matrix.platform.msvc-project != '' }}
uses: microsoft/setup-msbuild@v2
- name: Build msbuild
if: ${{ matrix.platform.msvc-project != '' }}
run: |
"$(cygpath -u '${{ steps.setup-msbuild.outputs.msbuildPath }}\msbuild.exe')" ${{ matrix.platform.msvc-project }} -m -p:BuildInParallel=true -p:Configuration=Release ${{ matrix.platform.msvc-project-flags }}
- name: 'Build (Android.mk)'
if: ${{ matrix.platform.android-mk }}
run: |
./build-scripts/androidbuildlibs.sh
- name: 'Create Gradle project (Android)'
if: ${{ matrix.platform.android-gradle }}
run: |
for folder in build-ndk-build build-cmake; do
python build-scripts/create-android-project.py \
--output "${folder}" \
--variant copy \
org.libsdl.testspriteminimal \
test/testspriteminimal.c test/icon.h
done
echo ""
echo "Project contents:"
echo ""
find "build-ndk-build/org.libsdl.testspriteminimal"
- name: 'Build Android app (Gradle & ndk-build)'
if: ${{ matrix.platform.android-gradle }}
run: |
cd build-ndk-build/org.libsdl.testspriteminimal
./gradlew -i assembleRelease
- name: 'Build Android app (Gradle & CMake)'
if: ${{ matrix.platform.android-gradle }}
run: |
cd build-cmake/org.libsdl.testspriteminimal
./gradlew -i assembleRelease -PBUILD_WITH_CMAKE=1
- name: 'Build (xcode)'
if: ${{ matrix.platform.xcode-sdk != '' }}
run: |
xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3 -configuration Release -sdk ${{ matrix.platform.xcode-sdk }} clean build
- name: 'Setup Python'
uses: 'actions/setup-python@main'
if: ${{ matrix.platform.check-sources }}
with:
python-version: '3.x'
- name: 'Check Sources'
if: ${{ matrix.platform.check-sources }}
run: |
set -e
build-scripts/test-versioning.sh
python build-scripts/check_android_jni.py
python build-scripts/check_stdlib_usage.py
- name: 'Upload binary package'
uses: actions/upload-artifact@v4
if: ${{ always() && matrix.platform.artifact != '' && (steps.package.outcome == 'success' || steps.cpactions.outcome == 'success') && (matrix.platform.enable-artifacts || steps.tests.outcome == 'failure') }}
with:
if-no-files-found: error
name: '${{ matrix.platform.artifact }}'
path: |
build/dist/SDL3*
build/include*
- name: 'Upload minidumps'
uses: actions/upload-artifact@v4
if: ${{ always() && steps.tests.outcome == 'failure' && (matrix.platform.platform == 'msvc' || matrix.platform.platform == 'msys2') }}
with:
if-no-files-found: ignore
name: '${{ matrix.platform.artifact }}-minidumps'
path: build/**/*.dmp
- name: "Upload Android test apk's"
uses: actions/upload-artifact@v4
if: ${{ matrix.platform.enable-artifacts && always() && matrix.platform.artifact != '' && steps.apks.outcome == 'success' }}
with:
if-no-files-found: error
name: '${{ matrix.platform.artifact }}-apks'
path: build/test/*.apk