main.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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, flags: true }
  17. - { name: Linux (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
  18. - { name: MacOS (CMake), os: macos-latest, shell: sh }
  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. - name: Build (CMake)
  107. if: "! matrix.platform.autotools"
  108. run: |
  109. cmake --build build/ --config Release --verbose --parallel
  110. - name: Run build-time tests (CMake)
  111. if: "! matrix.platform.autotools"
  112. run: |
  113. set -eu
  114. export SDL_TESTS_QUICK=1
  115. ctest -VV --test-dir build/
  116. - name: Install (CMake)
  117. if: "! matrix.platform.autotools"
  118. run: |
  119. set -eu
  120. cmake --install build/ --config Release
  121. echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
  122. ( cd cmake_prefix; find ) | LC_ALL=C sort -u
  123. - name: Configure (Autotools)
  124. if: matrix.platform.autotools
  125. run: |
  126. set -eu
  127. rm -fr build-autotools
  128. mkdir build-autotools
  129. ./autogen.sh
  130. (
  131. cd build-autotools
  132. ${{ github.workspace }}/configure \
  133. --prefix=${{ github.workspace }}/autotools_prefix \
  134. )
  135. if test "${{ runner.os }}" != "macOS" ; then
  136. curdir="$(pwd)"
  137. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  138. (
  139. mkdir -p build-autotools/test
  140. cd build-autotools/test
  141. ${{ github.workspace }}/test/configure \
  142. --x-includes=/usr/include \
  143. --x-libraries="/usr/lib/${multiarch}" \
  144. --prefix=${{ github.workspace }}/autotools_prefix \
  145. SDL_CFLAGS="-I${curdir}/include" \
  146. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  147. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  148. ${NULL+}
  149. )
  150. fi
  151. - name: Build (Autotools)
  152. if: matrix.platform.autotools
  153. run: |
  154. set -eu
  155. parallel="$(getconf _NPROCESSORS_ONLN)"
  156. make -j"${parallel}" -C build-autotools V=1
  157. if test "${{ runner.os }}" != "macOS" ; then
  158. make -j"${parallel}" -C build-autotools/test V=1
  159. fi
  160. - name: Run build-time tests (Autotools)
  161. if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
  162. run: |
  163. set -eu
  164. curdir="$(pwd)"
  165. parallel="$(getconf _NPROCESSORS_ONLN)"
  166. export SDL_TESTS_QUICK=1
  167. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  168. - name: Install (Autotools)
  169. if: matrix.platform.autotools
  170. run: |
  171. set -eu
  172. curdir="$(pwd)"
  173. parallel="$(getconf _NPROCESSORS_ONLN)"
  174. make -j"${parallel}" -C build-autotools install V=1
  175. if test "${{ runner.os }}" != "macOS" ; then
  176. make -j"${parallel}" -C build-autotools/test install V=1
  177. fi
  178. ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
  179. echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
  180. - name: Verify CMake configuration files
  181. run: |
  182. cmake -S cmake/test -B cmake_config_build -G Ninja \
  183. -DCMAKE_BUILD_TYPE=Release \
  184. -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
  185. cmake --build cmake_config_build --verbose
  186. - name: Verify sdl2-config
  187. run: |
  188. export CC=${{ matrix.platform.cc || 'gcc' }}
  189. export PATH=${{ env.SDL2_DIR }}/bin:$PATH
  190. cmake/test/test_sdlconfig.sh
  191. - name: Verify sdl2.pc
  192. run: |
  193. export CC=${{ matrix.platform.cc || 'gcc' }}
  194. export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
  195. cmake/test/test_pkgconfig.sh
  196. - name: Distcheck (Autotools)
  197. if: matrix.platform.autotools
  198. run: |
  199. set -eu
  200. parallel="$(getconf _NPROCESSORS_ONLN)"
  201. make -j"${parallel}" -C build-autotools dist V=1
  202. # Similar to Automake `make distcheck`: check that the tarball
  203. # release is sufficient to do a new build
  204. mkdir distcheck
  205. tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
  206. ( cd distcheck/SDL2-* && ./configure )
  207. make -j"${parallel}" -C distcheck/SDL2-*
  208. - name: Run installed-tests (Autotools)
  209. if: "runner.os == 'Linux' && matrix.platform.autotools"
  210. run: |
  211. set -eu
  212. parallel="$(getconf _NPROCESSORS_ONLN)"
  213. sudo make -j"${parallel}" -C build-autotools install
  214. sudo make -j"${parallel}" -C build-autotools/test install
  215. export SDL_TESTS_QUICK=1
  216. # We need to set LD_LIBRARY_PATH because it isn't in the default
  217. # linker search path. We don't need to set XDG_DATA_DIRS for
  218. # ginsttest-runner, because /usr/local/share *is* in the default
  219. # search path for that.
  220. env --chdir=/ \
  221. LD_LIBRARY_PATH=/usr/local/lib \
  222. SDL_AUDIODRIVER=dummy \
  223. SDL_VIDEODRIVER=dummy \
  224. ginsttest-runner --tap SDL2