main.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. name: Build
  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: ${{ matrix.platform.os }}
  10. defaults:
  11. run:
  12. shell: ${{ matrix.platform.shell }}
  13. strategy:
  14. fail-fast: false
  15. matrix:
  16. platform:
  17. - { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, artifact: 'SDL-mingw32' }
  18. - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, artifact: 'SDL-mingw64' }
  19. - { name: Windows (clang32), os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686, artifact: 'SDL-msys2-clang32' }
  20. - { name: Windows (clang64), os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64, artifact: 'SDL-msys2-clang64' }
  21. - { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64, artifact: 'SDL-msys2-ucrt64' }
  22. - { name: Ubuntu 20.04, os: ubuntu-20.04, shell: sh, artifact: 'SDL-ubuntu20.04' }
  23. - { name: Ubuntu 22.04, os: ubuntu-22.04, shell: sh, artifact: 'SDL-ubuntu22.04' }
  24. - { name: MacOS (Framework), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DSDL_FRAMEWORK=ON', skip_test_pkgconfig: true, artifact: 'SDL-macos-framework' }
  25. - { name: MacOS (GNU prefix), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64"', artifact: 'SDL-macos-gnu' }
  26. steps:
  27. - name: Set up MSYS2
  28. if: matrix.platform.shell == 'msys2 {0}'
  29. uses: msys2/setup-msys2@v2
  30. with:
  31. msystem: ${{ matrix.platform.msystem }}
  32. install: >-
  33. ${{ matrix.platform.msys-env }}-cc
  34. ${{ matrix.platform.msys-env }}-cmake
  35. ${{ matrix.platform.msys-env }}-ninja
  36. ${{ matrix.platform.msys-env }}-pkg-config
  37. - name: Setup Linux dependencies
  38. if: runner.os == 'Linux'
  39. run: |
  40. sudo apt-get update
  41. sudo apt-get install build-essential git \
  42. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  43. libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
  44. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  45. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  46. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  47. - name: Setup extra Ubuntu 22.04 dependencies
  48. if: matrix.platform.os == 'ubuntu-22.04'
  49. run: |
  50. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  51. - name: Setup Macos dependencies
  52. if: runner.os == 'macOS'
  53. run: |
  54. brew install \
  55. ninja
  56. - uses: actions/checkout@v3
  57. - name: Check that versioning is consistent
  58. # We only need to run this once: arbitrarily use the Linux/CMake build
  59. if: "runner.os == 'Linux'"
  60. run: ./build-scripts/test-versioning.sh
  61. - name: Configure (CMake)
  62. run: |
  63. cmake -S . -B build -G Ninja \
  64. -Wdeprecated -Wdev -Werror \
  65. -DSDL_TESTS=ON \
  66. -DSDL_WERROR=ON \
  67. -DSDL_INSTALL_TESTS=ON \
  68. -DSDL_VENDOR_INFO="Github Workflow" \
  69. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  70. -DCMAKE_BUILD_TYPE=Release \
  71. ${{ matrix.platform.cmake }}
  72. - name: Build (CMake)
  73. run: |
  74. cmake --build build/ --config Release --verbose --parallel
  75. - name: Run build-time tests (CMake)
  76. run: |
  77. set -eu
  78. export SDL_TESTS_QUICK=1
  79. ctest -VV --test-dir build/
  80. if test "${{ runner.os }}" = "Linux"; then
  81. # This should show us the SDL_REVISION
  82. strings build/libSDL3.so.0 | grep SDL-
  83. fi
  84. - name: Install (CMake)
  85. run: |
  86. set -eu
  87. cmake --install build/ --config Release
  88. ( cd cmake_prefix; find . ) | LC_ALL=C sort -u
  89. - name: Package (CPack)
  90. run: |
  91. cmake --build build/ --config Release --target package
  92. - name: Verify CMake configuration files
  93. run: |
  94. cmake -S cmake/test -B cmake_config_build -G Ninja \
  95. -DTEST_SHARED=ON \
  96. -DTEST_STATIC=ON \
  97. -DCMAKE_BUILD_TYPE=Release \
  98. -DCMAKE_PREFIX_PATH=$(echo "${{ github.workspace }}/cmake_prefix" | sed -e 's#\\#/#g')
  99. cmake --build cmake_config_build --verbose
  100. - name: Verify sdl3.pc
  101. if: ${{ !matrix.platform.skip_test_pkgconfig }}
  102. run: |
  103. export PKG_CONFIG_PATH=$(echo "${{ github.workspace }}/cmake_prefix/lib/pkgconfig" | sed -e 's#\\#/#g')
  104. cmake/test/test_pkgconfig.sh
  105. - uses: actions/upload-artifact@v3
  106. with:
  107. if-no-files-found: error
  108. name: ${{ matrix.platform.artifact }}
  109. path: build/dist/SDL3*