1
0

main.yml 8.3 KB

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