main.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. name: Build
  2. on: [push, pull_request]
  3. jobs:
  4. Build:
  5. name: ${{ matrix.platform.name }}
  6. runs-on: ${{ matrix.platform.os }}
  7. defaults:
  8. run:
  9. shell: ${{ matrix.platform.shell }}
  10. strategy:
  11. fail-fast: false
  12. matrix:
  13. platform:
  14. - { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
  15. - { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
  16. - { name: Windows (clang32), os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686 }
  17. - { name: Windows (clang64), os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64 }
  18. - { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64 }
  19. - { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh }
  20. - { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
  21. - { name: Intel oneAPI (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
  22. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
  23. - { name: Intel Compiler (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
  24. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
  25. - { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
  26. - { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
  27. - { name: iOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES="arm64"', cross: true, test-pkg-config: false }
  28. - { name: tvOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_ARCHITECTURES="arm64"', cross: true, test-pkg-config: false }
  29. - { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
  30. - { name: MacOS (autotools), os: macos-latest, shell: sh, autotools: true }
  31. steps:
  32. - name: Set up MSYS2
  33. if: matrix.platform.shell == 'msys2 {0}'
  34. uses: msys2/setup-msys2@v2
  35. with:
  36. msystem: ${{ matrix.platform.msystem }}
  37. install: >-
  38. ${{ matrix.platform.msys-env }}-cc
  39. ${{ matrix.platform.msys-env }}-cmake
  40. ${{ matrix.platform.msys-env }}-ninja
  41. ${{ matrix.platform.msys-env }}-pkg-config
  42. - name: Setup Linux dependencies
  43. if: runner.os == 'Linux'
  44. run: |
  45. sudo apt-get update
  46. sudo apt-get install build-essential git make autoconf automake libtool \
  47. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  48. libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
  49. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  50. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  51. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  52. - name: Setup extra Ubuntu 22.04 dependencies
  53. if: matrix.platform.os == 'ubuntu-22.04'
  54. run: |
  55. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  56. - name: Setup Macos dependencies
  57. if: runner.os == 'macOS'
  58. run: |
  59. brew install \
  60. autoconf \
  61. ninja \
  62. pkg-config
  63. - name: Setup Intel oneAPI
  64. if: matrix.platform.intel
  65. run: |
  66. # Download the key to system keyring
  67. wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
  68. | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
  69. # Add signed entry to apt sources and configure the APT client to use Intel repository:
  70. 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
  71. # Update package list
  72. sudo apt-get update -y
  73. # Install oneAPI
  74. sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
  75. - uses: actions/checkout@v4
  76. - name: Check that versioning is consistent
  77. # We only need to run this once: arbitrarily use the Linux/CMake build
  78. if: "runner.os == 'Linux' && ! matrix.platform.autotools"
  79. run: ./build-scripts/test-versioning.sh
  80. - name: Configure (CMake)
  81. if: "! matrix.platform.autotools"
  82. run: |
  83. ${{ matrix.platform.source_cmd }}
  84. cmake -S . -B build -G Ninja \
  85. -DSDL_TESTS=ON \
  86. -DSDL_WERROR=ON \
  87. -DSDL_INSTALL_TESTS=ON \
  88. -DSDL_VENDOR_INFO="Github Workflow" \
  89. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  90. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  91. ${{ matrix.platform.cmake }}
  92. - name: Build (CMake)
  93. if: "! matrix.platform.autotools"
  94. run: |
  95. ${{ matrix.platform.source_cmd }}
  96. cmake --build build/ --config RelWithDebInfo --verbose --parallel
  97. - name: Run build-time tests (CMake)
  98. if: ${{ ! matrix.platform.autotools && !matrix.platform.cross }}
  99. run: |
  100. ${{ matrix.platform.source_cmd }}
  101. set -eu
  102. export SDL_TESTS_QUICK=1
  103. ctest -VV --test-dir build/ -j2
  104. if test "${{ runner.os }}" = "Linux"; then
  105. # This should show us the SDL_REVISION
  106. strings build/libSDL2-2.0.so.0 | grep SDL-
  107. fi
  108. - name: Install (CMake)
  109. if: "! matrix.platform.autotools"
  110. run: |
  111. set -eu
  112. cmake --install build/ --config RelWithDebInfo
  113. echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
  114. ( cd cmake_prefix; find ) | LC_ALL=C sort -u
  115. - name: Configure (Autotools)
  116. if: matrix.platform.autotools
  117. run: |
  118. ${{ matrix.platform.source_cmd }}
  119. set -eu
  120. rm -fr build-autotools
  121. mkdir build-autotools
  122. ./autogen.sh
  123. (
  124. cd build-autotools
  125. ${{ github.workspace }}/configure \
  126. --enable-vendor-info="Github Workflow" \
  127. --enable-werror \
  128. --prefix=${{ github.workspace }}/autotools_prefix \
  129. )
  130. if test "${{ runner.os }}" != "macOS" ; then
  131. curdir="$(pwd)"
  132. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  133. (
  134. mkdir -p build-autotools/test
  135. cd build-autotools/test
  136. ${{ github.workspace }}/test/configure \
  137. --enable-werror \
  138. --x-includes=/usr/include \
  139. --x-libraries="/usr/lib/${multiarch}" \
  140. --prefix=${{ github.workspace }}/autotools_prefix \
  141. SDL_CFLAGS="-I${curdir}/include" \
  142. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  143. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  144. ${NULL+}
  145. )
  146. fi
  147. - name: Build (Autotools)
  148. if: matrix.platform.autotools
  149. run: |
  150. ${{ matrix.platform.source_cmd }}
  151. set -eu
  152. parallel="$(getconf _NPROCESSORS_ONLN)"
  153. make -j"${parallel}" -C build-autotools V=1
  154. if test "${{ runner.os }}" != "macOS" ; then
  155. make -j"${parallel}" -C build-autotools/test V=1
  156. fi
  157. - name: Run build-time tests (Autotools)
  158. if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
  159. run: |
  160. ${{ matrix.platform.source_cmd }}
  161. set -eu
  162. curdir="$(pwd)"
  163. parallel="$(getconf _NPROCESSORS_ONLN)"
  164. export SDL_TESTS_QUICK=1
  165. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  166. if test "${{ runner.os }}" = "Linux"; then
  167. # This should show us the SDL_REVISION
  168. strings "${curdir}/build-autotools/build/.libs/libSDL2-2.0.so.0" | grep SDL-
  169. fi
  170. - name: Install (Autotools)
  171. if: matrix.platform.autotools
  172. run: |
  173. ${{ matrix.platform.source_cmd }}
  174. set -eu
  175. curdir="$(pwd)"
  176. parallel="$(getconf _NPROCESSORS_ONLN)"
  177. make -j"${parallel}" -C build-autotools install V=1
  178. if test "${{ runner.os }}" != "macOS" ; then
  179. make -j"${parallel}" -C build-autotools/test install V=1
  180. fi
  181. ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
  182. echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
  183. - name: Verify CMake configuration files
  184. run: |
  185. ${{ matrix.platform.source_cmd }}
  186. cmake -S cmake/test -B cmake_config_build -G Ninja \
  187. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  188. ${{ matrix.platform.cmake }} \
  189. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
  190. cmake --build cmake_config_build --verbose
  191. - name: Verify sdl2-config
  192. if: ${{ !!matrix.platform.test-pkg-config }}
  193. run: |
  194. ${{ matrix.platform.source_cmd }}
  195. export PATH=${{ env.SDL2_DIR }}/bin:$PATH
  196. cmake/test/test_sdlconfig.sh
  197. - name: Verify sdl2.pc
  198. if: ${{ !!matrix.platform.test-pkg-config }}
  199. run: |
  200. ${{ matrix.platform.source_cmd }}
  201. export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
  202. cmake/test/test_pkgconfig.sh
  203. - name: Distcheck (Autotools)
  204. if: matrix.platform.autotools
  205. run: |
  206. set -eu
  207. parallel="$(getconf _NPROCESSORS_ONLN)"
  208. make -j"${parallel}" -C build-autotools dist V=1
  209. # Similar to Automake `make distcheck`: check that the tarball
  210. # release is sufficient to do a new build
  211. mkdir distcheck
  212. tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
  213. ( cd distcheck/SDL2-* && ./configure )
  214. make -j"${parallel}" -C distcheck/SDL2-*
  215. - name: Run installed-tests (Autotools)
  216. if: "runner.os == 'Linux' && matrix.platform.autotools"
  217. run: |
  218. ${{ matrix.platform.source_cmd }}
  219. set -eu
  220. parallel="$(getconf _NPROCESSORS_ONLN)"
  221. sudo make -j"${parallel}" -C build-autotools install
  222. sudo make -j"${parallel}" -C build-autotools/test install
  223. export SDL_TESTS_QUICK=1
  224. # We need to set LD_LIBRARY_PATH because it isn't in the default
  225. # linker search path. We don't need to set XDG_DATA_DIRS for
  226. # ginsttest-runner, because /usr/local/share *is* in the default
  227. # search path for that.
  228. env --chdir=/ \
  229. LD_LIBRARY_PATH=/usr/local/lib \
  230. SDL_AUDIODRIVER=dummy \
  231. SDL_VIDEODRIVER=dummy \
  232. ginsttest-runner --tap SDL2