main.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. brew install \
  61. ninja \
  62. pkg-config \
  63. llvm
  64. - name: Setup Intel oneAPI
  65. if: matrix.platform.intel
  66. run: |
  67. # Setup oneAPI repo
  68. wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
  69. sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
  70. sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
  71. sudo apt-get update -y
  72. # Install oneAPI
  73. sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
  74. - uses: actions/checkout@v3
  75. - name: Check that versioning is consistent
  76. # We only need to run this once: arbitrarily use the Linux/CMake build
  77. if: "runner.os == 'Linux'"
  78. run: ./build-scripts/test-versioning.sh
  79. - name: Configure (CMake)
  80. run: |
  81. ${{ matrix.platform.source_cmd }}
  82. cmake -S . -B build -G Ninja \
  83. -Wdeprecated -Wdev -Werror \
  84. -DSDL_SHARED=ON \
  85. -DSDL_STATIC=ON \
  86. -DSDL_TESTS=ON \
  87. -DSDL_WERROR=ON \
  88. -DSDL_INSTALL_TESTS=ON \
  89. -DSDL_VENDOR_INFO="Github Workflow" \
  90. -DSDL_CLANG_TIDY=ON \
  91. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  92. -DCMAKE_BUILD_TYPE=Release \
  93. ${{ matrix.platform.cmake }}
  94. - name: Build (CMake)
  95. id: build
  96. run: |
  97. ${{ matrix.platform.source_cmd }}
  98. cmake --build build/ --config Release --verbose --parallel
  99. - name: Run build-time tests (CMake)
  100. run: |
  101. ${{ matrix.platform.source_cmd }}
  102. set -eu
  103. export SDL_TESTS_QUICK=1
  104. ctest -VV --test-dir build/ -j2
  105. if test "${{ runner.os }}" = "Linux"; then
  106. # This should show us the SDL_REVISION
  107. strings build/libSDL3.so.0 | grep SDL-
  108. fi
  109. - name: Install (CMake)
  110. run: |
  111. ${{ matrix.platform.source_cmd }}
  112. set -eu
  113. cmake --install build/ --config Release
  114. ( cd cmake_prefix; find . ) | LC_ALL=C sort -u
  115. - name: Package (CPack)
  116. if: ${{ always() && steps.build.outcome == 'success' }}
  117. run: |
  118. cmake --build build/ --config Release --target package
  119. - name: Verify CMake configuration files
  120. run: |
  121. ${{ matrix.platform.source_cmd }}
  122. cmake -S cmake/test -B cmake_config_build -G Ninja \
  123. -DTEST_SHARED=ON \
  124. -DTEST_STATIC=${{ !matrix.platform.no-static }} \
  125. -DCMAKE_BUILD_TYPE=Release \
  126. -DCMAKE_PREFIX_PATH=$(echo "${{ github.workspace }}/cmake_prefix" | sed -e 's#\\#/#g')
  127. cmake --build cmake_config_build --verbose
  128. - name: Verify sdl3.pc
  129. if: ${{ !matrix.platform.skip_test_pkgconfig }}
  130. run: |
  131. ${{ matrix.platform.source_cmd }}
  132. export PKG_CONFIG_PATH=$(echo "${{ github.workspace }}/cmake_prefix/lib/pkgconfig" | sed -e 's#\\#/#g')
  133. cmake/test/test_pkgconfig.sh
  134. - uses: actions/upload-artifact@v3
  135. if: ${{ always() && steps.build.outcome == 'success' }}
  136. with:
  137. if-no-files-found: error
  138. name: ${{ matrix.platform.artifact }}
  139. path: build/dist/SDL3*