summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/.github/workflows/generic.yml
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-3.2.20/.github/workflows/generic.yml')
-rw-r--r--src/contrib/SDL-3.2.20/.github/workflows/generic.yml431
1 files changed, 431 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/.github/workflows/generic.yml b/src/contrib/SDL-3.2.20/.github/workflows/generic.yml
new file mode 100644
index 0000000..c2846ba
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/.github/workflows/generic.yml
@@ -0,0 +1,431 @@
1name: 'Build'
2run-name: 'Configure, Build and Test SDL'
3
4on:
5 workflow_call:
6 inputs:
7 platforms:
8 description: 'JSON-encoded test properties'
9 type: string
10 required: true
11
12jobs:
13 build:
14 name: ${{ matrix.platform.name }}
15 runs-on: ${{ matrix.platform.os }}
16 container: ${{ matrix.platform.container }}
17 defaults:
18 run:
19 shell: ${{ matrix.platform.shell }}
20 strategy:
21 fail-fast: false
22 matrix:
23 platform: ${{ fromJSON(inputs.platforms) }}
24 steps:
25 - name: 'Set up MSYS2'
26 if: ${{ matrix.platform.platform == 'msys2' }}
27 uses: msys2/setup-msys2@v2
28 with:
29 msystem: ${{ matrix.platform.msys2-msystem }}
30 install: >-
31 ${{ matrix.platform.msys2-env }}-cc
32 ${{ matrix.platform.msys2-env }}-cmake
33 ${{ matrix.platform.msys2-env }}-ninja
34 ${{ (!matrix.platform.msys2-no-perl && format('{0}-perl', matrix.platform.msys2-env)) || '' }}
35 ${{ matrix.platform.msys2-env }}-pkg-config
36 ${{ matrix.platform.msys2-env }}-clang-tools-extra
37 ${{ (matrix.platform.ccache && format('{0}-ccache', matrix.platform.msys2-env)) || '' }}
38 - name: 'About this job'
39 run: |
40 echo "key=${{ matrix.platform.key }}"
41 echo "name=${{ matrix.platform.name }}"
42 echo "os=${{ matrix.platform.os }}"
43 echo ""
44 echo "Add [sdl-ci-filter ${{ matrix.platform.key }}] to your commit message to reduce the number of jobs."
45 - uses: actions/checkout@v4
46 - name: 'Set up ninja'
47 if: ${{ matrix.platform.setup-ninja }}
48 uses: ./.github/actions/setup-ninja
49 - name: 'Set up libusb for MSVC'
50 if: ${{ matrix.platform.setup-libusb-arch != '' }}
51 uses: ./.github/actions/setup-msvc-libusb
52 with:
53 arch: ${{ matrix.platform.setup-libusb-arch }}
54 - uses: mymindstorm/setup-emsdk@v14
55 if: ${{ matrix.platform.platform == 'emscripten' }}
56 with:
57 version: 3.1.35
58 - uses: browser-actions/setup-chrome@v1
59 id: setup-chrome
60 if: ${{ matrix.platform.platform == 'emscripten' }}
61 with:
62 install-chromedriver: true
63 - name: 'Add chrome to PATH'
64 if: ${{ matrix.platform.platform == 'emscripten' }}
65 run: |
66 chrome_dir="$(dirname "${{ steps.setup-chrome.outputs.chrome-path }}")"
67 chromedriver_dir="$(dirname "${{ steps.setup-chrome.outputs.chromedriver-path }}")"
68 echo "CHROME_BINARY=${{ steps.setup-chrome.outputs.chrome-path }}" >>$GITHUB_ENV
69 echo "CHROMEDRIVER_BINARY=${{ steps.setup-chrome.outputs.chromedriver-path }}" >>$GITHUB_ENV
70 echo "chrome_dir=${chrome_dir}"
71 echo "chromedriver_dir=${chromedriver_dir}"
72 echo "${chrome_dir}" >>${GITHUB_PATH}
73 echo "${chromedriver_dir}" >>${GITHUB_PATH}
74 - uses: nttld/setup-ndk@v1
75 if: ${{ matrix.platform.android-ndk }}
76 id: setup-ndk
77 with:
78 local-cache: true
79 ndk-version: r21e
80 - name: 'Configure Android NDK variables'
81 if: ${{ matrix.platform.android-ndk }}
82 shell: sh
83 run: |
84 # We cannot use GitHub expressions in the controller job
85 echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >>$GITHUB_ENV
86 - uses: actions/setup-java@v4
87 if: ${{ matrix.platform.java }}
88 with:
89 distribution: 'temurin'
90 java-version: '17'
91 - uses: ilammy/msvc-dev-cmd@v1
92 if: ${{ matrix.platform.platform == 'msvc' }}
93 with:
94 arch: ${{ matrix.platform.msvc-vcvars-arch }}
95 sdk: ${{ matrix.platform.msvc-vcvars-sdk }}
96 - name: 'Set up Windows GDK Desktop'
97 uses: ./.github/actions/setup-gdk-desktop
98 if: ${{ matrix.platform.setup-gdk-folder != '' }}
99 with:
100 folder: '${{ matrix.platform.setup-gdk-folder }}'
101 - name: 'Set up LoongArch64 toolchain'
102 uses: ./.github/actions/setup-loongarch64-toolchain
103 id: setup-loongarch64-toolchain
104 if: ${{ matrix.platform.platform == 'loongarch64' }}
105 - name: 'Setup Intel oneAPI toolchain'
106 id: intel
107 if: ${{ matrix.platform.intel }}
108 run: |
109 # Download the key to system keyring
110 wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
111 | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
112
113 # Add signed entry to apt sources and configure the APT client to use Intel repository:
114 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
115
116 # Update package list
117 sudo apt-get update -y
118
119 # Install oneAPI
120 sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
121 - name: 'Install apk packages'
122 if: ${{ matrix.platform.apk-packages != '' }}
123 run: |
124 ${{ matrix.platform.sudo }} apk update
125 ${{ matrix.platform.sudo }} apk add ${{ matrix.platform.apk-packages }}
126 - name: 'Install apt packages'
127 if: ${{ matrix.platform.apt-packages != '' }}
128 run: |
129 ${{ matrix.platform.sudo }} apt-get update
130 ${{ matrix.platform.sudo }} apt-get install -y ${{ matrix.platform.apt-packages }}
131 - name: 'Install brew packages'
132 if: ${{ matrix.platform.brew-packages != '' }}
133 run: |
134 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
135 brew update
136 brew install ${{ matrix.platform.brew-packages }}
137 - name: 'Setup Python'
138 uses: 'actions/setup-python@main'
139 if: ${{ matrix.platform.setup-python }}
140 with:
141 python-version: '3.x'
142 - name: 'Install PyPI packages'
143 if: ${{ matrix.platform.pypi-packages != '' }}
144 run: |
145 python -m pip install --user ${{ matrix.platform.pypi-packages }}
146 - name: 'Set up GLES for VITA' # Must be after apk
147 if: ${{ matrix.platform.setup-vita-gles-type != '' }}
148 uses: ./.github/actions/setup-vita-gles
149 with:
150 type: ${{ matrix.platform.setup-vita-gles-type }}
151
152 - name: 'Pollute toolchain with "bad" SDL headers'
153 if: ${{ matrix.platform.pollute-directories != '' }}
154 #shell: ${{ matrix.platform.shell }}
155 run: |
156 # Create "bad" SDL headers in the toolchain.
157 # SDL sources should not use these.
158 for include in ${{ matrix.platform.pollute-directories }}; do
159 toolchain_directory="${include}/SDL3"
160 echo "Creating directory ${toolchain_directory}"
161 mkdir -p "${toolchain_directory}/SDL3"
162 for header in include/SDL3/*.h; do
163 dest="${toolchain_directory}/SDL3/$(basename "${header}")"
164 echo "Creating ${dest}"
165 echo '#error "System SDL headers must not be used by build system"' >"$dest"
166 done
167 done
168
169 - name: 'Calculate ccache key'
170 if: ${{ matrix.platform.ccache }}
171 id: prepare-restore-ccache
172 run: |
173 echo "timestamp=$(date -u "+%Y%m%d%H%M_%S")" >> "$GITHUB_OUTPUT"
174 - name: 'Restore ccache'
175 if: ${{ matrix.platform.ccache }}
176 uses: actions/cache/restore@v4
177 id: restore-ccache
178 with:
179 path: ${{ runner.temp }}/ccache
180 key: ccache-${{ matrix.platform.key }}-${{ steps.prepare-restore-ccache.outputs.timestamp }}
181 restore-keys: |
182 ccache-${{matrix.platform.key}}
183 - name: 'Configure ccache'
184 if: ${{ matrix.platform.ccache }}
185 run: |
186 echo 'CCACHE_DIR=${{ runner.temp }}/ccache' >>${GITHUB_ENV}
187 - name: 'Prepare ccache'
188 if: ${{ matrix.platform.ccache && steps.restore-ccache.outputs.cache-hit }}
189 run: |
190 if [ "x${{ runner.os }}" = "xmacOS" ]; then
191 touch_date="2025-02-01T12:00:00Z"
192 else
193 touch_date="2025-02-01"
194 fi
195 find "${CCACHE_DIR}" -type f -exec touch -a -m -d "$touch_date" {} +
196 ccache -s
197 ccache -z
198
199 - name: 'Configure (CMake)'
200 if: ${{ !matrix.platform.no-cmake }}
201 #shell: ${{ matrix.platform.shell }}
202 run: |
203 ${{ matrix.platform.source-cmd }}
204 ${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -G "${{ matrix.platform.cmake-generator }}" \
205 -Wdeprecated -Wdev -Werror \
206 ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
207 -DSDL_WERROR=${{ matrix.platform.werror }} \
208 -DSDL_EXAMPLES=${{ matrix.platform.build-tests }} \
209 -DSDL_TESTS=${{ matrix.platform.build-tests }} \
210 -DSDLTEST_TRACKMEM=ON \
211 -DSDL_INSTALL_TESTS=${{ matrix.platform.build-tests }} \
212 -DSDL_CLANG_TIDY=${{ matrix.platform.clang-tidy }} \
213 -DSDL_INSTALL_DOCS=ON \
214 -DSDL_INSTALL_CPACK=ON \
215 -DSDL_INSTALL_DOCS=ON \
216 ${{ matrix.platform.cmake-arguments }} \
217 -DSDL_SHARED=${{ matrix.platform.shared }} \
218 -DSDL_STATIC=${{ matrix.platform.static }} \
219 -DSDL_VENDOR_INFO="Github Workflow" \
220 -DCMAKE_INSTALL_PREFIX=prefix \
221 -DCMAKE_INSTALL_LIBDIR=lib \
222 -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
223 - name: 'Build (CMake)'
224 id: build
225 if: ${{ !matrix.platform.no-cmake }}
226# shell: ${{ matrix.platform.shell }}
227 run: |
228 ${{ matrix.platform.source-cmd }}
229 cmake --build build --config ${{ matrix.platform.cmake-build-type }} --verbose -- ${{ matrix.platform.cmake-build-arguments }}
230 - name: 'Verify SDL_REVISION'
231 if: ${{ !matrix.platform.no-cmake }}
232 run: |
233 echo "This should show us the SDL_REVISION"
234 echo "Shared library:"
235 ${{ (matrix.platform.shared-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
236 echo "Static library:"
237 ${{ (matrix.platform.static-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
238 - name: 'Run build-time tests (CMake)'
239 id: tests
240 if: ${{ !matrix.platform.no-cmake && matrix.platform.run-tests }}
241# shell: ${{ matrix.platform.shell }}
242 run: |
243 ${{ matrix.platform.source-cmd }}
244 ${{ matrix.platform.pretest-cmd }}
245 set -eu
246 export SDL_TESTS_QUICK=1
247 ctest -VV --test-dir build/ -j2
248 - name: "Build test apk's (CMake)"
249 id: apks
250 if: ${{ always() && steps.build.outcome == 'success' && matrix.platform.android-apks != '' }}
251# shell: ${{ matrix.platform.shell }}
252 run: |
253 ${{ matrix.platform.source-cmd }}
254 cmake --build build --config ${{ matrix.platform.cmake-build-type }} \
255 --target \
256 ${{ matrix.platform.android-apks }} \
257 --verbose \
258 -- ${{ matrix.platform.cmake-build-arguments }}
259 - name: 'Install (CMake)'
260 id: install
261 if: ${{ always() && steps.build.outcome == 'success' }}
262# shell: ${{ matrix.platform.shell }}
263 run: |
264 ${{ matrix.platform.source-cmd }}
265 cmake --install build --config ${{ matrix.platform.cmake-build-type }}
266 echo "prefix=$(pwd)/prefix" >> $GITHUB_OUTPUT
267 ( cd prefix; find . ) | LC_ALL=C sort -u
268 - name: 'Package (CPack)'
269 id: package
270 if: ${{ always() && steps.build.outcome == 'success' }}
271# shell: ${{ matrix.platform.shell }}
272 run: |
273 # DMG creation on macOS occasionally fails, so try multiple times
274 # https://gitlab.kitware.com/cmake/cmake/-/issues/25671
275 success=0
276 max_tries=10
277 for i in $(seq $max_tries); do
278 cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target package -- ${{ matrix.platform.cmake-build-arguments }} && success=1
279 if test $success = 1; then
280 break
281 fi
282 echo "Package creation failed. Sleep 1 second and try again."
283 sleep 1
284 done
285 if test $success = 0; then
286 echo "Package creation failed after $max_tries attempts."
287 exit 1
288 fi
289 - name: 'Verify CMake configuration files'
290 if: ${{ steps.install.outcome == 'success' }}
291# shell: ${{ matrix.platform.shell }}
292 run: |
293 ${{ matrix.platform.source-cmd }}
294 ${{ matrix.platform.cmake-config-emulator }} cmake -S cmake/test -B cmake_test_build -GNinja \
295 ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
296 -DTEST_SHARED=${{ matrix.platform.shared }} \
297 -DTEST_STATIC=${{ matrix.platform.static }} \
298 ${{ matrix.platform.cmake-arguments }} \
299 -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
300 -DCMAKE_PREFIX_PATH="${{ steps.install.outputs.prefix }}"
301 cmake --build cmake_test_build --verbose --config ${{ matrix.platform.cmake-build-type }} -- ${{ matrix.platform.cmake-build-arguments }}
302 - name: 'Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain'
303 if: ${{ steps.install.outcome == 'success' && matrix.platform.cc-from-cmake }}
304# shell: ${{ matrix.platform.shell }}
305 run: |
306 cmake -S .github/cmake -B /tmp/cmake_extract \
307 ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
308 -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
309 -DVAR_PATH=/tmp/env.txt
310 cat /tmp/env.txt >> $GITHUB_ENV
311 - name: 'Verify sdl3.pc'
312# shell: ${{ matrix.platform.shell }}
313 if: ${{ steps.install.outcome == 'success' && matrix.platform.test-pkg-config }}
314 run: |
315 ${{ matrix.platform.source-cmd }}
316 ${{ matrix.platform.cc && format('export CC="{0}"', matrix.platform.cc) || '' }}
317 ${{ matrix.platform.cflags && format('export CFLAGS="{0}"', matrix.platform.cflags) || '' }}
318 ${{ matrix.platform.ldflags && format('export LDFLAGS="{0}"', matrix.platform.ldflags) || '' }}
319 export PKG_CONFIG_PATH=${{ steps.install.outputs.prefix }}/lib/pkgconfig
320 cmake/test/test_pkgconfig.sh
321 - name: 'Build (cross-platform-actions, BSD)'
322 id: cpactions
323 if: ${{ matrix.platform.cpactions }}
324 uses: cross-platform-actions/action@v0.27.0
325 with:
326 operating_system: '${{ matrix.platform.cpactions-os }}'
327 architecture: '${{ matrix.platform.cpactions-arch }}'
328 version: '${{ matrix.platform.cpactions-version }}'
329 run: |
330 ${{ matrix.platform.cpactions-setup-cmd }}
331 ${{ matrix.platform.cpactions-install-cmd }}
332 cmake -S . -B build -GNinja \
333 ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
334 -Wdeprecated -Wdev -Werror \
335 -DSDL_WERROR=${{ matrix.platform.werror }} \
336 -DSDL_INSTALL_DOCS=ON \
337 ${{ matrix.platform.cmake-arguments }} \
338 -DSDL_SHARED=${{ matrix.platform.shared }} \
339 -DSDL_STATIC=${{ matrix.platform.static }} \
340 -DSDL_VENDOR_INFO="Github Workflow" \
341 -DCMAKE_INSTALL_PREFIX=prefix \
342 -DCMAKE_INSTALL_LIBDIR=lib \
343 -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
344 cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --verbose
345 cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target package
346
347 cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target clean
348 rm -rf build/dist/_CPack_Packages
349 rm -rf build/CMakeFiles
350 rm -rf build/docs
351 - name: Add msbuild to PATH
352 id: setup-msbuild
353 if: ${{ matrix.platform.msvc-project != '' }}
354 uses: microsoft/setup-msbuild@v2
355 - name: Build msbuild
356 if: ${{ matrix.platform.msvc-project != '' }}
357 run: |
358 "$(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 }}
359 - name: 'Build (Android.mk)'
360 if: ${{ matrix.platform.android-mk }}
361 run: |
362 ./build-scripts/androidbuildlibs.sh
363 - name: 'Create Gradle project (Android)'
364 if: ${{ matrix.platform.android-gradle }}
365 run: |
366 for folder in build-ndk-build build-cmake; do
367 python build-scripts/create-android-project.py \
368 --output "${folder}" \
369 --variant copy \
370 org.libsdl.testspriteminimal \
371 test/testspriteminimal.c test/icon.h
372 done
373 echo ""
374 echo "Project contents:"
375 echo ""
376 find "build-ndk-build/org.libsdl.testspriteminimal"
377 - name: 'Build Android app (Gradle & ndk-build)'
378 if: ${{ matrix.platform.android-gradle }}
379 run: |
380 cd build-ndk-build/org.libsdl.testspriteminimal
381 ./gradlew -i assembleRelease
382 - name: 'Build Android app (Gradle & CMake)'
383 if: ${{ matrix.platform.android-gradle }}
384 run: |
385 cd build-cmake/org.libsdl.testspriteminimal
386 ./gradlew -i assembleRelease -PBUILD_WITH_CMAKE=1
387 - name: 'Build (xcode)'
388 if: ${{ matrix.platform.xcode-sdk != '' }}
389 run: |
390 xcodebuild -project Xcode/SDL/SDL.xcodeproj -target SDL3 -configuration Release -sdk ${{ matrix.platform.xcode-sdk }} clean build
391 - name: 'Prune old ccache files'
392 if: ${{ matrix.platform.ccache }}
393 run: |
394 ccache --evict-older-than=1d
395 ccache -s
396 - name: 'Save ccache'
397 if: ${{ matrix.platform.ccache }}
398 uses: actions/cache/save@v4
399 with:
400 path: ${{ runner.temp }}/ccache
401 key: ${{ steps.restore-ccache.outputs.cache-primary-key }}
402 - name: 'Check Sources'
403 if: ${{ matrix.platform.check-sources }}
404 run: |
405 set -e
406 build-scripts/test-versioning.sh
407 python build-scripts/check_android_jni.py
408 python build-scripts/check_stdlib_usage.py
409 - name: 'Upload binary package'
410 uses: actions/upload-artifact@v4
411 if: ${{ always() && matrix.platform.artifact != '' && (steps.package.outcome == 'success' || steps.cpactions.outcome == 'success') && (matrix.platform.enable-artifacts || steps.tests.outcome == 'failure') }}
412 with:
413 if-no-files-found: error
414 name: '${{ matrix.platform.artifact }}'
415 path: |
416 build/dist/SDL3*
417 build/include*
418 - name: 'Upload minidumps'
419 uses: actions/upload-artifact@v4
420 if: ${{ always() && steps.tests.outcome == 'failure' && (matrix.platform.platform == 'msvc' || matrix.platform.platform == 'msys2') }}
421 with:
422 if-no-files-found: ignore
423 name: '${{ matrix.platform.artifact }}-minidumps'
424 path: build/**/*.dmp
425 - name: "Upload Android test apk's"
426 uses: actions/upload-artifact@v4
427 if: ${{ matrix.platform.enable-artifacts && always() && matrix.platform.artifact != '' && steps.apks.outcome == 'success' }}
428 with:
429 if-no-files-found: error
430 name: '${{ matrix.platform.artifact }}-apks'
431 path: build/test/*.apk \ No newline at end of file