Add SDL3 support alongside SDL2

Centralize the differences between SDL2 and SDL3 behind compatibility
interfaces and select the appropriate implementations with the
SYSTEM3_SDL_VERSION CMake option. Android remains on SDL2 for now.
This commit is contained in:
kichikuou
2026-09-15 20:37:08 +09:00
parent c10a8aa60e
commit d18abe1125
40 changed files with 1462 additions and 238 deletions
+11 -5
View File
@@ -8,6 +8,10 @@ env:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
sdl-version: [2, 3]
name: Emscripten SDL${{ matrix.sdl-version }}
steps:
- uses: actions/checkout@v6
@@ -32,9 +36,11 @@ jobs:
- name: Build
run: |
mkdir -p out/wasm
cd out/wasm
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=YES ../../
mkdir -p out/wasm-sdl${{ matrix.sdl-version }}
cd out/wasm-sdl${{ matrix.sdl-version }}
emcmake cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_COMPILE_WARNING_AS_ERROR=YES \
-DSYSTEM3_SDL_VERSION=${{ matrix.sdl-version }} ../..
make -j4
mkdir system3
mv system3.* system3/
@@ -42,5 +48,5 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: system3-wasm
path: out/wasm/system3
name: system3-wasm-sdl${{ matrix.sdl-version }}
path: out/wasm-sdl${{ matrix.sdl-version }}/system3
+12 -4
View File
@@ -3,12 +3,13 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04
strategy:
matrix:
build-type: ["Debug", "Release"]
sdl-version: [2, 3]
name: Linux ${{ matrix.build-type }}
name: Linux SDL${{ matrix.sdl-version }} ${{ matrix.build-type }}
steps:
- uses: actions/checkout@v6
with:
@@ -17,11 +18,18 @@ jobs:
- name: Install Deps
run: |
sudo apt update
sudo apt install libsdl2-dev libsdl2-ttf-dev librtmidi-dev nlohmann-json3-dev ninja-build
sudo apt install librtmidi-dev nlohmann-json3-dev ninja-build
if [ "${{ matrix.sdl-version }}" = 2 ]; then
sudo apt install libsdl2-dev libsdl2-ttf-dev
else
sudo apt install libsdl3-dev libsdl3-ttf-dev
fi
- name: Build
run: |
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DSYSTEM3_SDL_VERSION=${{ matrix.sdl-version }}
cmake --build build
- name: Test
+3 -1
View File
@@ -5,6 +5,7 @@ jobs:
build:
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest
name: Nintendo Switch SDL2
steps:
- uses: actions/checkout@v6
@@ -15,7 +16,8 @@ jobs:
run: |
mkdir -p out/switch
cd out/switch
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -DCMAKE_BUILD_TYPE=Release ../../
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake \
-DCMAKE_BUILD_TYPE=Release -DSYSTEM3_SDL_VERSION=2 ../../
make -j4
mkdir system3
mv system3.* system3/
+10 -3
View File
@@ -6,13 +6,20 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
arch: ["Win32", "x64"]
include:
- arch: "Win32"
sdl-version: 2
package: "system3-sdl2-msvc-32bit"
- arch: "x64"
sdl-version: 2
package: "system3-sdl2-msvc-64bit"
name: MSVS ${{ matrix.arch }}
- arch: "Win32"
sdl-version: 3
package: "system3-sdl3-msvc-32bit"
- arch: "x64"
sdl-version: 3
package: "system3-sdl3-msvc-64bit"
name: MSVS SDL${{ matrix.sdl-version }} ${{ matrix.arch }}
steps:
- name: Checkout
@@ -24,7 +31,7 @@ jobs:
run: |
mkdir out
cd out
cmake -A ${{ matrix.arch }} -DCMAKE_COMPILE_WARNING_AS_ERROR=YES ../
cmake -A ${{ matrix.arch }} -DCMAKE_COMPILE_WARNING_AS_ERROR=YES -DSYSTEM3_SDL_VERSION=${{ matrix.sdl-version }} ../
cmake --build . --config Release
cmake --install . --prefix artifacts
cp ../COPYING.txt artifacts/
+14 -4
View File
@@ -10,14 +10,23 @@ jobs:
include:
- sys: mingw32
package: "system3-sdl2-32bit"
sdl-version: 2
sdl-deps: "SDL2:p SDL2_ttf:p"
deps: ""
- sys: ucrt64
package: "system3-sdl2-64bit"
sdl-version: 2
sdl-deps: "SDL2:p SDL2_ttf:p"
deps: "nlohmann-json:p"
- sys: ucrt64
package: "system3-sdl3-64bit"
sdl-version: 3
sdl-deps: "sdl3:p sdl3-ttf:p"
deps: "nlohmann-json:p"
defaults:
run:
shell: msys2 {0}
name: MSYS2 ${{ matrix.sys }}
name: MSYS2 SDL${{ matrix.sdl-version }} ${{ matrix.sys }}
steps:
- name: Set up MSYS2
@@ -25,8 +34,7 @@ jobs:
with:
msystem: ${{ matrix.sys }}
pacboy: >-
SDL2:p
SDL2_ttf:p
${{ matrix.sdl-deps }}
rtmidi:p
${{ matrix.deps }}
@@ -48,7 +56,9 @@ jobs:
- name: Build
run: |
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=YES
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_COMPILE_WARNING_AS_ERROR=YES \
-DSYSTEM3_SDL_VERSION=${{ matrix.sdl-version }}
cmake --build build
- name: Test