main.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: Intel oneAPI (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
  24. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
  25. - { name: Intel Compiler (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
  26. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
  27. - { name: Ubuntu 22.04, os: ubuntu-22.04, shell: sh, artifact: 'SDL-ubuntu22.04' }
  28. - { name: MacOS (Framework) (x86_64), os: macos-12, shell: sh, cmake-platform: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"', cmake: '-DSDL_FRAMEWORK=ON -DSDL_CLANG_TIDY=OFF', skip_test_pkgconfig: true, artifact: 'SDL-macos-framework', no-static: true }
  29. - { name: MacOS (Framework) (arm64), os: macos-latest, shell: sh, cmake-platform: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"', cmake: '-DSDL_FRAMEWORK=ON -DSDL_CLANG_TIDY=OFF', skip_test_pkgconfig: true, no-static: true }
  30. - { name: MacOS (GNU prefix), os: macos-latest, shell: sh, cmake-platform: '-DCMAKE_OSX_ARCHITECTURES="arm64"', cmake: '-DCLANG_TIDY_BINARY="$(brew --prefix llvm)/bin/clang-tidy"', artifact: 'SDL-macos-arm64-gnu' }
  31. - { name: iOS (GNU prefix), os: macos-latest, shell: sh, cmake-platform: '-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"', cross-build: true, skip_test_pkgconfig: true, artifact: 'SDL-ios-gnu' }
  32. - { name: tvOS (GNU prefix), os: macos-latest, shell: sh, cmake-platform: '-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"', cross-build: true, skip_test_pkgconfig: true, artifact: 'SDL-tvos-gnu' }
  33. steps:
  34. - name: Set up MSYS2
  35. if: matrix.platform.shell == 'msys2 {0}'
  36. uses: msys2/setup-msys2@v2
  37. with:
  38. msystem: ${{ matrix.platform.msystem }}
  39. install: >-
  40. ${{ matrix.platform.msys-env }}-cc
  41. ${{ matrix.platform.msys-env }}-cmake
  42. ${{ matrix.platform.msys-env }}-ninja
  43. ${{ matrix.platform.msys-env }}-perl
  44. ${{ matrix.platform.msys-env }}-pkg-config
  45. ${{ matrix.platform.msys-env }}-clang-tools-extra
  46. - name: Setup Linux dependencies
  47. if: runner.os == 'Linux'
  48. run: |
  49. sudo apt-get update
  50. sudo apt-get install build-essential git \
  51. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  52. libaudio-dev libjack-dev libsndio-dev libusb-1.0-0-dev libx11-dev libxext-dev \
  53. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  54. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  55. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  56. - name: Setup extra Ubuntu 22.04 dependencies
  57. if: matrix.platform.os == 'ubuntu-22.04'
  58. run: |
  59. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  60. - name: Setup Macos dependencies
  61. if: runner.os == 'macOS'
  62. run: |
  63. export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
  64. brew update
  65. brew install \
  66. ninja \
  67. pkg-config \
  68. llvm
  69. - name: Setup Intel oneAPI
  70. if: matrix.platform.intel
  71. run: |
  72. # Download the key to system keyring
  73. wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
  74. | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
  75. # Add signed entry to apt sources and configure the APT client to use Intel repository:
  76. echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
  77. # Update package list
  78. sudo apt-get update -y
  79. # Install oneAPI
  80. sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
  81. - uses: actions/checkout@v4
  82. - name: Check that versioning is consistent
  83. # We only need to run this once: arbitrarily use the Linux/CMake build
  84. if: "runner.os == 'Linux'"
  85. run: ./build-scripts/test-versioning.sh
  86. - name: Configure (CMake)
  87. run: |
  88. ${{ matrix.platform.source_cmd }}
  89. cmake -S . -B build -G Ninja \
  90. -Wdeprecated -Wdev -Werror \
  91. -DSDL_SHARED=ON \
  92. -DSDL_STATIC=ON \
  93. -DSDL_TESTS=ON \
  94. -DSDL_WERROR=ON \
  95. -DSDL_INSTALL_TESTS=ON \
  96. -DSDL_VENDOR_INFO="Github Workflow" \
  97. -DSDL_CLANG_TIDY=ON \
  98. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  99. -DCMAKE_BUILD_TYPE=Release \
  100. ${{ matrix.platform.cmake-platform }} \
  101. ${{ matrix.platform.cmake }}
  102. - name: Build (CMake)
  103. id: build
  104. run: |
  105. ${{ matrix.platform.source_cmd }}
  106. cmake --build build/ --config Release --verbose --parallel
  107. - name: Run build-time tests (CMake)
  108. if: ${{ !matrix.platform.cross-build }}
  109. run: |
  110. ${{ matrix.platform.source_cmd }}
  111. set -eu
  112. export SDL_TESTS_QUICK=1
  113. ctest -VV --test-dir build/ -j2
  114. if test "${{ runner.os }}" = "Linux"; then
  115. # This should show us the SDL_REVISION
  116. strings build/libSDL3.so.0 | grep SDL-
  117. fi
  118. - name: Install (CMake)
  119. run: |
  120. ${{ matrix.platform.source_cmd }}
  121. set -eu
  122. cmake --install build/ --config Release
  123. ( cd cmake_prefix; find . ) | LC_ALL=C sort -u
  124. - name: Package (CPack)
  125. if: ${{ always() && steps.build.outcome == 'success' }}
  126. run: |
  127. cmake --build build/ --config Release --target package
  128. - name: Verify CMake configuration files
  129. run: |
  130. ${{ matrix.platform.source_cmd }}
  131. cmake -S cmake/test -B cmake_config_build -G Ninja \
  132. ${{ matrix.platform.cmake-platform }} \
  133. -DTEST_SHARED=ON \
  134. -DTEST_STATIC=${{ !matrix.platform.no-static }} \
  135. -DCMAKE_BUILD_TYPE=Release \
  136. -DCMAKE_PREFIX_PATH=$(echo "${{ github.workspace }}/cmake_prefix" | sed -e 's#\\#/#g')
  137. cmake --build cmake_config_build --verbose
  138. - name: Verify sdl3.pc
  139. if: ${{ !matrix.platform.skip_test_pkgconfig }}
  140. run: |
  141. ${{ matrix.platform.source_cmd }}
  142. export PKG_CONFIG_PATH=$(echo "${{ github.workspace }}/cmake_prefix/lib/pkgconfig" | sed -e 's#\\#/#g')
  143. cmake/test/test_pkgconfig.sh
  144. - uses: actions/upload-artifact@v4
  145. if: ${{ always() && matrix.platform.artifact != '' && steps.build.outcome == 'success' }}
  146. with:
  147. if-no-files-found: error
  148. name: ${{ matrix.platform.artifact }}
  149. path: build/dist/SDL3*