main.yml 7.9 KB

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