Skip to content

Commit

Permalink
Merge branch 'SDL2' into dreamcastSDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
GPF committed Aug 14, 2024
2 parents 0fdc589 + 70890b1 commit 9c9e69f
Show file tree
Hide file tree
Showing 153 changed files with 2,095 additions and 647 deletions.
82 changes: 82 additions & 0 deletions .github/actions/setup-gdk-desktop/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
62 changes: 62 additions & 0 deletions .github/actions/setup-ninja/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
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 }}
uses: actions/cache/save@v4
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Extract libusb'
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
4 changes: 2 additions & 2 deletions .github/workflows/cpactions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build
uses: cross-platform-actions/action@v0.23.0
uses: cross-platform-actions/action@v0.24.0
with:
operating_system: freebsd
version: '13.2'
version: '13.3'
shell: bash
run: |
sudo pkg update
Expand Down
85 changes: 65 additions & 20 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,35 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64' }
- { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32' }
- { name: Windows static VCRT (x64), flags: -A x64 -DSDL_FORCE_STATIC_VCRT=ON }
- { name: Windows static VCRT (x86), flags: -A Win32 -DSDL_FORCE_STATIC_VCRT=ON }
- { name: Windows (clang-cl x64), flags: -T ClangCL -A x64 }
- { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32 }
- { name: Windows (ARM), flags: -A ARM }
- { name: Windows (ARM64), flags: -A ARM64 }
- { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF, nowerror: true,
project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
- { name: 'Windows (x64)', vcvars: 'x64', artifact: 'SDL-VC-x64', project: 'VisualC/SDL.sln', projectflags: '/p:Platform=x64', }
- { name: 'Windows (x86)', vcvars: 'x64_x86', artifact: 'SDL-VC-x86', project: 'VisualC/SDL.sln', projectflags: '/p:Platform=Win32', }
- { name: 'Windows static VCRT (x64)', vcvars: 'x64', artifact: 'SDL-static-crt-x64', cmake-args: '-DSDL_FORCE_STATIC_VCRT=ON', }
- { name: 'Windows static VCRT (x86)', vcvars: 'x64_x86', artifact: 'SDL-static-crt-x86', cmake-args: '-DSDL_FORCE_STATIC_VCRT=ON', }
- { name: 'Windows (clang-cl x64)', vcvars: 'x64', artifact: 'SDL-clang-cl-x64', cmake-args: '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl', cppflags: '/clang:-m64', ldflags: '/MACHINE:X64', }
- { name: 'Windows (clang-cl x86)', vcvars: 'x86', artifact: 'SDL-clang-cl-x86', cmake-args: '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl', cppflags: '/clang:-m32', ldflags: '/MACHINE:X86', }
- { name: 'Windows (ARM)', vcvars: 'x64_arm', artifact: 'SDL-VC-arm32', }
- { name: 'Windows (ARM64)', vcvars: 'x64_arm64', artifact: 'SDL-VC-arm64', }
- { name: 'UWP (x64)', vcvars: 'x64', artifact: 'SDL-VC-UWP', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF',
project: 'VisualC-WinRT/SDL-UWP.sln', projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0', }
- { name: 'GDK (x64)', vcvars: 'x64', artifact: '', no-cmake: true, gdk: true,
project: 'VisualC-GDK/SDL.sln', projectflags: '/p:Platform=Gaming.Desktop.x64', }

steps:
- uses: actions/checkout@v4
- name: Set up ninja
if: ${{ !matrix.platform.no-cmake }}
uses: ./.github/actions/setup-ninja
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.platform.vcvars }}
- name: 'Set up Windows GDK Desktop'
uses: ./.github/actions/setup-gdk-desktop
if: ${{ matrix.platform.gdk }}
with:
folder: '${{ github.workspace }}/VisualC-GDK'
- name: Create CMake project using SDL as a subproject
shell: python
if: ${{ !matrix.platform.no-cmake }}
run: |
import os
import textwrap
Expand All @@ -45,36 +59,67 @@ jobs:
add_subdirectory("{ srcdir }" SDL)
"""))
- name: Configure (CMake)
run: cmake -S build -B build `
-DSDL_WERROR=${{ !matrix.platform.nowerror }} `
id: cmake-configure
if: ${{ !matrix.platform.no-cmake }}
run: cmake -S build -B build -GNinja `
-DCMAKE_BUILD_TYPE=Release `
-DSDL_WERROR=ON `
-DSDL_TESTS=ON `
-DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" `
-DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" `
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
-DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
-DCMAKE_STATIC_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
-DSDL_INSTALL_TESTS=ON `
-DSDL_VENDOR_INFO="Github Workflow" `
-DSDL2_DISABLE_INSTALL=OFF `
${{ matrix.platform.flags }} `
-DSDLTEST_PROCDUMP=ON `
${{ matrix.platform.cmake-args }} `
-DCMAKE_INSTALL_PREFIX=prefix
- name: Build (CMake)
run: cmake --build build/ --config Release --parallel
id: cmake-build
if: ${{ steps.cmake-configure.outcome == 'success' }}
run: |
cmake --build build/ --config Release --verbose --parallel -- -k0
- name: Run build-time tests
if: "! contains(matrix.platform.name, 'ARM')"
id: cmake-test
if: ${{ steps.cmake-build.outcome == 'success' && !contains(matrix.platform.name, 'ARM') && !contains(matrix.platform.name, 'UWP') }}
run: |
$env:SDL_TESTS_QUICK=1
ctest -VV --test-dir build/ -C Release -j2
- name: Install (CMake)
id: cmake-install
if: ${{ steps.cmake-build.outcome == 'success' }}
run: |
echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
cmake --install build/
- name: Verify CMake configuration files
if: ${{ !contains(matrix.platform.name, 'UWP') }} # FIXME: cmake/test/CMakeLists.txt should support UWP
if: ${{ steps.cmake-install.outcome == 'success' && !contains(matrix.platform.name, 'UWP') }}
run: |
cmake -S cmake/test -B cmake_config_build `
cmake -S cmake/test -B cmake_config_build -GNinja `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} `
${{ matrix.platform.flags }}
-DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" `
-DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" `
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
-DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
-DCMAKE_STATIC_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
${{ matrix.platform.cmake-args }}
cmake --build cmake_config_build --config Release
- name: Add msbuild to PATH
if: ${{ matrix.platform.project != '' }}
uses: microsoft/setup-msbuild@v2
- name: Build msbuild
if: ${{ matrix.platform.project != '' }}
run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
run: |
msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
- uses: actions/upload-artifact@v4
if: ${{ always() && steps.cmake-test.outcome == 'failure' }}
with:
if-no-files-found: ignore
name: '${{ matrix.platform.artifact }}-minidumps'
path: |
build/**/*.dmp
build/**/*.exe
build/**/*.dll
build/**/*.pdb
Loading

0 comments on commit 9c9e69f

Please sign in to comment.