msvc.yml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. name: Build (MSVC)
  2. on: [push, pull_request]
  3. jobs:
  4. Build:
  5. name: ${{ matrix.platform.name }}
  6. runs-on: windows-latest
  7. strategy:
  8. fail-fast: false
  9. matrix:
  10. platform:
  11. - { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64' }
  12. - { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32' }
  13. - { name: Windows static VCRT (x64), flags: -A x64 -DSDL_FORCE_STATIC_VCRT=ON }
  14. - { name: Windows static VCRT (x86), flags: -A Win32 -DSDL_FORCE_STATIC_VCRT=ON }
  15. - { name: Windows (clang-cl x64), flags: -T ClangCL -A x64 }
  16. - { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32 }
  17. - { name: Windows (ARM), flags: -A ARM }
  18. - { name: Windows (ARM64), flags: -A ARM64 }
  19. - { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF, nowerror: true,
  20. project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
  21. steps:
  22. - uses: actions/checkout@v4
  23. - name: Create CMake project using SDL as a subproject
  24. shell: python
  25. run: |
  26. import os
  27. import textwrap
  28. srcdir = r"${{ github.workspace }}".replace("\\", "/")
  29. builddir = f"{ srcdir }/build"
  30. os.makedirs(builddir)
  31. with open(f"{ builddir }/CMakeLists.txt", "w") as f:
  32. f.write(textwrap.dedent(f"""\
  33. # Always build .PDB symbol file
  34. set(CMAKE_POLICY_DEFAULT_CMP0141 "NEW" CACHE STRING "MSVC debug information format flags are selected by an abstraction")
  35. set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "MSVC debug information format")
  36. set(CMAKE_EXE_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flags for executables")
  37. set(CMAKE_SHARED_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flag for shared libraries")
  38. cmake_minimum_required(VERSION 3.0...3.25)
  39. project(sdl_user)
  40. enable_testing()
  41. add_subdirectory("{ srcdir }" SDL)
  42. """))
  43. - name: Configure (CMake)
  44. run: cmake -S build -B build `
  45. -DSDL_WERROR=${{ !matrix.platform.nowerror }} `
  46. -DSDL_TESTS=ON `
  47. -DSDL_INSTALL_TESTS=ON `
  48. -DSDL_VENDOR_INFO="Github Workflow" `
  49. -DSDL2_DISABLE_INSTALL=OFF `
  50. ${{ matrix.platform.flags }} `
  51. -DCMAKE_INSTALL_PREFIX=prefix
  52. - name: Build (CMake)
  53. run: cmake --build build/ --config Release --parallel
  54. - name: Run build-time tests
  55. if: "! contains(matrix.platform.name, 'ARM')"
  56. run: |
  57. $env:SDL_TESTS_QUICK=1
  58. ctest -VV --test-dir build/ -C Release -j2
  59. - name: Install (CMake)
  60. run: |
  61. echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
  62. cmake --install build/
  63. - name: Verify CMake configuration files
  64. if: ${{ !contains(matrix.platform.name, 'UWP') }} # FIXME: cmake/test/CMakeLists.txt should support UWP
  65. run: |
  66. cmake -S cmake/test -B cmake_config_build `
  67. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} `
  68. ${{ matrix.platform.flags }}
  69. cmake --build cmake_config_build --config Release
  70. - name: Add msbuild to PATH
  71. if: ${{ matrix.platform.project != '' }}
  72. uses: microsoft/setup-msbuild@v2
  73. - name: Build msbuild
  74. if: ${{ matrix.platform.project != '' }}
  75. run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}