msvc.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: Build (MSVC)
  2. on: [push, pull_request]
  3. concurrency:
  4. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  5. cancel-in-progress: true
  6. jobs:
  7. Build:
  8. name: ${{ matrix.platform.name }}
  9. runs-on: windows-latest
  10. strategy:
  11. fail-fast: false
  12. matrix:
  13. platform:
  14. - { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64', artifact: 'SDL-VC-x64' }
  15. - { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32', artifact: 'SDL-VC-x86' }
  16. - { name: Windows (clang-cl x64), flags: -T ClangCL -A x64, artifact: 'SDL-clang-cl-x64' }
  17. - { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32, artifact: 'SDL-clang-cl-x86' }
  18. - { name: Windows (ARM), flags: -A ARM, artifact: 'SDL-VC-arm32', notests: true }
  19. - { name: Windows (ARM64), flags: -A ARM64, artifact: 'SDL-VC-arm64', notests: true }
  20. - { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0", nowerror: true, notests: true,
  21. project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0', artifact: 'SDL-VC-UWP' }
  22. steps:
  23. - uses: actions/checkout@v4
  24. - name: Create CMake project using SDL as a subproject
  25. shell: python
  26. run: |
  27. import os
  28. import textwrap
  29. srcdir = r"${{ github.workspace }}".replace("\\", "/")
  30. builddir = f"{ srcdir }/build"
  31. os.makedirs(builddir)
  32. cmakelists_txt = 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. print(cmakelists_txt)
  44. with open(f"{ builddir }/CMakeLists.txt", "w") as f:
  45. f.write(cmakelists_txt)
  46. - name: Configure (CMake)
  47. run: cmake -S build -B build `
  48. -Wdeprecated -Wdev -Werror `
  49. -DSDL_WERROR=${{ !matrix.platform.nowerror }} `
  50. -DSDL_SHARED=ON `
  51. -DSDL_STATIC=ON `
  52. -DSDL_TESTS=ON `
  53. -DSDL_INSTALL_TESTS=ON `
  54. -DSDL_VENDOR_INFO="Github Workflow" `
  55. -DSDL_DISABLE_INSTALL=OFF `
  56. -DSDL_DISABLE_INSTALL_CPACK=OFF `
  57. -DSDL_DISABLE_INSTALL_DOCS=OFF `
  58. ${{ matrix.platform.flags }} `
  59. -DCMAKE_INSTALL_PREFIX=prefix
  60. - name: Build (CMake)
  61. id: build
  62. run: |
  63. cmake --build build/ --config Release --parallel
  64. - name: Run build-time tests
  65. if: ${{ !matrix.platform.notests }}
  66. run: |
  67. $env:SDL_TESTS_QUICK=1
  68. ctest -VV --test-dir build/ -C Release -j2
  69. - name: Install (CMake)
  70. run: |
  71. echo "SDL3_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
  72. cmake --install build/
  73. - name: Package (CPack)
  74. if: ${{ always() && steps.build.outcome == 'success' }}
  75. run: |
  76. cmake --build build/ --config Release --target PACKAGE
  77. - name: Verify CMake configuration files
  78. run: |
  79. cmake -S cmake/test -B cmake_config_build `
  80. -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} `
  81. ${{ matrix.platform.flags }}
  82. cmake --build cmake_config_build --config Release
  83. - name: Add msbuild to PATH
  84. if: ${{ matrix.platform.project != '' }}
  85. uses: microsoft/setup-msbuild@v1.1.3
  86. - name: Build msbuild
  87. if: ${{ matrix.platform.project != '' }}
  88. run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
  89. - uses: actions/upload-artifact@v4
  90. if: ${{ always() && steps.build.outcome == 'success' }}
  91. with:
  92. if-no-files-found: error
  93. name: ${{ matrix.platform.artifact }}
  94. path: build/dist/SDL3*