main.yml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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, cc: gcc }
  15. - { name: Windows (mingw64+clang), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, cc: clang }
  16. - { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh }
  17. - { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
  18. - { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
  19. - { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
  20. - { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
  21. - { name: MacOS (autotools), os: macos-latest, shell: sh, autotools: true }
  22. steps:
  23. - name: Set up MSYS2
  24. if: matrix.platform.shell == 'msys2 {0}'
  25. uses: msys2/setup-msys2@v2
  26. with:
  27. msystem: ${{ matrix.platform.msystem }}
  28. install: >-
  29. ${{ matrix.platform.msys-env }}-${{ matrix.platform.cc }}
  30. ${{ matrix.platform.msys-env }}-cmake
  31. ${{ matrix.platform.msys-env }}-ninja
  32. ${{ matrix.platform.msys-env }}-pkg-config
  33. - name: Configure MSYS2 compiler
  34. if: matrix.platform.shell == 'msys2 {0}'
  35. run: |
  36. if test x${{ matrix.platform.cc}} == xgcc; then
  37. echo "CC=gcc" >> $GITHUB_ENV
  38. echo "CXX=g++" >> $GITHUB_ENV
  39. fi
  40. if test x${{ matrix.platform.cc}} == xclang; then
  41. echo "CC=clang" >> $GITHUB_ENV
  42. echo "CXX=clang++" >> $GITHUB_ENV
  43. fi
  44. - name: Setup Linux dependencies
  45. if: runner.os == 'Linux'
  46. run: |
  47. sudo apt-get update
  48. sudo apt-get install build-essential git make autoconf automake libtool \
  49. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  50. libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
  51. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  52. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  53. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  54. - name: Setup extra Ubuntu 22.04 dependencies
  55. if: matrix.platform.os == 'ubuntu-22.04'
  56. run: |
  57. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  58. - name: Setup Macos dependencies
  59. if: runner.os == 'macOS'
  60. run: |
  61. brew install \
  62. ninja
  63. - uses: actions/checkout@v2
  64. - name: Check that versioning is consistent
  65. # We only need to run this once: arbitrarily use the Linux/CMake build
  66. if: "runner.os == 'Linux' && ! matrix.platform.autotools"
  67. run: ./test/versioning.sh
  68. - name: Configure (CMake)
  69. if: "! matrix.platform.autotools"
  70. run: |
  71. cmake -S . -B build -G Ninja \
  72. -DSDL_TESTS=ON \
  73. -DSDL_INSTALL_TESTS=ON \
  74. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  75. -DCMAKE_BUILD_TYPE=Release \
  76. ${{ matrix.platform.cmake }}
  77. - name: Build (CMake)
  78. if: "! matrix.platform.autotools"
  79. run: |
  80. cmake --build build/ --config Release --verbose --parallel
  81. - name: Run build-time tests (CMake)
  82. if: "! matrix.platform.autotools"
  83. run: |
  84. set -eu
  85. export SDL_TESTS_QUICK=1
  86. ctest -VV --test-dir build/
  87. - name: Install (CMake)
  88. if: "! matrix.platform.autotools"
  89. run: |
  90. set -eu
  91. cmake --install build/ --config Release
  92. echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
  93. ( cd cmake_prefix; find ) | LC_ALL=C sort -u
  94. - name: Configure (Autotools)
  95. if: matrix.platform.autotools
  96. run: |
  97. set -eu
  98. rm -fr build-autotools
  99. mkdir build-autotools
  100. ./autogen.sh
  101. (
  102. cd build-autotools
  103. ${{ github.workspace }}/configure \
  104. --prefix=${{ github.workspace }}/autotools_prefix \
  105. )
  106. if test "${{ runner.os }}" != "macOS" ; then
  107. curdir="$(pwd)"
  108. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  109. (
  110. mkdir -p build-autotools/test
  111. cd build-autotools/test
  112. ${{ github.workspace }}/test/configure \
  113. --x-includes=/usr/include \
  114. --x-libraries="/usr/lib/${multiarch}" \
  115. --prefix=${{ github.workspace }}/autotools_prefix \
  116. SDL_CFLAGS="-I${curdir}/include" \
  117. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  118. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  119. ${NULL+}
  120. )
  121. fi
  122. - name: Build (Autotools)
  123. if: matrix.platform.autotools
  124. run: |
  125. set -eu
  126. parallel="$(getconf _NPROCESSORS_ONLN)"
  127. make -j"${parallel}" -C build-autotools V=1
  128. if test "${{ runner.os }}" != "macOS" ; then
  129. make -j"${parallel}" -C build-autotools/test V=1
  130. fi
  131. - name: Run build-time tests (Autotools)
  132. if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
  133. run: |
  134. set -eu
  135. curdir="$(pwd)"
  136. parallel="$(getconf _NPROCESSORS_ONLN)"
  137. export SDL_TESTS_QUICK=1
  138. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  139. - name: Install (Autotools)
  140. if: matrix.platform.autotools
  141. run: |
  142. set -eu
  143. curdir="$(pwd)"
  144. parallel="$(getconf _NPROCESSORS_ONLN)"
  145. make -j"${parallel}" -C build-autotools install V=1
  146. if test "${{ runner.os }}" != "macOS" ; then
  147. make -j"${parallel}" -C build-autotools/test install V=1
  148. fi
  149. ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
  150. echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
  151. - name: Verify CMake configuration files
  152. run: |
  153. cmake -S cmake/test -B cmake_config_build -G Ninja \
  154. -DCMAKE_BUILD_TYPE=Release \
  155. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
  156. cmake --build cmake_config_build --verbose
  157. - name: Verify sdl2-config
  158. run: |
  159. export CC=${{ matrix.platform.cc || 'gcc' }}
  160. export PATH=${{ env.SDL2_DIR }}/bin:$PATH
  161. cmake/test/test_sdlconfig.sh
  162. - name: Verify sdl2.pc
  163. run: |
  164. export CC=${{ matrix.platform.cc || 'gcc' }}
  165. export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
  166. cmake/test/test_pkgconfig.sh
  167. - name: Distcheck (Autotools)
  168. if: matrix.platform.autotools
  169. run: |
  170. set -eu
  171. parallel="$(getconf _NPROCESSORS_ONLN)"
  172. make -j"${parallel}" -C build-autotools dist V=1
  173. # Similar to Automake `make distcheck`: check that the tarball
  174. # release is sufficient to do a new build
  175. mkdir distcheck
  176. tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
  177. ( cd distcheck/SDL2-* && ./configure )
  178. make -j"${parallel}" -C distcheck/SDL2-*
  179. - name: Run installed-tests (Autotools)
  180. if: "runner.os == 'Linux' && matrix.platform.autotools"
  181. run: |
  182. set -eu
  183. parallel="$(getconf _NPROCESSORS_ONLN)"
  184. sudo make -j"${parallel}" -C build-autotools install
  185. sudo make -j"${parallel}" -C build-autotools/test install
  186. export SDL_TESTS_QUICK=1
  187. # We need to set LD_LIBRARY_PATH because it isn't in the default
  188. # linker search path. We don't need to set XDG_DATA_DIRS for
  189. # ginsttest-runner, because /usr/local/share *is* in the default
  190. # search path for that.
  191. env --chdir=/ \
  192. LD_LIBRARY_PATH=/usr/local/lib \
  193. SDL_AUDIODRIVER=dummy \
  194. SDL_VIDEODRIVER=dummy \
  195. ginsttest-runner --tap SDL2