main.yml 8.2 KB

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