1
0

msvc.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 static VCRT (x64), flags: -A x64 -DSDL_FORCE_STATIC_VCRT=ON, artifact: 'SDL-VC-static-VCRT-x64' }
  17. - { name: Windows static VCRT (x86), flags: -A Win32 -DSDL_FORCE_STATIC_VCRT=ON, artifact: 'SDL-VC-static-VCRT-x86' }
  18. - { name: Windows (clang-cl x64), flags: -T ClangCL -A x64, artifact: 'SDL-clang-cl-x64' }
  19. - { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32, artifact: 'SDL-clang-cl-x86' }
  20. - { name: Windows (ARM), flags: -A ARM, artifact: 'SDL-VC-arm32', notests: true }
  21. - { name: Windows (ARM64), flags: -A ARM64, artifact: 'SDL-VC-arm64', notests: true }
  22. - { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0", nowerror: true, notests: true,
  23. project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0', artifact: 'SDL-VC-UWP' }
  24. steps:
  25. - uses: actions/checkout@v3
  26. - name: Create CMake project using SDL as a subproject
  27. shell: python
  28. run: |
  29. import os
  30. import textwrap
  31. srcdir = r"${{ github.workspace }}".replace("\\", "/")
  32. builddir = f"{ srcdir }/build"
  33. os.makedirs(builddir)
  34. cmakelists_txt = textwrap.dedent(f"""\
  35. # Always build .PDB symbol file
  36. set(CMAKE_POLICY_DEFAULT_CMP0141 "NEW" CACHE STRING "MSVC debug information format flags are selected by an abstraction")
  37. set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "MSVC debug information format")
  38. set(CMAKE_EXE_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flags for executables")
  39. set(CMAKE_SHARED_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flag for shared libraries")
  40. cmake_minimum_required(VERSION 3.0...3.25)
  41. project(sdl_user)
  42. enable_testing()
  43. add_subdirectory("{ srcdir }" SDL)
  44. """)
  45. print(cmakelists_txt)
  46. with open(f"{ builddir }/CMakeLists.txt", "w") as f:
  47. f.write(cmakelists_txt)
  48. - name: Configure (CMake)
  49. run: cmake -S build -B build `
  50. -Wdeprecated -Wdev -Werror `
  51. -DSDL_WERROR=${{ !matrix.platform.nowerror }} `
  52. -DSDL_SHARED=ON `
  53. -DSDL_STATIC=ON `
  54. -DSDL_TESTS=ON `
  55. -DSDL_INSTALL_TESTS=ON `
  56. -DSDL_VENDOR_INFO="Github Workflow" `
  57. -DSDL_DISABLE_INSTALL=OFF `
  58. -DSDL_DISABLE_INSTALL_CPACK=OFF `
  59. -DSDL_DISABLE_INSTALL_DOCS=OFF `
  60. ${{ matrix.platform.flags }} `
  61. -DCMAKE_INSTALL_PREFIX=prefix
  62. - name: Build (CMake)
  63. id: build
  64. run: |
  65. cmake --build build/ --config Release --parallel
  66. - name: Run build-time tests
  67. if: ${{ !matrix.platform.notests }}
  68. run: |
  69. $env:SDL_TESTS_QUICK=1
  70. ctest -VV --test-dir build/ -C Release -j2
  71. - name: Install (CMake)
  72. run: |
  73. echo "SDL3_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
  74. cmake --install build/
  75. - name: Package (CPack)
  76. if: ${{ always() && steps.build.outcome == 'success' }}
  77. run: |
  78. cmake --build build/ --config Release --target PACKAGE
  79. - name: Verify CMake configuration files
  80. run: |
  81. cmake -S cmake/test -B cmake_config_build `
  82. -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} `
  83. ${{ matrix.platform.flags }}
  84. cmake --build cmake_config_build --config Release
  85. - name: Add msbuild to PATH
  86. if: ${{ matrix.platform.project != '' }}
  87. uses: microsoft/setup-msbuild@v1.1.3
  88. - name: Build msbuild
  89. if: ${{ matrix.platform.project != '' }}
  90. run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
  91. - uses: actions/upload-artifact@v3
  92. if: ${{ always() && steps.build.outcome == 'success' }}
  93. with:
  94. if-no-files-found: error
  95. name: ${{ matrix.platform.artifact }}
  96. path: build/dist/SDL3*