main.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 -DSDL_CLANG_TIDY=OFF', skip_test_pkgconfig: true, artifact: 'SDL-macos-framework' }
  25. - { name: MacOS (GNU prefix), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64" -DCLANG_TIDY_BINARY="$(brew --prefix llvm)/bin/clang-tidy"', 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. ${{ matrix.platform.msys-env }}-clang-tools-extra
  38. - name: Setup Linux dependencies
  39. if: runner.os == 'Linux'
  40. run: |
  41. sudo apt-get update
  42. sudo apt-get install build-essential git \
  43. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  44. libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
  45. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  46. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  47. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  48. - name: Setup extra Ubuntu 22.04 dependencies
  49. if: matrix.platform.os == 'ubuntu-22.04'
  50. run: |
  51. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  52. - name: Setup Macos dependencies
  53. if: runner.os == 'macOS'
  54. run: |
  55. brew install \
  56. ninja \
  57. pkg-config \
  58. llvm
  59. - uses: actions/checkout@v3
  60. - name: Check that versioning is consistent
  61. # We only need to run this once: arbitrarily use the Linux/CMake build
  62. if: "runner.os == 'Linux'"
  63. run: ./build-scripts/test-versioning.sh
  64. - name: Configure (CMake)
  65. run: |
  66. cmake -S . -B build -G Ninja \
  67. -Wdeprecated -Wdev -Werror \
  68. -DSDL_SHARED=ON \
  69. -DSDL_STATIC=ON \
  70. -DSDL_TESTS=ON \
  71. -DSDL_WERROR=ON \
  72. -DSDL_INSTALL_TESTS=ON \
  73. -DSDL_VENDOR_INFO="Github Workflow" \
  74. -DSDL_CLANG_TIDY=ON \
  75. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  76. -DCMAKE_BUILD_TYPE=Release \
  77. ${{ matrix.platform.cmake }}
  78. - name: Build (CMake)
  79. run: |
  80. cmake --build build/ --config Release --verbose --parallel
  81. - name: Run build-time tests (CMake)
  82. run: |
  83. set -eu
  84. export SDL_TESTS_QUICK=1
  85. ctest -VV --test-dir build/
  86. if test "${{ runner.os }}" = "Linux"; then
  87. # This should show us the SDL_REVISION
  88. strings build/libSDL3.so.0 | grep SDL-
  89. fi
  90. - name: Install (CMake)
  91. run: |
  92. set -eu
  93. cmake --install build/ --config Release
  94. ( cd cmake_prefix; find . ) | LC_ALL=C sort -u
  95. - name: Package (CPack)
  96. run: |
  97. cmake --build build/ --config Release --target package
  98. - name: Verify CMake configuration files
  99. run: |
  100. cmake -S cmake/test -B cmake_config_build -G Ninja \
  101. -DTEST_SHARED=ON \
  102. -DTEST_STATIC=ON \
  103. -DCMAKE_BUILD_TYPE=Release \
  104. -DCMAKE_PREFIX_PATH=$(echo "${{ github.workspace }}/cmake_prefix" | sed -e 's#\\#/#g')
  105. cmake --build cmake_config_build --verbose
  106. - name: Verify sdl3.pc
  107. if: ${{ !matrix.platform.skip_test_pkgconfig }}
  108. run: |
  109. export PKG_CONFIG_PATH=$(echo "${{ github.workspace }}/cmake_prefix/lib/pkgconfig" | sed -e 's#\\#/#g')
  110. cmake/test/test_pkgconfig.sh
  111. - uses: actions/upload-artifact@v3
  112. with:
  113. if-no-files-found: error
  114. name: ${{ matrix.platform.artifact }}
  115. path: build/dist/SDL3*