main.yml 8.0 KB

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