main.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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: ./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_INSTALL_TESTS=ON \
  66. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  67. -DCMAKE_BUILD_TYPE=Release \
  68. ${{ matrix.platform.cmake }}
  69. - name: Build (CMake)
  70. if: "! matrix.platform.autotools"
  71. run: |
  72. cmake --build build/ --config Release --verbose --parallel
  73. - name: Run build-time tests (CMake)
  74. if: "! matrix.platform.autotools"
  75. run: |
  76. set -eu
  77. export SDL_TESTS_QUICK=1
  78. ctest -VV --test-dir build/
  79. - name: Install (CMake)
  80. if: "! matrix.platform.autotools"
  81. run: |
  82. set -eu
  83. cmake --install build/ --config Release
  84. echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
  85. ( cd cmake_prefix; find ) | LC_ALL=C sort -u
  86. - name: Configure (Autotools)
  87. if: matrix.platform.autotools
  88. run: |
  89. set -eu
  90. rm -fr build-autotools
  91. mkdir build-autotools
  92. ./autogen.sh
  93. (
  94. cd build-autotools
  95. ${{ github.workspace }}/configure \
  96. --prefix=${{ github.workspace }}/autotools_prefix \
  97. )
  98. if test "${{ runner.os }}" != "macOS" ; then
  99. curdir="$(pwd)"
  100. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  101. (
  102. mkdir -p build-autotools/test
  103. cd build-autotools/test
  104. ${{ github.workspace }}/test/configure \
  105. --x-includes=/usr/include \
  106. --x-libraries="/usr/lib/${multiarch}" \
  107. --prefix=${{ github.workspace }}/autotools_prefix \
  108. SDL_CFLAGS="-I${curdir}/include" \
  109. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  110. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  111. ${NULL+}
  112. )
  113. fi
  114. - name: Build (Autotools)
  115. if: matrix.platform.autotools
  116. run: |
  117. set -eu
  118. parallel="$(getconf _NPROCESSORS_ONLN)"
  119. make -j"${parallel}" -C build-autotools V=1
  120. if test "${{ runner.os }}" != "macOS" ; then
  121. make -j"${parallel}" -C build-autotools/test V=1
  122. fi
  123. - name: Run build-time tests (Autotools)
  124. if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
  125. run: |
  126. set -eu
  127. curdir="$(pwd)"
  128. parallel="$(getconf _NPROCESSORS_ONLN)"
  129. export SDL_TESTS_QUICK=1
  130. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  131. - name: Install (Autotools)
  132. if: matrix.platform.autotools
  133. run: |
  134. set -eu
  135. curdir="$(pwd)"
  136. parallel="$(getconf _NPROCESSORS_ONLN)"
  137. make -j"${parallel}" -C build-autotools install V=1
  138. if test "${{ runner.os }}" != "macOS" ; then
  139. make -j"${parallel}" -C build-autotools/test install V=1
  140. fi
  141. ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
  142. echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
  143. - name: Verify CMake configuration files
  144. run: |
  145. cmake -S cmake/test -B cmake_config_build -G Ninja \
  146. -DCMAKE_BUILD_TYPE=Release \
  147. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
  148. cmake --build cmake_config_build --verbose
  149. - name: Verify sdl2-config
  150. run: |
  151. export PATH=${{ env.SDL2_DIR }}/bin:$PATH
  152. cmake/test/test_sdlconfig.sh
  153. - name: Verify sdl2.pc
  154. run: |
  155. export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
  156. cmake/test/test_pkgconfig.sh
  157. - name: Distcheck (Autotools)
  158. if: matrix.platform.autotools
  159. run: |
  160. set -eu
  161. parallel="$(getconf _NPROCESSORS_ONLN)"
  162. make -j"${parallel}" -C build-autotools dist V=1
  163. # Similar to Automake `make distcheck`: check that the tarball
  164. # release is sufficient to do a new build
  165. mkdir distcheck
  166. tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
  167. ( cd distcheck/SDL2-* && ./configure )
  168. make -j"${parallel}" -C distcheck/SDL2-*
  169. - name: Run installed-tests (Autotools)
  170. if: "runner.os == 'Linux' && matrix.platform.autotools"
  171. run: |
  172. set -eu
  173. parallel="$(getconf _NPROCESSORS_ONLN)"
  174. sudo make -j"${parallel}" -C build-autotools install
  175. sudo make -j"${parallel}" -C build-autotools/test install
  176. export SDL_TESTS_QUICK=1
  177. # We need to set LD_LIBRARY_PATH because it isn't in the default
  178. # linker search path. We don't need to set XDG_DATA_DIRS for
  179. # ginsttest-runner, because /usr/local/share *is* in the default
  180. # search path for that.
  181. env --chdir=/ \
  182. LD_LIBRARY_PATH=/usr/local/lib \
  183. SDL_AUDIODRIVER=dummy \
  184. SDL_VIDEODRIVER=dummy \
  185. ginsttest-runner --tap SDL2