main.yml 7.2 KB

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