msvc.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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)', vcvars-arch: 'x64', artifact: 'SDL-VC-x64', project: 'VisualC/SDL.sln', projectflags: '/p:Platform=x64', }
  12. - { name: 'Windows (x86)', vcvars-arch: 'x64_x86', artifact: 'SDL-VC-x86', project: 'VisualC/SDL.sln', projectflags: '/p:Platform=Win32', }
  13. - { name: 'Windows static VCRT (x64)', vcvars-arch: 'x64', artifact: 'SDL-static-crt-x64', cmake-args: '-DSDL_FORCE_STATIC_VCRT=ON', }
  14. - { name: 'Windows static VCRT (x86)', vcvars-arch: 'x64_x86', artifact: 'SDL-static-crt-x86', cmake-args: '-DSDL_FORCE_STATIC_VCRT=ON', }
  15. - { name: 'Windows (clang-cl x64)', vcvars-arch: 'x64', artifact: 'SDL-clang-cl-x64', cmake-args: '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl', cppflags: '/clang:-m64', ldflags: '/MACHINE:X64', }
  16. - { name: 'Windows (clang-cl x86)', vcvars-arch: 'x86', artifact: 'SDL-clang-cl-x86', cmake-args: '-DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl', cppflags: '/clang:-m32', ldflags: '/MACHINE:X86', }
  17. - { name: 'Windows (ARM)', vcvars-arch: 'x64_arm', artifact: 'SDL-VC-arm32', vcvars-sdk: '10.0.22621.0'}
  18. - { name: 'Windows (ARM64)', vcvars-arch: 'x64_arm64', artifact: 'SDL-VC-arm64', }
  19. - { name: 'UWP (x64)', vcvars-arch: 'x64', artifact: 'SDL-VC-UWP', cmake-args: '-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF',
  20. project: 'VisualC-WinRT/SDL-UWP.sln', projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0', }
  21. - { name: 'GDK (x64)', vcvars-arch: 'x64', artifact: '', no-cmake: true, gdk: true,
  22. project: 'VisualC-GDK/SDL.sln', projectflags: '/p:Platform=Gaming.Desktop.x64', }
  23. steps:
  24. - uses: actions/checkout@v4
  25. - name: Set up ninja
  26. if: ${{ !matrix.platform.no-cmake }}
  27. uses: ./.github/actions/setup-ninja
  28. - uses: ilammy/msvc-dev-cmd@v1
  29. with:
  30. arch: ${{ matrix.platform.vcvars-arch }}
  31. sdk: ${{ matrix.platform.vcvars-sdk }}
  32. - name: 'Set up Windows GDK Desktop'
  33. uses: ./.github/actions/setup-gdk-desktop
  34. if: ${{ matrix.platform.gdk }}
  35. with:
  36. folder: '${{ github.workspace }}/VisualC-GDK'
  37. - name: Create CMake project using SDL as a subproject
  38. shell: python
  39. if: ${{ !matrix.platform.no-cmake }}
  40. run: |
  41. import os
  42. import textwrap
  43. srcdir = r"${{ github.workspace }}".replace("\\", "/")
  44. builddir = f"{ srcdir }/build"
  45. os.makedirs(builddir)
  46. with open(f"{ builddir }/CMakeLists.txt", "w") as f:
  47. f.write(textwrap.dedent(f"""\
  48. # Always build .PDB symbol file
  49. set(CMAKE_POLICY_DEFAULT_CMP0141 "NEW" CACHE STRING "MSVC debug information format flags are selected by an abstraction")
  50. set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "MSVC debug information format")
  51. set(CMAKE_EXE_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flags for executables")
  52. set(CMAKE_SHARED_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flag for shared libraries")
  53. cmake_minimum_required(VERSION 3.0...3.25)
  54. project(sdl_user)
  55. enable_testing()
  56. add_subdirectory("{ srcdir }" SDL)
  57. """))
  58. - name: Configure (CMake)
  59. id: cmake-configure
  60. if: ${{ !matrix.platform.no-cmake }}
  61. run: cmake -S build -B build -GNinja `
  62. -DCMAKE_BUILD_TYPE=RelWithDebInfo `
  63. -DSDL_WERROR=ON `
  64. -DSDL_TESTS=ON `
  65. -DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" `
  66. -DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" `
  67. -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  68. -DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  69. -DCMAKE_STATIC_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  70. -DSDL_INSTALL_TESTS=ON `
  71. -DSDL_VENDOR_INFO="Github Workflow" `
  72. -DSDL2_DISABLE_INSTALL=OFF `
  73. -DSDLTEST_PROCDUMP=ON `
  74. ${{ matrix.platform.cmake-args }} `
  75. -DCMAKE_INSTALL_PREFIX=prefix
  76. - name: Build (CMake)
  77. id: cmake-build
  78. if: ${{ steps.cmake-configure.outcome == 'success' }}
  79. run: |
  80. cmake --build build/ --config RelWithDebInfo --verbose --parallel -- -k0
  81. - name: Run build-time tests
  82. id: cmake-test
  83. if: ${{ steps.cmake-build.outcome == 'success' && !contains(matrix.platform.name, 'ARM') && !contains(matrix.platform.name, 'UWP') }}
  84. run: |
  85. $env:SDL_TESTS_QUICK=1
  86. ctest -VV --test-dir build/ -C RelWithDebInfo -j2
  87. - name: Install (CMake)
  88. id: cmake-install
  89. if: ${{ steps.cmake-build.outcome == 'success' }}
  90. run: |
  91. echo "SDL2_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
  92. cmake --install build/
  93. - name: Verify CMake configuration files
  94. if: ${{ steps.cmake-install.outcome == 'success' && !contains(matrix.platform.name, 'UWP') }}
  95. run: |
  96. cmake -S cmake/test -B cmake_config_build -GNinja `
  97. -DCMAKE_BUILD_TYPE=RelWithDebInfo `
  98. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} `
  99. -DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" `
  100. -DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" `
  101. -DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  102. -DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  103. -DCMAKE_STATIC_LINKER_FLAGS="${{ matrix.platform.ldflags }}" `
  104. ${{ matrix.platform.cmake-args }}
  105. cmake --build cmake_config_build --config RelWithDebInfo
  106. - name: Add msbuild to PATH
  107. if: ${{ matrix.platform.project != '' }}
  108. uses: microsoft/setup-msbuild@v2
  109. - name: Build msbuild
  110. if: ${{ matrix.platform.project != '' }}
  111. run: |
  112. msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
  113. - uses: actions/upload-artifact@v4
  114. if: ${{ always() && steps.cmake-test.outcome == 'failure' }}
  115. with:
  116. if-no-files-found: ignore
  117. name: '${{ matrix.platform.artifact }}-minidumps'
  118. path: |
  119. build/**/*.dmp
  120. build/**/*.exe
  121. build/**/*.dll
  122. build/**/*.pdb