mirror of https://github.com/libsdl-org/SDL.git
126 lines
6.3 KiB
YAML
126 lines
6.3 KiB
YAML
name: Build (MSVC)
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
Build:
|
|
name: ${{ matrix.platform.name }}
|
|
runs-on: windows-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
platform:
|
|
- { 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
|
|
srcdir = r"${{ github.workspace }}".replace("\\", "/")
|
|
builddir = f"{ srcdir }/build"
|
|
os.makedirs(builddir)
|
|
with open(f"{ builddir }/CMakeLists.txt", "w") as f:
|
|
f.write(textwrap.dedent(f"""\
|
|
# Always build .PDB symbol file
|
|
set(CMAKE_POLICY_DEFAULT_CMP0141 "NEW" CACHE STRING "MSVC debug information format flags are selected by an abstraction")
|
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "MSVC debug information format")
|
|
set(CMAKE_EXE_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flags for executables")
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flag for shared libraries")
|
|
cmake_minimum_required(VERSION 3.0...3.25)
|
|
project(sdl_user)
|
|
enable_testing()
|
|
add_subdirectory("{ srcdir }" SDL)
|
|
"""))
|
|
- name: Configure (CMake)
|
|
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 `
|
|
-DSDLTEST_PROCDUMP=ON `
|
|
${{ matrix.platform.cmake-args }} `
|
|
-DCMAKE_INSTALL_PREFIX=prefix
|
|
- name: Build (CMake)
|
|
id: cmake-build
|
|
if: ${{ steps.cmake-configure.outcome == 'success' }}
|
|
run: |
|
|
cmake --build build/ --config Release --verbose --parallel -- -k0
|
|
- name: Run build-time tests
|
|
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: ${{ steps.cmake-install.outcome == 'success' && !contains(matrix.platform.name, 'UWP') }}
|
|
run: |
|
|
cmake -S cmake/test -B cmake_config_build -GNinja `
|
|
-DCMAKE_BUILD_TYPE=Release `
|
|
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} `
|
|
-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 }}
|
|
- 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
|