From 6aaedb813fa11ba0679c3051bc2eb28646b9506c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 30 Aug 2025 16:53:58 -0700 Subject: Update to SDL3 --- .../SDL-3.2.20/.github/PULL_REQUEST_TEMPLATE.md | 7 + .../.github/actions/setup-gdk-desktop/action.yml | 82 ++ .../actions/setup-loongarch64-toolchain/action.yml | 53 ++ .../.github/actions/setup-msvc-libusb/action.yml | 71 ++ .../.github/actions/setup-ninja/action.yml | 62 ++ .../.github/actions/setup-vita-gles/action.yml | 93 +++ .../SDL-3.2.20/.github/cmake/CMakeLists.txt | 16 + src/contrib/SDL-3.2.20/.github/workflows/build.yml | 48 ++ .../.github/workflows/create-test-plan.py | 870 +++++++++++++++++++++ .../SDL-3.2.20/.github/workflows/generic.yml | 431 ++++++++++ .../SDL-3.2.20/.github/workflows/release.yml | 652 +++++++++++++++ 11 files changed, 2385 insertions(+) create mode 100644 src/contrib/SDL-3.2.20/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 src/contrib/SDL-3.2.20/.github/actions/setup-gdk-desktop/action.yml create mode 100644 src/contrib/SDL-3.2.20/.github/actions/setup-loongarch64-toolchain/action.yml create mode 100644 src/contrib/SDL-3.2.20/.github/actions/setup-msvc-libusb/action.yml create mode 100644 src/contrib/SDL-3.2.20/.github/actions/setup-ninja/action.yml create mode 100644 src/contrib/SDL-3.2.20/.github/actions/setup-vita-gles/action.yml create mode 100644 src/contrib/SDL-3.2.20/.github/cmake/CMakeLists.txt create mode 100644 src/contrib/SDL-3.2.20/.github/workflows/build.yml create mode 100755 src/contrib/SDL-3.2.20/.github/workflows/create-test-plan.py create mode 100644 src/contrib/SDL-3.2.20/.github/workflows/generic.yml create mode 100644 src/contrib/SDL-3.2.20/.github/workflows/release.yml (limited to 'src/contrib/SDL-3.2.20/.github') diff --git a/src/contrib/SDL-3.2.20/.github/PULL_REQUEST_TEMPLATE.md b/src/contrib/SDL-3.2.20/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..533be85 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + + +## Description + + +## Existing Issue(s) + diff --git a/src/contrib/SDL-3.2.20/.github/actions/setup-gdk-desktop/action.yml b/src/contrib/SDL-3.2.20/.github/actions/setup-gdk-desktop/action.yml new file mode 100644 index 0000000..10427ac --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/actions/setup-gdk-desktop/action.yml @@ -0,0 +1,82 @@ +name: 'Setup GDK (Game Development Kit) for Windows Desktop' +description: 'Download GDK and install into MSBuild' +inputs: + # Keep edition and ref in sync! + edition: + description: 'GDK edition' + default: '240601' # YYMMUU (Year Month Update) + ref: + description: 'Git reference' + default: 'June_2024_Update_1' + folder: + description: 'Folder where to create Directory.Build.props' + required: true + default: '${{ github.workspace }}' +runs: + using: 'composite' + steps: + - uses: actions/setup-python@main + with: + python-version: 3.x + - name: 'Calculate variables' + id: calc + shell: pwsh + run: | + $vs_folder=@(vswhere -latest -property installationPath) + echo "vs-folder=${vs_folder}" >> $Env:GITHUB_OUTPUT + + echo "gdk-path=${{ runner.temp }}\GDK-${{ inputs.edition }}" >> $Env:GITHUB_OUTPUT + + echo "cache-key=gdk-${{ inputs.ref }}-${{ inputs.edition }}" >> $Env:GITHUB_OUTPUT + - name: 'Restore cached GDK' + id: cache-restore + uses: actions/cache/restore@v4 + with: + path: '${{ steps.calc.outputs.gdk-path }}' + key: ${{ steps.calc.outputs.cache-key }} + - name: 'Download GDK' + if: ${{ !steps.cache-restore.outputs.cache-hit }} + shell: pwsh + run: | + python build-scripts/setup-gdk-desktop.py ` + --download ` + --temp-folder "${{ runner.temp }}" ` + --gdk-path="${{ steps.calc.outputs.gdk-path }}" ` + --ref-edition "${{ inputs.ref }},${{ inputs.edition }}" ` + --vs-folder="${{ steps.calc.outputs.vs-folder }}" ` + --no-user-props + - name: 'Extract GDK' + if: ${{ !steps.cache-restore.outputs.cache-hit }} + shell: pwsh + run: | + python build-scripts/setup-gdk-desktop.py ` + --extract ` + --ref-edition "${{ inputs.ref }},${{ inputs.edition }}" ` + --temp-folder "${{ runner.temp }}" ` + --gdk-path="${{ steps.calc.outputs.gdk-path }}" ` + --vs-folder="${{ steps.calc.outputs.vs-folder }}" ` + --no-user-props + - name: 'Cache GDK' + if: ${{ !steps.cache-restore.outputs.cache-hit }} + uses: actions/cache/save@v4 + with: + path: '${{ steps.calc.outputs.gdk-path }}' + key: ${{ steps.calc.outputs.cache-key }} + - name: 'Copy MSBuild files into GDK' + shell: pwsh + run: | + python build-scripts/setup-gdk-desktop.py ` + --ref-edition "${{ inputs.ref }},${{ inputs.edition }}" ` + --gdk-path="${{ steps.calc.outputs.gdk-path }}" ` + --vs-folder="${{ steps.calc.outputs.vs-folder }}" ` + --copy-msbuild ` + --no-user-props + - name: 'Write user props' + shell: pwsh + run: | + python build-scripts/setup-gdk-desktop.py ` + --ref-edition "${{ inputs.ref }},${{ inputs.edition }}" ` + --temp-folder "${{ runner.temp }}" ` + --vs-folder="${{ steps.calc.outputs.vs-folder }}" ` + --gdk-path="${{ steps.calc.outputs.gdk-path }}" ` + "--props-folder=${{ inputs.folder }}" diff --git a/src/contrib/SDL-3.2.20/.github/actions/setup-loongarch64-toolchain/action.yml b/src/contrib/SDL-3.2.20/.github/actions/setup-loongarch64-toolchain/action.yml new file mode 100644 index 0000000..e7f9ddc --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/actions/setup-loongarch64-toolchain/action.yml @@ -0,0 +1,53 @@ +name: 'Setup LoongArch64 toolchain' +description: 'Download Linux LoongArch64 toolchain and set output variables' +inputs: + version: + description: 'LoongArch64 version' + default: '2023.08.08' +outputs: + prefix: + description: "LoongArch toolchain prefix" + value: ${{ steps.final.outputs.prefix }} + cc: + description: "LoongArch C compiler" + value: ${{ steps.final.outputs.cc }} + cxx: + description: "LoongArch C++ compiler" + value: ${{ steps.final.outputs.cxx }} +runs: + using: 'composite' + steps: + - uses: actions/cache/restore@v4 + id: restore-cache + with: + path: /opt/cross-tools + key: loongarch64-${{ inputs.version }} + + - name: 'Download LoongArch64 gcc+glibc toolchain' + if: ${{ !steps.restore-cache.outputs.cache-hit }} + shell: bash + run: | + url="https://github.com/loongson/build-tools/releases/download/${{ inputs.version }}/CLFS-loongarch64-8.1-x86_64-cross-tools-gcc-glibc.tar.xz" + + wget "$url" -O /tmp/toolchain.tar.xz + + mkdir -p /opt + tar -C /opt -x -f /tmp/toolchain.tar.xz + + - uses: actions/cache/save@v4 + if: ${{ !steps.restore-cache.outputs.cache-hit }} + with: + path: /opt/cross-tools + key: loongarch64-${{ inputs.version }} + - name: 'Set output vars' + id: final + shell: bash + run: | + prefix=/opt/cross-tools + echo "prefix=${prefix}" >> $GITHUB_OUTPUT + cc="${prefix}/bin/loongarch64-unknown-linux-gnu-gcc" + cxx="${prefix}/bin/loongarch64-unknown-linux-gnu-g++" + echo "cc=${cc}" >> $GITHUB_OUTPUT + echo "cxx=${cxx}" >> $GITHUB_OUTPUT + echo "LOONGARCH64_CC=${cc}" >>$GITHUB_ENV + echo "LOONGARCH64_CXX=${cxx}" >>$GITHUB_ENV diff --git a/src/contrib/SDL-3.2.20/.github/actions/setup-msvc-libusb/action.yml b/src/contrib/SDL-3.2.20/.github/actions/setup-msvc-libusb/action.yml new file mode 100644 index 0000000..cbbf098 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/actions/setup-msvc-libusb/action.yml @@ -0,0 +1,71 @@ +name: 'Setup libusb for MSVC' +description: 'Download libusb sdk for MSVC, and set output/environment variables' +inputs: + version: + description: 'libusb version' + required: true + default: '1.0.27' + arch: + description: "libusb architecture (x86 or x64)" + rqeuired: true +outputs: + root: + description: "libusb root directory" + value: ${{ steps.final.outputs.root }} +runs: + using: 'composite' + steps: + - name: 'Restore cached libusb-${{ inputs.version }}.7z' + id: cache-restore + uses: actions/cache/restore@v4 + with: + path: 'C:\temp\libusb-${{ inputs.version }}.7z' + key: libusb-msvc-${{ inputs.version }} + - name: 'Download libusb ${{ inputs.version }}' + if: ${{ !steps.cache-restore.outputs.cache-hit }} + shell: pwsh + run: | + Invoke-WebRequest "https://github.com/libusb/libusb/releases/download/v${{ inputs.version }}/libusb-${{ inputs.version }}.7z" -OutFile "C:\temp\libusb-${{ inputs.version }}.7z" + - name: 'Cache libusb-${{ inputs.version }}.7z' + if: ${{ !steps.cache-restore.outputs.cache-hit }} + uses: actions/cache/save@v4 + with: + path: 'C:\temp\libusb-${{ inputs.version }}.7z' + key: libusb-msvc-${{ inputs.version }} + - name: 'Extract libusb' + shell: pwsh + run: | + 7z "-oC:\temp\libusb-${{ inputs.version }}" x "C:\temp\libusb-${{ inputs.version }}.7z" + - name: 'Set output vars' + id: final + shell: pwsh + run: | + if ('${{ inputs.arch }}' -eq 'x86') { + $archdir = "MS32"; + } elseif ('${{ inputs.arch }}' -eq 'x64') { + $archdir = "MS64"; + } else { + write-host "Invalid arch=${{ inputs.arch }}" + exit 1 + } + $libusb_incdir = "C:\temp\libusb-${{ inputs.version }}\include"; + $libusb_libdir = "C:\temp\libusb-${{ inputs.version }}\VS2022\${archdir}\dll"; + + $libusb_header = "${libusb_incdir}\libusb.h"; + $libusb_implib = "${libusb_libdir}\libusb-1.0.lib"; + $libusb_dll = "${libusb_libdir}\libusb-1.0.dll"; + + if (!(Test-Path "${libusb_header}")) { + write-host "${libusb_header} does not exist!" + exit 1 + } + if (!(Test-Path "${libusb_implib}")){ + write-host "${libusb_implib} does not exist!" + exit 1 + } + if (!(Test-Path "${libusb_dll}")) { + write-host "${libusb_dll} does not exist!" + exit 1 + } + echo "root=${libusb_incdir};${libusb_libdir}" >> $env:GITHUB_OUTPUT + echo "LibUSB_ROOT=${libusb_incdir};${libusb_libdir}" >> $env:GITHUB_ENV diff --git a/src/contrib/SDL-3.2.20/.github/actions/setup-ninja/action.yml b/src/contrib/SDL-3.2.20/.github/actions/setup-ninja/action.yml new file mode 100644 index 0000000..a1d3ad9 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.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/src/contrib/SDL-3.2.20/.github/actions/setup-vita-gles/action.yml b/src/contrib/SDL-3.2.20/.github/actions/setup-vita-gles/action.yml new file mode 100644 index 0000000..e263737 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/actions/setup-vita-gles/action.yml @@ -0,0 +1,93 @@ +name: 'Setup GLES for PlayStation Vita' +description: 'Download GLES for VITA (PVR or PIB), and copy it into the vita sdk' +inputs: + pib-version: + description: 'PIB version' + default: '1.1.4' + pvr-version: + description: 'PVR_PSP2 version' + default: '3.9' + type: + description: '"pib" or "pvr"' + default: '' +runs: + using: 'composite' + steps: + - name: 'Calculate variables' + id: calc + shell: sh + run: | + if test "x${VITASDK}" = "x"; then + echo "VITASDK must be defined" + exit 1; + fi + case "x${{ inputs.type }}" in + "xpvr") + echo "cache-key=SDL-vita-gles-pvr-${{ inputs.pvr-version}}" >> ${GITHUB_OUTPUT} + ;; + "xpib") + echo "cache-key=SDL-vita-gles-pib-${{ inputs.pib-version}}" >> ${GITHUB_OUTPUT} + ;; + *) + echo "Invalid type. Must be 'pib' or 'pvr'." + exit 1 + ;; + esac + - uses: actions/cache/restore@v4 + id: restore-cache + with: + path: /vita/dependencies + key: '${{ steps.calc.outputs.cache-key }}' + - name: 'Download PVR_PSP2 (GLES)' + if: ${{ !steps.restore-cache.outputs.cache-hit && inputs.type == 'pvr' }} + shell: sh + run: | + pvr_psp2_version=${{ inputs.pvr-version }} + + mkdir -p /vita/dependencies/include + mkdir -p /vita/dependencies/lib + + # Configure PVR_PSP2 headers + wget https://github.com/GrapheneCt/PVR_PSP2/archive/refs/tags/v$pvr_psp2_version.zip -P/tmp + unzip /tmp/v$pvr_psp2_version.zip -d/tmp + cp -r /tmp/PVR_PSP2-$pvr_psp2_version/include/* /vita/dependencies/include + rm /tmp/v$pvr_psp2_version.zip + + # include guard of PVR_PSP2's khrplatform.h does not match the usual one + sed -i -e s/__drvkhrplatform_h_/__khrplatform_h_/ /vita/dependencies/include/KHR/khrplatform.h + + # Configure PVR_PSP2 stub libraries + wget https://github.com/GrapheneCt/PVR_PSP2/releases/download/v$pvr_psp2_version/vitasdk_stubs.zip -P/tmp + unzip /tmp/vitasdk_stubs.zip -d/tmp/pvr_psp2_stubs + find /tmp/pvr_psp2_stubs -type f -name "*.a" -exec cp {} /vita/dependencies/lib \; + rm /tmp/vitasdk_stubs.zip + rm -rf /tmp/pvr_psp2_stubs + + - name: 'Download gl4es4vita (OpenGL)' + if: ${{ !steps.restore-cache.outputs.cache-hit && inputs.type == 'pib' }} + shell: sh + run: | + gl4es4vita_version=${{ inputs.pib-version }} + + mkdir -p /vita/dependencies/include + mkdir -p /vita/dependencies/lib + + # Configure gl4es4vita headers + wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/include.zip -P/tmp + unzip -o /tmp/include.zip -d/vita/dependencies/include + rm /tmp/include.zip + + # Configure gl4es4vita stub libraries + wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/vitasdk_stubs.zip -P/tmp + unzip /tmp/vitasdk_stubs.zip -d/vita/dependencies/lib + + - uses: actions/cache/save@v4 + if: ${{ !steps.restore-cache.outputs.cache-hit }} + with: + path: /vita/dependencies + key: '${{ steps.calc.outputs.cache-key }}' + + - name: Copy PVR_PSP2 (GLES) or gl4es4vita (OpenGL) to vita toolchain dir + shell: sh + run: | + cp -rv /vita/dependencies/* ${VITASDK}/arm-vita-eabi diff --git a/src/contrib/SDL-3.2.20/.github/cmake/CMakeLists.txt b/src/contrib/SDL-3.2.20/.github/cmake/CMakeLists.txt new file mode 100644 index 0000000..4875701 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/cmake/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.0...3.5) +project(ci_utils C CXX) + +set(txt "CC=${CMAKE_C_COMPILER} +CXX=${CMAKE_CXX_COMPILER} +CFLAGS=${CMAKE_C_FLAGS} +CXXFLAGS=${CMAKE_CXX_FLAGS} +LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_C_STANDARD_LIBRARIES} +") + +message("${txt}") + +set(VAR_PATH "/tmp/env.txt" CACHE PATH "Where to write environment file") +message(STATUS "Writing CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS environment to ${VAR_PATH}") + +file(WRITE "${VAR_PATH}" "${txt}") diff --git a/src/contrib/SDL-3.2.20/.github/workflows/build.yml b/src/contrib/SDL-3.2.20/.github/workflows/build.yml new file mode 100644 index 0000000..09652e0 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: 'Build (All)' + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + controller: + name: 'Create test plan' + runs-on: 'ubuntu-latest' + outputs: + platforms-level1: ${{ steps.plan.outputs.platforms-level1 }} + platforms-others: ${{ steps.plan.outputs.platforms-others }} + steps: + - uses: actions/setup-python@main + with: + python-version: 3.x + - uses: actions/checkout@main + with: + sparse-checkout: '.github/workflows/create-test-plan.py' + - name: 'Create plan' + id: plan + run: | + # Adding [sdl-ci-filter GLOB] to the commit message will limit the jobs + # e.g. [sdl-ci-filter msvc-*] + EOF=$(openssl rand -hex 32) + cat >/tmp/commit_message.txt <<$EOF + ${{ github.event.head_commit.message }} + $EOF + + python .github/workflows/create-test-plan.py \ + --github-variable-prefix platforms \ + --github-ci \ + --verbose \ + ${{ (github.repository_owner != 'libsdl-org' && '--no-artifact') || '' }} \ + --commit-message-file /tmp/commit_message.txt + level1: + needs: [controller] + uses: './.github/workflows/generic.yml' + with: + platforms: ${{ needs.controller.outputs.platforms-level1 }} + level2: + needs: [controller, level1] + uses: './.github/workflows/generic.yml' + with: + platforms: ${{ needs.controller.outputs.platforms-others }} diff --git a/src/contrib/SDL-3.2.20/.github/workflows/create-test-plan.py b/src/contrib/SDL-3.2.20/.github/workflows/create-test-plan.py new file mode 100755 index 0000000..5e2ab02 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/workflows/create-test-plan.py @@ -0,0 +1,870 @@ +#!/usr/bin/env python +import argparse +import dataclasses +import fnmatch +from enum import Enum +import json +import logging +import os +import re +from typing import Optional + +logger = logging.getLogger(__name__) + + +class AppleArch(Enum): + Aarch64 = "aarch64" + X86_64 = "x86_64" + + +class MsvcArch(Enum): + X86 = "x86" + X64 = "x64" + Arm32 = "arm" + Arm64 = "arm64" + + +class JobOs(Enum): + WindowsLatest = "windows-latest" + UbuntuLatest = "ubuntu-latest" + MacosLatest = "macos-latest" + Ubuntu22_04 = "ubuntu-22.04" + Ubuntu24_04 = "ubuntu-24.04" + Ubuntu24_04_arm = "ubuntu-24.04-arm" + Macos13 = "macos-13" + + +class SdlPlatform(Enum): + Android = "android" + Emscripten = "emscripten" + Haiku = "haiku" + LoongArch64 = "loongarch64" + Msys2 = "msys2" + Linux = "linux" + MacOS = "macos" + Ios = "ios" + Tvos = "tvos" + Msvc = "msvc" + N3ds = "n3ds" + PowerPC = "powerpc" + PowerPC64 = "powerpc64" + Ps2 = "ps2" + Psp = "psp" + Vita = "vita" + Riscos = "riscos" + FreeBSD = "freebsd" + NetBSD = "netbsd" + + +class Msys2Platform(Enum): + Mingw32 = "mingw32" + Mingw64 = "mingw64" + Clang64 = "clang64" + Ucrt64 = "ucrt64" + + +class IntelCompiler(Enum): + Icc = "icc" + Icx = "icx" + + +class VitaGLES(Enum): + Pib = "pib" + Pvr = "pvr" + + +@dataclasses.dataclass(slots=True) +class JobSpec: + name: str + os: JobOs + platform: SdlPlatform + artifact: Optional[str] + container: Optional[str] = None + no_cmake: bool = False + xcode: bool = False + android_mk: bool = False + android_gradle: bool = False + lean: bool = False + android_arch: Optional[str] = None + android_abi: Optional[str] = None + android_platform: Optional[int] = None + msys2_platform: Optional[Msys2Platform] = None + intel: Optional[IntelCompiler] = None + apple_framework: Optional[bool] = None + apple_archs: Optional[set[AppleArch]] = None + msvc_project: Optional[str] = None + msvc_arch: Optional[MsvcArch] = None + clang_cl: bool = False + gdk: bool = False + vita_gles: Optional[VitaGLES] = None + + +JOB_SPECS = { + "msys2-mingw32": JobSpec(name="Windows (msys2, mingw32)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw32", msys2_platform=Msys2Platform.Mingw32, ), + "msys2-mingw64": JobSpec(name="Windows (msys2, mingw64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64", msys2_platform=Msys2Platform.Mingw64, ), + "msys2-clang64": JobSpec(name="Windows (msys2, clang64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-clang", msys2_platform=Msys2Platform.Clang64, ), + "msys2-ucrt64": JobSpec(name="Windows (msys2, ucrt64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-ucrt", msys2_platform=Msys2Platform.Ucrt64, ), + "msvc-x64": JobSpec(name="Windows (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x64", msvc_arch=MsvcArch.X64, msvc_project="VisualC/SDL.sln", ), + "msvc-x86": JobSpec(name="Windows (MSVC, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, msvc_project="VisualC/SDL.sln", ), + "msvc-clang-x64": JobSpec(name="Windows (MSVC, clang-cl x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x64", msvc_arch=MsvcArch.X64, clang_cl=True, ), + "msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ), + "msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ), + "msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ), + "msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ), + "ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", ), + "ubuntu-24.04-arm64": JobSpec(name="Ubuntu 24.04 (ARM64)", os=JobOs.Ubuntu24_04_arm, platform=SdlPlatform.Linux, artifact="SDL-ubuntu24.04-arm64", ), + "steamrt-sniper": JobSpec(name="Steam Linux Runtime (Sniper)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-slrsniper", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta", ), + "ubuntu-intel-icx": JobSpec(name="Ubuntu 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ), + "ubuntu-intel-icc": JobSpec(name="Ubuntu 22.04 (Intel Compiler)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-icc", intel=IntelCompiler.Icc, ), + "macos-framework-x64": JobSpec(name="MacOS (Framework) (x64)", os=JobOs.Macos13, platform=SdlPlatform.MacOS, artifact="SDL-macos-framework", apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, xcode=True, ), + "macos-framework-arm64": JobSpec(name="MacOS (Framework) (arm64)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact=None, apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, ), + "macos-gnu-arm64": JobSpec(name="MacOS (GNU prefix)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact="SDL-macos-arm64-gnu", apple_framework=False, apple_archs={AppleArch.Aarch64, }, ), + "ios": JobSpec(name="iOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Ios, artifact="SDL-ios-arm64", xcode=True, ), + "tvos": JobSpec(name="tvOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Tvos, artifact="SDL-tvos-arm64", xcode=True, ), + "android-cmake": JobSpec(name="Android (CMake)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Android, artifact="SDL-android-arm64", android_abi="arm64-v8a", android_arch="aarch64", android_platform=23, ), + "android-cmake-lean": JobSpec(name="Android (CMake, lean)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Android, artifact="SDL-lean-android-arm64", android_abi="arm64-v8a", android_arch="aarch64", android_platform=23, lean=True, ), + "android-mk": JobSpec(name="Android (Android.mk)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Android, artifact=None, no_cmake=True, android_mk=True, ), + "android-gradle": JobSpec(name="Android (Gradle)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Android, artifact=None, no_cmake=True, android_gradle=True, ), + "emscripten": JobSpec(name="Emscripten", os=JobOs.UbuntuLatest, platform=SdlPlatform.Emscripten, artifact="SDL-emscripten", ), + "haiku": JobSpec(name="Haiku", os=JobOs.UbuntuLatest, platform=SdlPlatform.Haiku, artifact="SDL-haiku-x64", container="ghcr.io/haiku/cross-compiler:x86_64-r1beta5", ), + "loongarch64": JobSpec(name="LoongArch64", os=JobOs.UbuntuLatest, platform=SdlPlatform.LoongArch64, artifact="SDL-loongarch64", ), + "n3ds": JobSpec(name="Nintendo 3DS", os=JobOs.UbuntuLatest, platform=SdlPlatform.N3ds, artifact="SDL-n3ds", container="devkitpro/devkitarm:latest", ), + "ppc": JobSpec(name="PowerPC", os=JobOs.UbuntuLatest, platform=SdlPlatform.PowerPC, artifact="SDL-ppc", container="dockcross/linux-ppc:latest", ), + "ppc64": JobSpec(name="PowerPC64", os=JobOs.UbuntuLatest, platform=SdlPlatform.PowerPC64, artifact="SDL-ppc64le", container="dockcross/linux-ppc64le:latest", ), + "ps2": JobSpec(name="Sony PlayStation 2", os=JobOs.UbuntuLatest, platform=SdlPlatform.Ps2, artifact="SDL-ps2", container="ps2dev/ps2dev:latest", ), + "psp": JobSpec(name="Sony PlayStation Portable", os=JobOs.UbuntuLatest, platform=SdlPlatform.Psp, artifact="SDL-psp", container="pspdev/pspdev:latest", ), + "vita-pib": JobSpec(name="Sony PlayStation Vita (GLES w/ pib)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Vita, artifact="SDL-vita-pib", container="vitasdk/vitasdk:latest", vita_gles=VitaGLES.Pib, ), + "vita-pvr": JobSpec(name="Sony PlayStation Vita (GLES w/ PVR_PSP2)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Vita, artifact="SDL-vita-pvr", container="vitasdk/vitasdk:latest", vita_gles=VitaGLES.Pvr, ), + "riscos": JobSpec(name="RISC OS", os=JobOs.UbuntuLatest, platform=SdlPlatform.Riscos, artifact="SDL-riscos", container="riscosdotinfo/riscos-gccsdk-4.7:latest", ), + "netbsd": JobSpec(name="NetBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.NetBSD, artifact="SDL-netbsd-x64", ), + "freebsd": JobSpec(name="FreeBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.FreeBSD, artifact="SDL-freebsd-x64", ), +} + + +class StaticLibType(Enum): + MSVC = "SDL3-static.lib" + A = "libSDL3.a" + + +class SharedLibType(Enum): + WIN32 = "SDL3.dll" + SO_0 = "libSDL3.so.0" + SO = "libSDL3.so" + DYLIB = "libSDL3.0.dylib" + FRAMEWORK = "SDL3.framework/Versions/A/SDL3" + + +@dataclasses.dataclass(slots=True) +class JobDetails: + name: str + key: str + os: str + platform: str + artifact: str + no_cmake: bool + ccache: bool = False + build_tests: bool = True + container: str = "" + cmake_build_type: str = "RelWithDebInfo" + shell: str = "sh" + sudo: str = "sudo" + cmake_config_emulator: str = "" + apk_packages: list[str] = dataclasses.field(default_factory=list) + apt_packages: list[str] = dataclasses.field(default_factory=list) + brew_packages: list[str] = dataclasses.field(default_factory=list) + cmake_toolchain_file: str = "" + cmake_arguments: list[str] = dataclasses.field(default_factory=list) + cmake_generator: str = "Ninja" + cmake_build_arguments: list[str] = dataclasses.field(default_factory=list) + clang_tidy: bool = True + cppflags: list[str] = dataclasses.field(default_factory=list) + cc: str = "" + cxx: str = "" + cflags: list[str] = dataclasses.field(default_factory=list) + cxxflags: list[str] = dataclasses.field(default_factory=list) + ldflags: list[str] = dataclasses.field(default_factory=list) + pollute_directories: list[str] = dataclasses.field(default_factory=list) + use_cmake: bool = True + shared: bool = True + static: bool = True + shared_lib: Optional[SharedLibType] = None + static_lib: Optional[StaticLibType] = None + run_tests: bool = True + test_pkg_config: bool = True + cc_from_cmake: bool = False + source_cmd: str = "" + pretest_cmd: str = "" + java: bool = False + android_apks: list[str] = dataclasses.field(default_factory=list) + android_ndk: bool = False + android_mk: bool = False + android_gradle: bool = False + minidump: bool = False + intel: bool = False + msys2_msystem: str = "" + msys2_env: str = "" + msys2_no_perl: bool = False + werror: bool = True + msvc_vcvars_arch: str = "" + msvc_vcvars_sdk: str = "" + msvc_project: str = "" + msvc_project_flags: list[str] = dataclasses.field(default_factory=list) + setup_ninja: bool = False + setup_libusb_arch: str = "" + xcode_sdk: str = "" + cpactions: bool = False + setup_gdk_folder: str = "" + cpactions_os: str = "" + cpactions_version: str = "" + cpactions_arch: str = "" + cpactions_setup_cmd: str = "" + cpactions_install_cmd: str = "" + setup_vita_gles_type: str = "" + check_sources: bool = False + setup_python: bool = False + pypi_packages: list[str] = dataclasses.field(default_factory=list) + binutils_strings: str = "strings" + + def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]: + data = { + "name": self.name, + "key": self.key, + "os": self.os, + "ccache": self.ccache, + "container": self.container if self.container else "", + "platform": self.platform, + "artifact": self.artifact, + "enable-artifacts": enable_artifacts, + "shell": self.shell, + "msys2-msystem": self.msys2_msystem, + "msys2-env": self.msys2_env, + "msys2-no-perl": self.msys2_no_perl, + "android-ndk": self.android_ndk, + "java": self.java, + "intel": self.intel, + "apk-packages": my_shlex_join(self.apk_packages), + "apt-packages": my_shlex_join(self.apt_packages), + "test-pkg-config": self.test_pkg_config, + "brew-packages": my_shlex_join(self.brew_packages), + "pollute-directories": my_shlex_join(self.pollute_directories), + "no-cmake": self.no_cmake, + "build-tests": self.build_tests, + "source-cmd": self.source_cmd, + "pretest-cmd": self.pretest_cmd, + "cmake-config-emulator": self.cmake_config_emulator, + "cc": self.cc, + "cxx": self.cxx, + "cflags": my_shlex_join(self.cppflags + self.cflags), + "cxxflags": my_shlex_join(self.cppflags + self.cxxflags), + "ldflags": my_shlex_join(self.ldflags), + "cmake-generator": self.cmake_generator, + "cmake-toolchain-file": self.cmake_toolchain_file, + "clang-tidy": self.clang_tidy, + "cmake-arguments": my_shlex_join(self.cmake_arguments), + "cmake-build-arguments": my_shlex_join(self.cmake_build_arguments), + "shared": self.shared, + "static": self.static, + "shared-lib": self.shared_lib.value if self.shared_lib else None, + "static-lib": self.static_lib.value if self.static_lib else None, + "cmake-build-type": self.cmake_build_type, + "run-tests": self.run_tests, + "android-apks": my_shlex_join(self.android_apks), + "android-gradle": self.android_gradle, + "android-mk": self.android_mk, + "werror": self.werror, + "sudo": self.sudo, + "msvc-vcvars-arch": self.msvc_vcvars_arch, + "msvc-vcvars-sdk": self.msvc_vcvars_sdk, + "msvc-project": self.msvc_project, + "msvc-project-flags": my_shlex_join(self.msvc_project_flags), + "setup-ninja": self.setup_ninja, + "setup-libusb-arch": self.setup_libusb_arch, + "cc-from-cmake": self.cc_from_cmake, + "xcode-sdk": self.xcode_sdk, + "cpactions": self.cpactions, + "cpactions-os": self.cpactions_os, + "cpactions-version": self.cpactions_version, + "cpactions-arch": self.cpactions_arch, + "cpactions-setup-cmd": self.cpactions_setup_cmd, + "cpactions-install-cmd": self.cpactions_install_cmd, + "setup-vita-gles-type": self.setup_vita_gles_type, + "setup-gdk-folder": self.setup_gdk_folder, + "check-sources": self.check_sources, + "setup-python": self.setup_python, + "pypi-packages": my_shlex_join(self.pypi_packages), + "binutils-strings": self.binutils_strings, + } + return {k: v for k, v in data.items() if v != ""} + + +def my_shlex_join(s): + def escape(s): + if s[:1] == "'" and s[-1:] == "'": + return s + if set(s).intersection(set("; \t")): + return f'"{s}"' + return s + + return " ".join(escape(s)) + + +def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDetails: + job = JobDetails( + name=spec.name, + key=key, + os=spec.os.value, + artifact=spec.artifact or "", + container=spec.container or "", + platform=spec.platform.value, + sudo="sudo", + no_cmake=spec.no_cmake, + ) + if job.os.startswith("ubuntu"): + job.apt_packages.extend([ + "ninja-build", + "pkg-config", + ]) + pretest_cmd = [] + if trackmem_symbol_names: + pretest_cmd.append("export SDL_TRACKMEM_SYMBOL_NAMES=1") + else: + pretest_cmd.append("export SDL_TRACKMEM_SYMBOL_NAMES=0") + win32 = spec.platform in (SdlPlatform.Msys2, SdlPlatform.Msvc) + fpic = None + build_parallel = True + if spec.lean: + job.cppflags.append("-DSDL_LEAN_AND_MEAN=1") + if win32: + job.cmake_arguments.append("-DSDLTEST_PROCDUMP=ON") + job.minidump = True + if spec.intel is not None: + match spec.intel: + case IntelCompiler.Icx: + job.cc = "icx" + job.cxx = "icpx" + case IntelCompiler.Icc: + job.cc = "icc" + job.cxx = "icpc" + # Disable deprecation warning + job.cppflags.append("-diag-disable=10441") + # Avoid 'Catastrophic error: cannot open precompiled header file' + job.cmake_arguments.append("-DCMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON") + job.clang_tidy = False + case _: + raise ValueError(f"Invalid intel={spec.intel}") + job.source_cmd = f"source /opt/intel/oneapi/setvars.sh;" + job.intel = True + job.shell = "bash" + job.cmake_arguments.extend(( + f"-DCMAKE_C_COMPILER={job.cc}", + f"-DCMAKE_CXX_COMPILER={job.cxx}", + "-DCMAKE_SYSTEM_NAME=Linux", + )) + match spec.platform: + case SdlPlatform.Msvc: + job.setup_ninja = not spec.gdk + job.clang_tidy = False # complains about \threadsafety: "unknown command tag name [clang-diagnostic-documentation-unknown-command]" + job.msvc_project = spec.msvc_project if spec.msvc_project else "" + job.msvc_project_flags.append("-p:TreatWarningsAsError=true") + job.test_pkg_config = False + job.shared_lib = SharedLibType.WIN32 + job.static_lib = StaticLibType.MSVC + job.cmake_arguments.extend(( + "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=ProgramDatabase", + "-DCMAKE_EXE_LINKER_FLAGS=-DEBUG", + "-DCMAKE_SHARED_LINKER_FLAGS=-DEBUG", + )) + + job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$:Debug>'") + + if spec.clang_cl: + job.cmake_arguments.extend(( + "-DCMAKE_C_COMPILER=clang-cl", + "-DCMAKE_CXX_COMPILER=clang-cl", + )) + match spec.msvc_arch: + case MsvcArch.X86: + job.cflags.append("/clang:-m32") + job.ldflags.append("/MACHINE:X86") + case MsvcArch.X64: + job.cflags.append("/clang:-m64") + job.ldflags.append("/MACHINE:X64") + case _: + raise ValueError(f"Unsupported clang-cl architecture (arch={spec.msvc_arch})") + if spec.msvc_project: + match spec.msvc_arch: + case MsvcArch.X86: + msvc_platform = "Win32" + case MsvcArch.X64: + msvc_platform = "x64" + case _: + raise ValueError(f"Unsupported vcxproj architecture (arch={spec.msvc_arch})") + if spec.gdk: + msvc_platform = f"Gaming.Desktop.{msvc_platform}" + job.msvc_project_flags.append(f"-p:Platform={msvc_platform}") + match spec.msvc_arch: + case MsvcArch.X86: + job.msvc_vcvars_arch = "x64_x86" + case MsvcArch.X64: + job.msvc_vcvars_arch = "x64" + case MsvcArch.Arm32: + job.msvc_vcvars_arch = "x64_arm" + job.msvc_vcvars_sdk = "10.0.22621.0" # 10.0.26100.0 dropped ARM32 um and ucrt libraries + job.run_tests = False + case MsvcArch.Arm64: + job.msvc_vcvars_arch = "x64_arm64" + job.run_tests = False + if spec.gdk: + job.setup_gdk_folder = "VisualC-GDK" + else: + match spec.msvc_arch: + case MsvcArch.X86: + job.setup_libusb_arch = "x86" + case MsvcArch.X64: + job.setup_libusb_arch = "x64" + case SdlPlatform.Linux: + if spec.name.startswith("Ubuntu"): + assert spec.os.value.startswith("ubuntu-") + job.apt_packages.extend(( + "ccache", + "gnome-desktop-testing", + "libasound2-dev", + "libpulse-dev", + "libaudio-dev", + "libjack-dev", + "libsndio-dev", + "libusb-1.0-0-dev", + "libx11-dev", + "libxext-dev", + "libxrandr-dev", + "libxcursor-dev", + "libxfixes-dev", + "libxi-dev", + "libxss-dev", + "libwayland-dev", + "libxkbcommon-dev", + "libdrm-dev", + "libgbm-dev", + "libgl1-mesa-dev", + "libgles2-mesa-dev", + "libegl1-mesa-dev", + "libdbus-1-dev", + "libibus-1.0-dev", + "libudev-dev", + "fcitx-libs-dev", + )) + match = re.match(r"ubuntu-(?P[0-9]+)\.(?P[0-9]+).*", spec.os.value) + ubuntu_year, ubuntu_month = [int(match["year"]), int(match["month"])] + if ubuntu_year >= 22: + job.apt_packages.extend(("libpipewire-0.3-dev", "libdecor-0-dev")) + job.apt_packages.extend(( + "libunwind-dev", # For SDL_test memory tracking + )) + job.ccache = True + if trackmem_symbol_names: + # older libunwind is slow + job.cmake_arguments.append("-DSDLTEST_TIMEOUT_MULTIPLIER=2") + job.shared_lib = SharedLibType.SO_0 + job.static_lib = StaticLibType.A + fpic = True + case SdlPlatform.Ios | SdlPlatform.Tvos: + job.brew_packages.extend([ + "ccache", + "ninja", + ]) + job.ccache = True + job.clang_tidy = False + job.run_tests = False + job.test_pkg_config = False + job.shared_lib = SharedLibType.DYLIB + job.static_lib = StaticLibType.A + match spec.platform: + case SdlPlatform.Ios: + if spec.xcode: + job.xcode_sdk = 'iphoneos' + job.cmake_arguments.extend([ + "-DCMAKE_SYSTEM_NAME=iOS", + "-DCMAKE_OSX_ARCHITECTURES=\"arm64\"", + "-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0", + ]) + case SdlPlatform.Tvos: + if spec.xcode: + job.xcode_sdk = 'appletvos' + job.cmake_arguments.extend([ + "-DCMAKE_SYSTEM_NAME=tvOS", + "-DCMAKE_OSX_ARCHITECTURES=\"arm64\"", + "-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0", + ]) + case SdlPlatform.MacOS: + if spec.apple_framework: + job.static = False + job.clang_tidy = False + job.test_pkg_config = False + job.cmake_arguments.extend(( + "'-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64'", + "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13", + "-DSDL_FRAMEWORK=ON", + )) + job.shared_lib = SharedLibType.FRAMEWORK + else: + job.clang_tidy = True + job.cmake_arguments.extend(( + "-DCMAKE_OSX_ARCHITECTURES=arm64", + "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13", + "-DCLANG_TIDY_BINARY=$(brew --prefix llvm)/bin/clang-tidy", + )) + job.shared_lib = SharedLibType.DYLIB + job.static_lib = StaticLibType.A + job.ccache = True + job.apt_packages = [] + job.brew_packages.extend(( + "ccache", + "ninja", + )) + if job.clang_tidy: + job.brew_packages.append("llvm") + if spec.xcode: + job.xcode_sdk = "macosx" + case SdlPlatform.Android: + job.android_gradle = spec.android_gradle + job.android_mk = spec.android_mk + job.apt_packages.append("ccache") + job.run_tests = False + job.shared_lib = SharedLibType.SO + job.static_lib = StaticLibType.A + if spec.android_mk or not spec.no_cmake: + job.android_ndk = True + if spec.android_gradle or not spec.no_cmake: + job.java = True + if spec.android_mk or spec.android_gradle: + job.apt_packages = [] + if not spec.no_cmake: + job.ccache = True + job.cmake_arguments.extend(( + f"-DANDROID_PLATFORM={spec.android_platform}", + f"-DANDROID_ABI={spec.android_abi}", + )) + job.cmake_toolchain_file = "${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake" + job.cc = f"${{ANDROID_NDK_HOME}}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target={spec.android_arch}-none-linux-androideabi{spec.android_platform}" + + job.android_apks = [ + "testaudiorecording-apk", + "testautomation-apk", + "testcontroller-apk", + "testmultiaudio-apk", + "testsprite-apk", + ] + case SdlPlatform.Emscripten: + job.clang_tidy = False # clang-tidy does not understand -gsource-map + job.shared = False + job.ccache = True + job.apt_packages.append("ccache") + job.cmake_config_emulator = "emcmake" + job.cmake_build_type = "Debug" + job.test_pkg_config = False + job.cmake_arguments.extend(( + "-DSDLTEST_BROWSER=chrome", + "-DSDLTEST_TIMEOUT_MULTIPLIER=4", + "-DSDLTEST_CHROME_BINARY=${CHROME_BINARY}", + )) + job.cflags.extend(( + "-gsource-map", + "-ffile-prefix-map=${PWD}=/SDL", + )) + job.ldflags.extend(( + "--source-map-base", "/", + )) + pretest_cmd.extend(( + "# Start local HTTP server", + "cmake --build build --target serve-sdl-tests --verbose &", + "chrome --version", + "chromedriver --version", + )) + job.static_lib = StaticLibType.A + job.setup_python = True + job.pypi_packages.append("selenium") + case SdlPlatform.Ps2: + job.ccache = False # actions/ccache does not work in psp container (incompatible tar of busybox) + build_parallel = False + job.shared = False + job.sudo = "" + job.apt_packages = [] + job.apk_packages = ["ccache", "cmake", "gmp", "mpc1", "mpfr4", "ninja", "pkgconf", "git", ] + job.cmake_toolchain_file = "${PS2DEV}/ps2sdk/ps2dev.cmake" + job.clang_tidy = False + job.run_tests = False + job.shared = False + job.cc = "mips64r5900el-ps2-elf-gcc" + job.ldflags = ["-L${PS2DEV}/ps2sdk/ee/lib", "-L${PS2DEV}/gsKit/lib", "-L${PS2DEV}/ps2sdk/ports/lib", ] + job.static_lib = StaticLibType.A + case SdlPlatform.Psp: + job.ccache = False # actions/ccache does not work in psp container (incompatible tar of busybox) + build_parallel = False + job.sudo = "" + job.apt_packages = [] + job.apk_packages = ["ccache", "cmake", "gmp", "mpc1", "mpfr4", "ninja", "pkgconf", ] + job.cmake_toolchain_file = "${PSPDEV}/psp/share/pspdev.cmake" + job.clang_tidy = False + job.run_tests = False + job.shared = False + job.cc = "psp-gcc" + job.ldflags = ["-L${PSPDEV}/lib", "-L${PSPDEV}/psp/lib", "-L${PSPDEV}/psp/sdk/lib", ] + job.pollute_directories = ["${PSPDEV}/include", "${PSPDEV}/psp/include", "${PSPDEV}/psp/sdk/include", ] + job.static_lib = StaticLibType.A + case SdlPlatform.Vita: + job.ccache = True + job.sudo = "" + job.apt_packages = [] + job.apk_packages = ["ccache", "cmake", "ninja", "pkgconf", "bash", "tar"] + job.cmake_toolchain_file = "${VITASDK}/share/vita.toolchain.cmake" + assert spec.vita_gles is not None + job.setup_vita_gles_type = { + VitaGLES.Pib: "pib", + VitaGLES.Pvr: "pvr", + }[spec.vita_gles] + job.cmake_arguments.extend(( + f"-DVIDEO_VITA_PIB={ 'true' if spec.vita_gles == VitaGLES.Pib else 'false' }", + f"-DVIDEO_VITA_PVR={ 'true' if spec.vita_gles == VitaGLES.Pvr else 'false' }", + "-DSDL_ARMNEON=ON", + "-DSDL_ARMSIMD=ON", + )) + # Fix vita.toolchain.cmake (https://github.com/vitasdk/vita-toolchain/pull/253) + job.source_cmd = r"""sed -i -E "s#set\\( PKG_CONFIG_EXECUTABLE \"\\$\\{VITASDK}/bin/arm-vita-eabi-pkg-config\" \\)#set\\( PKG_CONFIG_EXECUTABLE \"${VITASDK}/bin/arm-vita-eabi-pkg-config\" CACHE PATH \"Path of pkg-config executable\" \\)#" ${VITASDK}/share/vita.toolchain.cmake""" + job.clang_tidy = False + job.run_tests = False + job.shared = False + job.cc = "arm-vita-eabi-gcc" + job.static_lib = StaticLibType.A + case SdlPlatform.Haiku: + job.ccache = True + fpic = False + job.run_tests = False + job.apt_packages.append("ccache") + job.cc = "x86_64-unknown-haiku-gcc" + job.cxx = "x86_64-unknown-haiku-g++" + job.sudo = "" + job.cmake_arguments.extend(( + f"-DCMAKE_C_COMPILER={job.cc}", + f"-DCMAKE_CXX_COMPILER={job.cxx}", + "-DSDL_UNIX_CONSOLE_BUILD=ON", + )) + job.shared_lib = SharedLibType.SO_0 + job.static_lib = StaticLibType.A + case SdlPlatform.PowerPC64 | SdlPlatform.PowerPC: + job.ccache = True + # FIXME: Enable SDL_WERROR + job.werror = False + job.clang_tidy = False + job.run_tests = False + job.sudo = "" + job.apt_packages = ["ccache"] + job.shared_lib = SharedLibType.SO_0 + job.static_lib = StaticLibType.A + job.cmake_arguments.extend(( + "-DSDL_UNIX_CONSOLE_BUILD=ON", + )) + case SdlPlatform.LoongArch64: + job.ccache = True + fpic = True + job.run_tests = False + job.apt_packages.append("ccache") + job.cc = "${LOONGARCH64_CC}" + job.cxx = "${LOONGARCH64_CXX}" + job.cmake_arguments.extend(( + f"-DCMAKE_C_COMPILER={job.cc}", + f"-DCMAKE_CXX_COMPILER={job.cxx}", + "-DSDL_UNIX_CONSOLE_BUILD=ON", + "-DCMAKE_SYSTEM_NAME=Linux", + )) + job.shared_lib = SharedLibType.SO_0 + job.static_lib = StaticLibType.A + case SdlPlatform.N3ds: + job.cmake_generator = "Unix Makefiles" + job.cmake_build_arguments.append("-j$(nproc)") + job.ccache = False + job.shared = False + job.apt_packages = [] + job.clang_tidy = False + job.run_tests = False + job.cc_from_cmake = True + job.cmake_toolchain_file = "${DEVKITPRO}/cmake/3DS.cmake" + job.binutils_strings = "/opt/devkitpro/devkitARM/bin/arm-none-eabi-strings" + job.static_lib = StaticLibType.A + case SdlPlatform.Msys2: + job.ccache = True + job.shell = "msys2 {0}" + assert spec.msys2_platform + job.msys2_msystem = spec.msys2_platform.value + job.msys2_env = { + "mingw32": "mingw-w64-i686", + "mingw64": "mingw-w64-x86_64", + "clang64": "mingw-w64-clang-x86_64", + "ucrt64": "mingw-w64-ucrt-x86_64", + }[spec.msys2_platform.value] + job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, ) + job.shared_lib = SharedLibType.WIN32 + job.static_lib = StaticLibType.A + case SdlPlatform.Riscos: + job.ccache = False # FIXME: enable when container gets upgrade + # FIXME: Enable SDL_WERROR + job.werror = False + job.apt_packages = ["ccache", "cmake", "ninja-build"] + job.test_pkg_config = False + job.shared = False + job.run_tests = False + job.sudo = "" + job.cmake_arguments.extend(( + "-DRISCOS:BOOL=ON", + "-DCMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON", + "-DSDL_GCC_ATOMICS:BOOL=OFF", + )) + job.cmake_toolchain_file = "/home/riscos/env/toolchain-riscos.cmake" + job.static_lib = StaticLibType.A + case SdlPlatform.FreeBSD | SdlPlatform.NetBSD: + job.cpactions = True + job.no_cmake = True + job.run_tests = False + job.apt_packages = [] + job.shared_lib = SharedLibType.SO_0 + job.static_lib = StaticLibType.A + match spec.platform: + case SdlPlatform.FreeBSD: + job.cpactions_os = "freebsd" + job.cpactions_version = "14.2" + job.cpactions_arch = "x86-64" + job.cpactions_setup_cmd = "sudo pkg update" + job.cpactions_install_cmd = "sudo pkg install -y cmake ninja pkgconf libXcursor libXext libXinerama libXi libXfixes libXrandr libXScrnSaver libXxf86vm wayland wayland-protocols libxkbcommon mesa-libs libglvnd evdev-proto libinotify alsa-lib jackit pipewire pulseaudio sndio dbus zh-fcitx ibus libudev-devd" + job.cmake_arguments.extend(( + "-DSDL_CHECK_REQUIRED_INCLUDES=/usr/local/include", + "-DSDL_CHECK_REQUIRED_LINK_OPTIONS=-L/usr/local/lib", + )) + case SdlPlatform.NetBSD: + job.cpactions_os = "netbsd" + job.cpactions_version = "10.1" + job.cpactions_arch = "x86-64" + job.cpactions_setup_cmd = "export PATH=\"/usr/pkg/sbin:/usr/pkg/bin:/sbin:$PATH\"; export PKG_CONFIG_PATH=\"/usr/pkg/lib/pkgconfig\";export PKG_PATH=\"https://cdn.netBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r|cut -f \"1 2\" -d.)/All/\";echo \"PKG_PATH=$PKG_PATH\";echo \"uname -a -> \"$(uname -a)\"\";sudo -E sysctl -w security.pax.aslr.enabled=0;sudo -E sysctl -w security.pax.aslr.global=0;sudo -E pkgin clean;sudo -E pkgin update" + job.cpactions_install_cmd = "sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1" + case _: + raise ValueError(f"Unsupported platform={spec.platform}") + + if "ubuntu" in spec.name.lower(): + job.check_sources = True + job.setup_python = True + + if job.ccache: + job.cmake_arguments.extend(( + "-DCMAKE_C_COMPILER_LAUNCHER=ccache", + "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", + )) + if not build_parallel: + job.cmake_build_arguments.append("-j1") + if job.cflags or job.cppflags: + job.cmake_arguments.append(f"-DCMAKE_C_FLAGS=\"{my_shlex_join(job.cflags + job.cppflags)}\"") + if job.cxxflags or job.cppflags: + job.cmake_arguments.append(f"-DCMAKE_CXX_FLAGS=\"{my_shlex_join(job.cxxflags + job.cppflags)}\"") + if job.ldflags: + job.cmake_arguments.append(f"-DCMAKE_SHARED_LINKER_FLAGS=\"{my_shlex_join(job.ldflags)}\"") + job.cmake_arguments.append(f"-DCMAKE_EXE_LINKER_FLAGS=\"{my_shlex_join(job.ldflags)}\"") + job.pretest_cmd = "\n".join(pretest_cmd) + def tf(b): + return "ON" if b else "OFF" + + if fpic is not None: + job.cmake_arguments.append(f"-DCMAKE_POSITION_INDEPENDENT_CODE={tf(fpic)}") + + if job.no_cmake: + job.cmake_arguments = [] + + return job + + +def spec_to_platform(spec: JobSpec, key: str, enable_artifacts: bool, trackmem_symbol_names: bool) -> dict[str, str|bool]: + logger.info("spec=%r", spec) + job = spec_to_job(spec, key=key, trackmem_symbol_names=trackmem_symbol_names) + logger.info("job=%r", job) + platform = job.to_workflow(enable_artifacts=enable_artifacts) + logger.info("platform=%r", platform) + return platform + + +def main(): + parser = argparse.ArgumentParser(allow_abbrev=False) + parser.add_argument("--github-variable-prefix", default="platforms") + parser.add_argument("--github-ci", action="store_true") + parser.add_argument("--verbose", action="store_true") + parser.add_argument("--commit-message-file") + parser.add_argument("--no-artifact", dest="enable_artifacts", action="store_false") + parser.add_argument("--trackmem-symbol-names", dest="trackmem_symbol_names", action="store_true") + args = parser.parse_args() + + logging.basicConfig(level=logging.INFO if args.verbose else logging.WARNING) + + remaining_keys = set(JOB_SPECS.keys()) + + all_level_keys = ( + # Level 1 + ( + "haiku", + ), + ) + + filters = [] + if args.commit_message_file: + with open(args.commit_message_file, "r") as f: + commit_message = f.read() + for m in re.finditer(r"\[sdl-ci-filter (.*)]", commit_message, flags=re.M): + filters.append(m.group(1).strip(" \t\n\r\t'\"")) + + if re.search(r"\[sdl-ci-artifacts?]", commit_message, flags=re.M): + args.enable_artifacts = True + + if re.search(r"\[sdl-ci-(full-)?trackmem(-symbol-names)?]", commit_message, flags=re.M): + args.trackmem_symbol_names = True + + if not filters: + filters.append("*") + + logger.info("filters: %r", filters) + + all_level_platforms = {} + + all_platforms = {key: spec_to_platform(spec, key=key, enable_artifacts=args.enable_artifacts, trackmem_symbol_names=args.trackmem_symbol_names) for key, spec in JOB_SPECS.items()} + + for level_i, level_keys in enumerate(all_level_keys, 1): + level_key = f"level{level_i}" + logger.info("Level %d: keys=%r", level_i, level_keys) + assert all(k in remaining_keys for k in level_keys) + level_platforms = tuple(all_platforms[key] for key in level_keys) + remaining_keys.difference_update(level_keys) + all_level_platforms[level_key] = level_platforms + logger.info("=" * 80) + + logger.info("Keys before filter: %r", remaining_keys) + + filtered_remaining_keys = set() + for filter in filters: + filtered_remaining_keys.update(fnmatch.filter(remaining_keys, filter)) + + logger.info("Keys after filter: %r", filtered_remaining_keys) + + remaining_keys = filtered_remaining_keys + + logger.info("Remaining: %r", remaining_keys) + all_level_platforms["others"] = tuple(all_platforms[key] for key in remaining_keys) + + if args.github_ci: + for level, platforms in all_level_platforms.items(): + platforms_json = json.dumps(platforms) + txt = f"{args.github_variable_prefix}-{level}={platforms_json}" + logger.info("%s", txt) + if "GITHUB_OUTPUT" in os.environ: + with open(os.environ["GITHUB_OUTPUT"], "a") as f: + f.write(txt) + f.write("\n") + else: + logger.warning("GITHUB_OUTPUT not defined") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) 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 @@ +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 + ${{ (matrix.platform.ccache && format('{0}-ccache', matrix.platform.msys2-env)) || '' }} + - 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-arch }} + sdk: ${{ matrix.platform.msvc-vcvars-sdk }} + - 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: 'Setup Python' + uses: 'actions/setup-python@main' + if: ${{ matrix.platform.setup-python }} + with: + python-version: '3.x' + - name: 'Install PyPI packages' + if: ${{ matrix.platform.pypi-packages != '' }} + run: | + python -m pip install --user ${{ matrix.platform.pypi-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: 'Calculate ccache key' + if: ${{ matrix.platform.ccache }} + id: prepare-restore-ccache + run: | + echo "timestamp=$(date -u "+%Y%m%d%H%M_%S")" >> "$GITHUB_OUTPUT" + - name: 'Restore ccache' + if: ${{ matrix.platform.ccache }} + uses: actions/cache/restore@v4 + id: restore-ccache + with: + path: ${{ runner.temp }}/ccache + key: ccache-${{ matrix.platform.key }}-${{ steps.prepare-restore-ccache.outputs.timestamp }} + restore-keys: | + ccache-${{matrix.platform.key}} + - name: 'Configure ccache' + if: ${{ matrix.platform.ccache }} + run: | + echo 'CCACHE_DIR=${{ runner.temp }}/ccache' >>${GITHUB_ENV} + - name: 'Prepare ccache' + if: ${{ matrix.platform.ccache && steps.restore-ccache.outputs.cache-hit }} + run: | + if [ "x${{ runner.os }}" = "xmacOS" ]; then + touch_date="2025-02-01T12:00:00Z" + else + touch_date="2025-02-01" + fi + find "${CCACHE_DIR}" -type f -exec touch -a -m -d "$touch_date" {} + + ccache -s + ccache -z + + - 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 -G "${{ matrix.platform.cmake-generator }}" \ + -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_INSTALL_DOCS=ON \ + -DSDL_INSTALL_CPACK=ON \ + -DSDL_INSTALL_DOCS=ON \ + ${{ 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('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo ""' }} + echo "Static library:" + ${{ (matrix.platform.static-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.static-lib)) || 'echo ""' }} + - 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: ${{ always() && 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: ${{ always() && 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: ${{ always() && 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.27.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_INSTALL_DOCS=ON \ + ${{ 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: 'Prune old ccache files' + if: ${{ matrix.platform.ccache }} + run: | + ccache --evict-older-than=1d + ccache -s + - name: 'Save ccache' + if: ${{ matrix.platform.ccache }} + uses: actions/cache/save@v4 + with: + path: ${{ runner.temp }}/ccache + key: ${{ steps.restore-ccache.outputs.cache-primary-key }} + - 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 \ No newline at end of file diff --git a/src/contrib/SDL-3.2.20/.github/workflows/release.yml b/src/contrib/SDL-3.2.20/.github/workflows/release.yml new file mode 100644 index 0000000..01eaee9 --- /dev/null +++ b/src/contrib/SDL-3.2.20/.github/workflows/release.yml @@ -0,0 +1,652 @@ +name: 'release' +run-name: 'Create SDL release artifacts for ${{ inputs.commit }}' + +on: + workflow_dispatch: + inputs: + commit: + description: 'Commit of SDL' + required: true + +jobs: + + src: + runs-on: ubuntu-latest + outputs: + project: ${{ steps.releaser.outputs.project }} + version: ${{ steps.releaser.outputs.version }} + src-tar-gz: ${{ steps.releaser.outputs.src-tar-gz }} + src-tar-xz: ${{ steps.releaser.outputs.src-tar-xz }} + src-zip: ${{ steps.releaser.outputs.src-zip }} + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: 'Fetch build-release.py' + uses: actions/checkout@v4 + with: + sparse-checkout: 'build-scripts/build-release.py' + - name: 'Set up SDL sources' + uses: actions/checkout@v4 + with: + path: 'SDL' + fetch-depth: 0 + - name: 'Build Source archive' + id: releaser + shell: bash + run: | + python build-scripts/build-release.py \ + --actions source \ + --commit ${{ inputs.commit }} \ + --root "${{ github.workspace }}/SDL" \ + --github \ + --debug + - name: 'Store source archives' + uses: actions/upload-artifact@v4 + with: + name: sources + path: '${{ github.workspace}}/dist' + - name: 'Generate summary' + run: | + echo "Run the following commands to download all artifacts:" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "mkdir -p /tmp/${{ steps.releaser.outputs.project }}-${{ steps.releaser.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "cd /tmp/${{ steps.releaser.outputs.project }}-${{ steps.releaser.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "gh run -R ${{ github.repository }} download ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + linux-verify: + needs: [src] + runs-on: ubuntu-latest + steps: + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Unzip ${{ needs.src.outputs.src-zip }}' + id: zip + run: | + mkdir /tmp/zipdir + cd /tmp/zipdir + unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}" + echo "path=/tmp/zipdir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: tar + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Compare contents of ${{ needs.src.outputs.src-zip }} and ${{ needs.src.outputs.src-tar-gz }}' + run: | + diff /tmp/zipdir /tmp/tardir + - name: 'Test versioning' + shell: bash + run: | + ${{ steps.tar.outputs.path }}/build-scripts/test-versioning.sh + - name: 'Install Linux dependencies' + run: | + sudo apt-get update -y + sudo apt-get install -y \ + gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev \ + libusb-1.0-0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev \ + libxss-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \ + libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev + - name: 'CMake (configure + build + tests + examples)' + run: | + cmake -S ${{ steps.tar.outputs.path }} -B /tmp/build -DSDL_TEST_LIBRARY=TRUE -DSDL_TESTS=TRUE -DSDL_EXAMPLES=TRUE + cmake --build /tmp/build --verbose + ctest --test-dir /tmp/build --no-tests=error --output-on-failure + + dmg: + needs: [src] + runs-on: macos-latest + outputs: + dmg: ${{ steps.releaser.outputs.dmg }} + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: 'Fetch build-release.py' + uses: actions/checkout@v4 + with: + sparse-checkout: 'build-scripts/build-release.py' + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: tar + run: | + mkdir -p "${{ github.workspace }}/tardir" + tar -C "${{ github.workspace }}/tardir" -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=${{ github.workspace }}/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Build SDL3.dmg' + id: releaser + shell: bash + run: | + python build-scripts/build-release.py \ + --actions dmg \ + --commit ${{ inputs.commit }} \ + --root "${{ steps.tar.outputs.path }}" \ + --github \ + --debug + - name: 'Store DMG image file' + uses: actions/upload-artifact@v4 + with: + name: dmg + path: '${{ github.workspace }}/dist' + + dmg-verify: + needs: [dmg, src] + runs-on: macos-latest + steps: + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Download ${{ needs.dmg.outputs.dmg }}' + uses: actions/download-artifact@v4 + with: + name: dmg + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: src + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Mount ${{ needs.dmg.outputs.dmg }}' + id: mount + run: | + hdiutil attach '${{ github.workspace }}/${{ needs.dmg.outputs.dmg }}' + mount_point="/Volumes/${{ needs.src.outputs.project }}" + if [ ! -d "$mount_point/${{ needs.src.outputs.project }}.xcframework" ]; then + echo "Cannot find ${{ needs.src.outputs.project }}.xcframework!" + exit 1 + fi + echo "mount_point=$mount_point">>$GITHUB_OUTPUT + - name: 'CMake (configure + build) Darwin' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \ + -DCMAKE_SYSTEM_NAME=Darwin \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \ + -Werror=dev \ + -B build_darwin + cmake --build build_darwin --config Release --verbose + + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/macos-arm64_x86_64" \ + -DCMAKE_SYSTEM_NAME=Darwin \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \ + -Werror=dev \ + -B build_darwin_2 + cmake --build build_darwin --config Release --verbose + - name: 'CMake (configure + build) iOS' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \ + -DCMAKE_SYSTEM_NAME=iOS \ + -DCMAKE_OSX_ARCHITECTURES="arm64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -Werror=dev \ + -B build_ios + cmake --build build_ios --config Release --verbose + - name: 'CMake (configure + build) tvOS' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \ + -DCMAKE_SYSTEM_NAME=tvOS \ + -DCMAKE_OSX_ARCHITECTURES="arm64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -Werror=dev \ + -B build_tvos + cmake --build build_tvos --config Release --verbose + - name: 'CMake (configure + build) iOS simulator' + run: | + sysroot=$(xcodebuild -version -sdk iphonesimulator Path) + echo "sysroot=$sysroot" + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \ + -DCMAKE_SYSTEM_NAME=iOS \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCMAKE_OSX_SYSROOT="${sysroot}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -Werror=dev \ + -B build_ios_simulator + cmake --build build_ios_simulator --config Release --verbose + - name: 'CMake (configure + build) tvOS simulator' + run: | + sysroot=$(xcodebuild -version -sdk appletvsimulator Path) + echo "sysroot=$sysroot" + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=FALSE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=FALSE \ + -DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \ + -DCMAKE_SYSTEM_NAME=tvOS \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCMAKE_OSX_SYSROOT="${sysroot}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -Werror=dev \ + -B build_tvos_simulator + cmake --build build_tvos_simulator --config Release --verbose + + msvc: + needs: [src] + runs-on: windows-2025 + outputs: + VC-x86: ${{ steps.releaser.outputs.VC-x86 }} + VC-x64: ${{ steps.releaser.outputs.VC-x64 }} + VC-arm64: ${{ steps.releaser.outputs.VC-arm64 }} + VC-devel: ${{ steps.releaser.outputs.VC-devel }} + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: 'Fetch build-release.py' + uses: actions/checkout@v4 + with: + sparse-checkout: 'build-scripts/build-release.py' + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Unzip ${{ needs.src.outputs.src-zip }}' + id: zip + run: | + New-Item C:\temp -ItemType Directory -ErrorAction SilentlyContinue + cd C:\temp + unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}" + echo "path=C:\temp\${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$Env:GITHUB_OUTPUT + - name: 'Build MSVC binary archives' + id: releaser + run: | + python build-scripts/build-release.py ` + --actions msvc ` + --commit ${{ inputs.commit }} ` + --root "${{ steps.zip.outputs.path }}" ` + --github ` + --debug + - name: 'Store MSVC archives' + uses: actions/upload-artifact@v4 + with: + name: win32 + path: '${{ github.workspace }}/dist' + + msvc-verify: + needs: [msvc, src] + runs-on: windows-latest + steps: + - name: 'Fetch .github/actions/setup-ninja/action.yml' + uses: actions/checkout@v4 + with: + sparse-checkout: '.github/actions/setup-ninja/action.yml' + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Download MSVC binaries' + uses: actions/download-artifact@v4 + with: + name: win32 + path: '${{ github.workspace }}' + - name: 'Unzip ${{ needs.src.outputs.src-zip }}' + id: src + run: | + mkdir '${{ github.workspace }}/sources' + cd '${{ github.workspace }}/sources' + unzip "${{ github.workspace }}/${{ needs.src.outputs.src-zip }}" + echo "path=${{ github.workspace }}/sources/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT + - name: 'Unzip ${{ needs.msvc.outputs.VC-devel }}' + id: bin + run: | + mkdir '${{ github.workspace }}/vc' + cd '${{ github.workspace }}/vc' + unzip "${{ github.workspace }}/${{ needs.msvc.outputs.VC-devel }}" + echo "path=${{ github.workspace }}/vc/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$env:GITHUB_OUTPUT + - name: Set up ninja + uses: ./.github/actions/setup-ninja + - name: 'Configure vcvars x86' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64_x86 + - name: 'CMake (configure + build + tests) x86' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` + -B build_x86 ` + -GNinja ` + -DCMAKE_BUILD_TYPE=Debug ` + -Werror=dev ` + -DTEST_FULL=TRUE ` + -DTEST_STATIC=FALSE ` + -DTEST_SHARED=TRUE ` + -DTEST_TEST=TRUE ` + -DCMAKE_SUPPRESS_REGENERATION=TRUE ` + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" + Start-Sleep -Seconds 2 + cmake --build build_x86 --config Release --verbose + ctest --test-dir build_x86 --no-tests=error -C Release --output-on-failure + - name: 'Configure vcvars x64' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + - name: 'CMake (configure + build + tests) x64' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` + -B build_x64 ` + -GNinja ` + -DCMAKE_BUILD_TYPE=Debug ` + -Werror=dev ` + -DTEST_FULL=TRUE ` + -DTEST_STATIC=FALSE ` + -DTEST_SHARED=TRUE ` + -DTEST_TEST=TRUE ` + -DCMAKE_SUPPRESS_REGENERATION=TRUE ` + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" + Start-Sleep -Seconds 2 + cmake --build build_x64 --config Release --verbose + ctest --test-dir build_x64 --no-tests=error -C Release --output-on-failure + - name: 'Configure vcvars arm64' + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64_arm64 + - name: 'CMake (configure + build) arm64' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` + -B build_arm64 ` + -GNinja ` + -DCMAKE_BUILD_TYPE=Debug ` + -Werror=dev ` + -DTEST_FULL=TRUE ` + -DTEST_STATIC=FALSE ` + -DTEST_SHARED=TRUE ` + -DTEST_TEST=TRUE ` + -DCMAKE_SUPPRESS_REGENERATION=TRUE ` + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" + Start-Sleep -Seconds 2 + cmake --build build_arm64 --config Release --verbose + - name: 'CMake (configure + build) arm64ec' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" ` + -B build_arm64ec ` + -GNinja ` + -DCMAKE_BUILD_TYPE=Debug ` + -Werror=dev ` + -DTEST_FULL=TRUE ` + -DTEST_STATIC=FALSE ` + -DTEST_SHARED=TRUE ` + -DTEST_TEST=TRUE ` + -DSDL_DISABLE_AVX=TRUE ` + -DSDL_DISABLE_AVX2=TRUE ` + -DSDL_DISABLE_AVX512F=TRUE ` + -DCMAKE_SUPPRESS_REGENERATION=TRUE ` + -DCMAKE_C_FLAGS="/arm64EC" ` + -DCMAKE_CXX_FLAGS="/arm64EC" ` + -DCMAKE_EXE_LINKER_FLAGS="/MACHINE:ARM64EC" ` + -DCMAKE_SHARED_LINKER_FLAGS="/MACHINE:ARM64EC" ` + -DCMAKE_STATIC_LINKER_FLAGS="/MACHINE:ARM64EC" ` + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" + Start-Sleep -Seconds 2 + cmake --build build_arm64ec --config Release --verbose + + mingw: + needs: [src] + runs-on: ubuntu-24.04 # FIXME: current ubuntu-latest ships an outdated mingw, replace with ubuntu-latest once 24.04 becomes the new default + outputs: + mingw-devel-tar-gz: ${{ steps.releaser.outputs.mingw-devel-tar-gz }} + mingw-devel-tar-xz: ${{ steps.releaser.outputs.mingw-devel-tar-xz }} + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: 'Fetch build-release.py' + uses: actions/checkout@v4 + with: + sparse-checkout: 'build-scripts/build-release.py' + - name: 'Install Mingw toolchain' + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: tar + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Build MinGW binary archives' + id: releaser + run: | + python build-scripts/build-release.py \ + --actions mingw \ + --commit ${{ inputs.commit }} \ + --root "${{ steps.tar.outputs.path }}" \ + --github \ + --debug + - name: 'Store MinGW archives' + uses: actions/upload-artifact@v4 + with: + name: mingw + path: '${{ github.workspace }}/dist' + + mingw-verify: + needs: [mingw, src] + runs-on: ubuntu-latest + steps: + - name: 'Install Mingw toolchain' + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-mingw-w64 g++-mingw-w64 ninja-build + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Download MinGW binaries' + uses: actions/download-artifact@v4 + with: + name: mingw + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: src + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Untar ${{ needs.mingw.outputs.mingw-devel-tar-gz }}' + id: bin + run: | + mkdir -p /tmp/mingw-tardir + tar -C /tmp/mingw-tardir -v -x -f "${{ github.workspace }}/${{ needs.mingw.outputs.mingw-devel-tar-gz }}" + echo "path=/tmp/mingw-tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'CMake (configure + build) i686' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DCMAKE_BUILD_TYPE="Release" \ + -DTEST_FULL=TRUE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=TRUE \ + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \ + -DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-i686.cmake" \ + -DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \ + -Werror=dev \ + -B build_x86 + cmake --build build_x86 --config Release --verbose + - name: 'CMake (configure + build) x86_64' + run: | + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DCMAKE_BUILD_TYPE="Release" \ + -DTEST_FULL=TRUE \ + -DTEST_STATIC=false \ + -DTEST_TEST=TRUE \ + -DCMAKE_PREFIX_PATH="${{ steps.bin.outputs.path }}" \ + -DCMAKE_TOOLCHAIN_FILE="${{ steps.src.outputs.path }}/build-scripts/cmake-toolchain-mingw64-x86_64.cmake" \ + -DCMAKE_C_FLAGS="-DSDL_DISABLE_SSE4_2" \ + -Werror=dev \ + -B build_x64 + cmake --build build_x64 --config Release --verbose + + android: + needs: [src] + runs-on: ubuntu-latest + outputs: + android-aar: ${{ steps.releaser.outputs.android-aar }} + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: 'Fetch build-release.py' + uses: actions/checkout@v4 + with: + sparse-checkout: 'build-scripts/build-release.py' + - name: 'Setup Android NDK' + uses: nttld/setup-ndk@v1 + with: + local-cache: true + ndk-version: r21e + - name: 'Setup Java JDK' + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '11' + - name: 'Install ninja' + run: | + sudo apt-get update -y + sudo apt-get install -y ninja-build + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: tar + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Build Android prefab binary archive(s)' + id: releaser + run: | + python build-scripts/build-release.py \ + --actions android \ + --commit ${{ inputs.commit }} \ + --root "${{ steps.tar.outputs.path }}" \ + --github \ + --debug + - name: 'Store Android archive(s)' + uses: actions/upload-artifact@v4 + with: + name: android + path: '${{ github.workspace }}/dist' + + android-verify: + needs: [android, src] + runs-on: ubuntu-latest + steps: + - name: 'Set up Python' + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: 'Download source archives' + uses: actions/download-artifact@v4 + with: + name: sources + path: '${{ github.workspace }}' + - name: 'Download Android .aar archive' + uses: actions/download-artifact@v4 + with: + name: android + path: '${{ github.workspace }}' + - name: 'Untar ${{ needs.src.outputs.src-tar-gz }}' + id: src + run: | + mkdir -p /tmp/tardir + tar -C /tmp/tardir -v -x -f "${{ github.workspace }}/${{ needs.src.outputs.src-tar-gz }}" + echo "path=/tmp/tardir/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}" >>$GITHUB_OUTPUT + - name: 'Extract Android SDK from AAR' + id: sdk + run: | + cd /tmp + unzip "${{ github.workspace }}/${{ needs.android.outputs.android-aar }}" + python "${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" -o /tmp/SDL3-android + echo "prefix=/tmp/SDL3-android" >>$GITHUB_OUTPUT + echo "sdl3-aar=/tmp/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" >>$GITHUB_OUTPUT + - name: 'CMake (configure + build) x86, x64, arm32, arm64' + run: | + android_abis="x86 x86_64 armeabi-v7a arm64-v8a" + for android_abi in ${android_abis}; do + echo "Configuring ${android_abi}..." + cmake -S "${{ steps.src.outputs.path }}/cmake/test" \ + -DTEST_FULL=TRUE \ + -DTEST_STATIC=FALSE \ + -DTEST_TEST=TRUE \ + -DCMAKE_PREFIX_PATH="${{ steps.sdk.outputs.prefix }}" \ + -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ + -DANDROID_ABI=${android_abi} \ + -DCMAKE_BUILD_TYPE=Release \ + -B "${android_abi}" + echo "Building ${android_abi}..." + cmake --build "${android_abi}" --config Release --verbose + done + - name: 'Create gradle project' + id: create-gradle-project + run: | + python ${{ steps.src.outputs.path }}/build-scripts/create-android-project.py \ + org.libsdl.testspriteminimal \ + ${{ steps.src.outputs.path }}/test/testspriteminimal.c \ + ${{ steps.src.outputs.path }}/test/icon.h \ + --variant aar \ + --output "/tmp/projects" + echo "path=/tmp/projects/org.libsdl.testspriteminimal" >>$GITHUB_OUTPUT + - name: 'Copy SDL3 aar into Gradle project' + run: | + cp "${{ steps.sdk.outputs.sdl3-aar }}" "${{ steps.create-gradle-project.outputs.path }}/app/libs" + + echo "" + echo "Project contents:" + echo "" + find "${{ steps.create-gradle-project.outputs.path }}" + - name: 'Build app (Gradle & CMake)' + run: | + cd "${{ steps.create-gradle-project.outputs.path }}" + ./gradlew -i assembleRelease -Pandroid.native.buildOutput=verbose -PBUILD_WITH_CMAKE=1 + - name: 'Build app (Gradle & ndk-build)' + run: | + cd "${{ steps.create-gradle-project.outputs.path }}" + ./gradlew -i assembleRelease -Pandroid.native.buildOutput=verbose -- cgit v1.2.3