SDL_image: ci: update SDL2 -> SDL3

From ee60c55d3fab3bccb5ed7414ade58a5aa5638367 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 5 Jan 2023 17:06:53 +0100
Subject: [PATCH] ci: update SDL2 -> SDL3

---
 .github/workflows/main.yml | 148 ++++++++-----------------------------
 1 file changed, 29 insertions(+), 119 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b4975f17..4d31d4fe 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -15,15 +15,12 @@ jobs:
       fail-fast: false
       matrix:
         platform:
-        - { name: Windows (MSVC+CMake),         os: windows-latest, shell: sh,   cmake: '-DSDL2IMAGE_VENDORED=ON -GNinja', msvc: 1, shared: 1, static: 0 }
-        - { name: Windows (mingw32+autotools),  os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, shared: 1, static: 1 }
-        - { name: Windows (mingw64+CMake),      os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0,
-            cmake: '-DSDL2IMAGE_BACKEND_STB=OFF -DSDL2IMAGE_BACKEND_WIC=OFF -DSDL2IMAGE_VENDORED=OFF -DSDL2IMAGE_AVIF=ON -G "Ninja Multi-Config"' }
-        - { name: Linux (autotools),            os: ubuntu-20.04,   shell: sh, shared: 1, static: 1}
-        - { name: Linux (CMake),                os: ubuntu-20.04,   shell: sh,  cmake: '-DSDL2IMAGE_VENDORED=ON -GNinja', shared: 1, static: 0 }
-        - { name: 'Linux (CMake, static)',      os: ubuntu-20.04,   shell: sh,   cmake: '-DSDL2IMAGE_VENDORED=ON -DBUILD_SHARED_LIBS=OFF -GNinja', shared: 0, static: 1 }
-        - { name: Macos (autotools),            os: macos-latest,   shell: sh, shared: 1, static: 1 }
-        - { name: Macos (CMake),                os: macos-latest,   shell: sh,   cmake: '-DSDL2IMAGE_VENDORED=ON -GNinja', shared: 1, static: 0 }
+        - { name: Windows (MSVC),    os: windows-latest, shell: sh,  cmake: '-DSDL3IMAGE_VENDORED=ON -GNinja', msvc: 1, shared: 1, static: 0 }
+        - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, shared: 1, static: 0,
+            cmake: '-DSDL3IMAGE_BACKEND_STB=OFF -DSDL3IMAGE_BACKEND_WIC=OFF -DSDL3IMAGE_VENDORED=OFF -DSDL3IMAGE_AVIF=ON -G "Ninja Multi-Config"' }
+        - { name: Linux,             os: ubuntu-20.04,   shell: sh,  cmake: '-DSDL3IMAGE_VENDORED=ON -GNinja', shared: 1, static: 0 }
+        - { name: 'Linux (static)',  os: ubuntu-20.04,   shell: sh,  cmake: '-DSDL3IMAGE_VENDORED=ON -DBUILD_SHARED_LIBS=OFF -GNinja', shared: 0, static: 1 }
+        - { name: Macos,             os: macos-latest,   shell: sh,  cmake: '-DSDL3IMAGE_VENDORED=ON -GNinja', shared: 1, static: 0 }
 
     steps:
     - name: Set up MSYS2
@@ -32,8 +29,7 @@ jobs:
       with:
         msystem: ${{ matrix.platform.msystem }}
         install: >-
-          ${{ matrix.platform.msys-env }}-SDL2
-          ${{ matrix.platform.msys-env }}-autotools
+          ${{ matrix.platform.msys-env }}-SDL3
           ${{ matrix.platform.msys-env }}-cmake
           ${{ matrix.platform.msys-env }}-gcc
           ${{ matrix.platform.msys-env }}-libavif
@@ -49,8 +45,6 @@ jobs:
       if: runner.os == 'macOS'
       run: |
           brew install \
-            autoconf \
-            automake \
             jpeg \
             libavif \
             libpng \
@@ -61,20 +55,17 @@ jobs:
             webp \
             zlib \
             ${NULL+}
-          brew install sdl2
+          brew install sdl3
     - name: Setup Linux dependencies
       if: runner.os == 'Linux'
       run: |
         sudo apt-get update
         sudo apt-get -y install \
-          autoconf \
-          automake \
           cmake \
           libjpeg-dev \
           libpng-dev \
-          libsdl2-dev \
+          libSDL3-dev \
           libtiff-dev \
-          libtool \
           libwebp-dev \
           ninja-build \
           pkg-config \
@@ -90,7 +81,7 @@ jobs:
       shell: pwsh
       run: |
         .github/fetch_sdl_vc.ps1
-        echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/SDL2-devel-VC" >> $Env:GITHUB_ENV
+        echo "SDL3_DIR=$Env:GITHUB_WORKSPACE/SDL3-devel-VC" >> $Env:GITHUB_ENV
     - name: Setup Ninja for MSVC
       if: "matrix.platform.msvc"
       uses: ashutoshvarma/setup-ninja@master
@@ -102,47 +93,44 @@ jobs:
         arch: x64
 
     - name: Check that versioning is consistent
-      # We only need to run this once: arbitrarily use the Linux/CMake build
-      if: "runner.os == 'Linux' && matrix.platform.cmake"
+      # We only need to run this once: arbitrarily use the Linux build
+      if: "runner.os == 'Linux'"
       run: ./test-versioning.sh
 
-    - name: Setup (CMake)
-      if: ${{ matrix.platform.cmake && !matrix.platform.msystem && !matrix.platform.msvc }}
+    - name: Setup
+      if: ${{ !matrix.platform.msystem && !matrix.platform.msvc }}
       uses: jwlawson/actions-setup-cmake@v1.12
       with:
         cmake-version: '3.16'
-    - name: Configure (CMake)
-      if: "matrix.platform.cmake"
+    - name: Configure
       run: |
         set -- \
           -DBUILD_SHARED_LIBS=ON \
           -DCMAKE_BUILD_TYPE=Release \
-          -DSDL2IMAGE_SAMPLES=ON \
-          -DSDL2IMAGE_TESTS_INSTALL=ON \
-          -DSDL2IMAGE_JXL=ON \
-          -DSDL2IMAGE_TIF=ON \
-          -DSDL2IMAGE_WEBP=ON \
+          -DSDL3IMAGE_SAMPLES=ON \
+          -DSDL3IMAGE_TESTS_INSTALL=ON \
+          -DSDL3IMAGE_JXL=ON \
+          -DSDL3IMAGE_TIF=ON \
+          -DSDL3IMAGE_WEBP=ON \
           -DCMAKE_INSTALL_PREFIX=prefix_cmake \
           ${NULL+}
 
         if [ "${{ matrix.platform.msystem }}" = "" ]; then
-            # mingw-w64-*-SDL2 doesn't have SDL_test, and the macOS CMake
+            # mingw-w64-*-SDL3 doesn't have SDL_test, and the macOS CMake
             # build can't find it (see #260), so we only enable build-time
             # tests for Linux at the moment.
-            set -- "$@" -DSDL2IMAGE_TESTS=ON
+            set -- "$@" -DSDL3IMAGE_TESTS=ON
             # If we dlopen() vendored soft dependencies, the test won't
             # find them: https://github.com/libsdl-org/SDL_image/issues/259
-            set -- "$@" -DSDL2IMAGE_DEPS_SHARED=OFF
+            set -- "$@" -DSDL3IMAGE_DEPS_SHARED=OFF
         fi
 
         cmake -B build \
           "$@" \
           ${{ matrix.platform.cmake }}
     - name: Build (CMake)
-      if: "matrix.platform.cmake"
       run: cmake --build build/ --config Release --parallel --verbose
-    - name: Run build-time tests (CMake)
-      if: "runner.os == 'Linux' && matrix.platform.cmake"
+    - name: Run build-time tests
       run: |
         set -eu
 
@@ -171,15 +159,15 @@ jobs:
 
         ctest -VV --test-dir build/test
     - name: Install (CMake)
-      if: "(matrix.platform.shell == 'sh' || contains(matrix.platform.shell, 'msys2')) && matrix.platform.cmake"
+      if: "matrix.platform.shell == 'sh' || contains(matrix.platform.shell, 'msys2')"
       run: |
         set -eu
         rm -fr DESTDIR-cmake
         cmake --install build/ --config Release
-        echo "SDL2_image_DIR=$(pwd)/prefix_cmake" >> $GITHUB_ENV
+        echo "SDL3_image_DIR=$(pwd)/prefix_cmake" >> $GITHUB_ENV
         ( cd prefix_cmake; find . ) | LC_ALL=C sort -u
-    - name: Upload artifacts (CMake)
-      if: "failure() && runner.os == 'Linux' && matrix.platform.cmake"
+    - name: Upload artifacts
+      if: "failure() && runner.os == 'Linux'"
       uses: actions/upload-artifact@v3
       with:
         name: "${{ matrix.platform.name }} artifacts"
@@ -189,89 +177,11 @@ jobs:
           build/test/*.png
         if-no-files-found: ignore
 
-    - name: Configure (Autotools)
-      if: "! matrix.platform.cmake"
-      run: |
-        set -eu
-        rm -fr build-autotools
-        mkdir build-autotools
-        ./autogen.sh
-        # We do the CMake build with stb_image and the Autotools build without
-        set -- --disable-stb-image --prefix=$(pwd)/prefix_autotools
-        # mingw-w64-*-SDL2 doesn't have SDL_test, so only build this on Unix
-        if [ "${{ matrix.platform.shell }}" = 'sh' ]; then
-          set -- "$@" --enable-tests
-          set -- "$@" --enable-installed-tests
-        fi
-        ( cd build-autotools && ../configure "$@" )
-    - name: Build (Autotools)
-      if: "! matrix.platform.cmake"
-      run: |
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools V=1
-    - name: Run build-time tests (Autotools)
-      if: "! matrix.platform.cmake"
-      run: |
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-
-        # Expect to support all formats except AVIF and JXL in these builds.
-        # See test/README.md for how this works.
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_AVIF=0
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_BMP=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_CUR=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_GIF=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_ICO=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_JPG=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_JXL=0
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_LBM=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_PCX=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_PNG=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_PNM=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_QOI=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_SVG=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_TGA=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_TIF=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_WEBP=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_XPM=1
-        export SDL_IMAGE_TEST_REQUIRE_LOAD_XV=1
-
-        export SDL_IMAGE_TEST_REQUIRE_SAVE_JPG=1
-        export SDL_IMAGE_TEST_REQUIRE_SAVE_PNG=1
-
-        make -j"${parallel}" -C build-autotools check V=1 VERBOSE=1
-    - name: Install (Autotools)
-      if: "! matrix.platform.cmake"
-      run: |
-        set -eu
-        curdir="$(pwd)"
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools install V=1
-        echo "SDL2_image_DIR=$(pwd)/prefix_autotools" >> $GITHUB_ENV
-        ( cd prefix_autotools; find . ) | LC_ALL=C sort -u
-    - name: Distcheck (Autotools)
-      if: "runner.os == 'Linux' && ! matrix.platform.cmake"
-      run: |
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools distcheck V=1
-    - name: Upload artifacts (Autotools)
-      if: "failure() && ! matrix.platform.cmake"
-      uses: actions/upload-artifact@v3
-      with:
-        name: ${{ matrix.platform.name }} artifacts
-        path: |
-          build-autotools/test/*.bmp
-          build-autotools/test/*.jpg
-          build-autotools/test/*.log
-          build-autotools/test/*.png
-        if-no-files-found: ignore
     - name: Verify CMake configuration files
       run: |
           cmake -S cmake/test -B cmake_config_build \
             -DCMAKE_BUILD_TYPE=Release \
-            -DCMAKE_PREFIX_PATH="${{ env.SDL2_image_DIR }};${{ env.SDL2_DIR }}" \
+            -DCMAKE_PREFIX_PATH="${{ env.SDL3_image_DIR }};${{ env.SDL3_DIR }}" \
             -DTEST_SHARED=${{ matrix.platform.shared }} \
             -DTEST_STATIC=${{ matrix.platform.static }}
           cmake --build cmake_config_build --verbose