SDL_gesture: Use libsdl-org/setup-sdl + private setup-ninja action

From dfd3001d3bf0cac291384f225aa6ca48c39a2e89 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 6 Nov 2025 22:02:58 +0100
Subject: [PATCH] Use libsdl-org/setup-sdl + private setup-ninja action

---
 .github/actions/setup-ninja/action.yml | 62 +++++++++++++++++++++++++
 .github/fetch_sdl_vc.ps1               | 40 ----------------
 .github/workflows/main.yml             | 63 +++++++++-----------------
 3 files changed, 83 insertions(+), 82 deletions(-)
 create mode 100644 .github/actions/setup-ninja/action.yml
 delete mode 100644 .github/fetch_sdl_vc.ps1

diff --git a/.github/actions/setup-ninja/action.yml b/.github/actions/setup-ninja/action.yml
new file mode 100644
index 0000000..b5d5fad
--- /dev/null
+++ b/.github/actions/setup-ninja/action.yml
@@ -0,0 +1,62 @@
+name: 'Setup ninja'
+description: 'Download ninja and add it to the PATH environment variable'
+inputs:
+  version:
+    description: 'Ninja version'
+    default: '1.12.1'
+runs:
+  using: 'composite'
+  steps:
+    - name: 'Calculate variables'
+      id: calc
+      shell: sh
+      run: |
+        case "${{ runner.os }}-${{ runner.arch }}" in
+          "Linux-X86" | "Linux-X64")
+            archive="ninja-linux.zip"
+            ;;
+          "Linux-ARM64")
+            archive="ninja-linux-aarch64.zip"
+            ;;
+          "macOS-X86" | "macOS-X64" | "macOS-ARM64")
+            archive="ninja-mac.zip"
+            ;;
+          "Windows-X86" | "Windows-X64")
+            archive="ninja-win.zip"
+            ;;
+          "Windows-ARM64")
+            archive="ninja-winarm64.zip"
+            ;;
+          *)
+            echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
+            exit 1;
+            ;;
+        esac
+        echo "archive=${archive}" >> ${GITHUB_OUTPUT}
+        echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
+    - name: 'Restore cached ${{ steps.calc.outputs.archive }}'
+      id: cache-restore
+      uses: actions/cache/restore@v4
+      with:
+        path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
+        key: ${{ steps.calc.outputs.cache-key }}
+    - name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
+      if: ${{ (!steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false') }}
+      shell: pwsh
+      run: |
+        Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
+    - name: 'Cache ${{ steps.calc.outputs.archive }}'
+      if: ${{ (!steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false') }}
+      uses: actions/cache/save@v4
+      with:
+        path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
+        key: ${{ steps.calc.outputs.cache-key }}
+    - name: 'Extract ninja'
+      shell: pwsh
+      run: |
+        7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
+    - name: 'Set output variables'
+      id: final
+      shell: pwsh
+      run: |
+        echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH
diff --git a/.github/fetch_sdl_vc.ps1 b/.github/fetch_sdl_vc.ps1
deleted file mode 100644
index 84eec24..0000000
--- a/.github/fetch_sdl_vc.ps1
+++ /dev/null
@@ -1,40 +0,0 @@
-$ErrorActionPreference = "Stop"
-
-$project_root = "$psScriptRoot\.."
-Write-Output "project_root: $project_root"
-
-$sdl2_version = "2.0.10"
-$sdl2_zip = "SDL2-devel-$($sdl2_version)-VC.zip"
-
-$sdl2_url = "https://github.com/libsdl-org/SDL/releases/download/release-$($sdl2_version)/SDL2-devel-$($sdl2_version)-VC.zip"
-$sdl2_dlpath = "$($Env:TEMP)\$sdl2_zip"
-
-$sdl2_bindir = "$($project_root)"
-$sdl2_extractdir = "$($sdl2_bindir)\SDL2-$($sdl2_version)"
-$sdl2_root_name = "SDL2-devel-VC"
-
-echo "sdl2_bindir:     $sdl2_bindir"
-echo "sdl2_extractdir: $sdl2_extractdir"
-echo "sdl2_root_name:  $sdl2_root_name"
-
-echo "Cleaning previous artifacts"
-if (Test-Path $sdl2_extractdir) {
-    Remove-Item $sdl2_extractdir -Recurse -Force
-}
-if (Test-Path "$($sdl2_bindir)/$sdl2_root_name") {
-    Remove-Item "$($sdl2_bindir)/$sdl2_root_name" -Recurse -Force
-}
-if (Test-Path $sdl2_dlpath) {
-    Remove-Item $sdl2_dlpath -Force
-}
-
-Write-Output "Downloading $sdl2_url"
-Invoke-WebRequest -Uri $sdl2_url -OutFile $sdl2_dlpath
-
-Write-Output "Extracting archive"
-Expand-Archive $sdl2_dlpath -DestinationPath $sdl2_bindir
-
-Write-Output "Setting up SDL2 folder"
-Rename-Item $sdl2_extractdir $sdl2_root_name
-
-Write-Output "Done"
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index dbe19fd..7e57ec2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -22,71 +22,50 @@ jobs:
         - { name: Macos,             os: macos-latest,   shell: sh }
 
     steps:
+    - uses: actions/checkout@v5
+    - name: Set up ninja
+      if: ${{ !contains(matrix.platform.shell, 'msys2') }}
+      uses: ./.github/actions/setup-ninja
+
+    - uses: ilammy/msvc-dev-cmd@v1
+      if: "matrix.platform.msvc"
+      with:
+          arch: x64
     - name: Set up MSYS2
       if: matrix.platform.shell == 'msys2 {0}'
       uses: msys2/setup-msys2@v2
       with:
         msystem: ${{ matrix.platform.msystem }}
         install: >-
-          ${{ matrix.platform.msys-env }}-SDL2
           ${{ matrix.platform.msys-env }}-cmake
           ${{ matrix.platform.msys-env }}-gcc
           ${{ matrix.platform.msys-env }}-ninja
-    - name: Setup Macos dependencies
-      if: runner.os == 'macOS'
-      run: |
-        brew install \
-          sdl2 \
-          ninja \
-          ${NULL+}
-    - name: Setup Linux dependencies
-      if: runner.os == 'Linux'
-      run: |
-        sudo apt-get update
-        sudo apt-get -y install \
-          cmake \
-          libsdl2-dev \
-          ninja-build \
-          pkg-config \
-          ${NULL+}
-    - uses: actions/checkout@v4
-    - name: Setup MSVC dependencies
-      if: "matrix.platform.msvc"
-      shell: pwsh
-      run: |
-        echo "::group::Downloading SDL"
-        .github/fetch_sdl_vc.ps1
-        echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/SDL2-devel-VC" >> $Env:GITHUB_ENV
-        echo "::endgroup::"
-    - name: Setup Ninja for MSVC
-      if: "matrix.platform.msvc"
-      uses: ashutoshvarma/setup-ninja@master
-      with:
-        version: 1.10.2
-    - uses: ilammy/msvc-dev-cmd@v1
-      if: "matrix.platform.msvc"
+    - name: Set up SDL3
+      uses: libsdl-org/setup-sdl@main
       with:
-        arch: x64
+        cmake-arguments: '-DSDL_X11=OFF -DSDL_WAYLAND=OFF -DSDL_UNIX_CONSOLE_BUILD=ON'  # For ci purposes, we're ok with a SDL3 without X11/Wayland
+        cmake-generator: Ninja
+        version: 3-head
+        shell: ${{ matrix.platform.shell }}
 
     - name: Configure (CMake)
       run: |
-        cmake -S . -B build \
+        cmake -S . -B build -GNinja \
           -DSDLGESTURE_TESTS=ON \
-          -DCMAKE_BUILD_TYPE=Release \
+          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
           -DCMAKE_INSTALL_PREFIX=prefix
     - name: Build (CMake)
       run: |
-        cmake --build build/ --config Release --parallel --verbose
+        cmake --build build/ --parallel --verbose
     - name: Install (CMake)
       run: |
         set -eu
-        rm -fr prefix_cmake
-        cmake --install build/ --config Release
+        cmake --install build/
         ( cd prefix; find . ) | LC_ALL=C sort -u
 
     - name: Verify CMake configuration files
       run: |
-        cmake -S test -B cmake_config_build \
-          -DCMAKE_BUILD_TYPE=Release \
+        cmake -S test -B cmake_config_build -GNinja \
+          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
           -DCMAKE_PREFIX_PATH="$PWD/prefix"
         cmake --build cmake_config_build --verbose --config Release