main.yml 7.4 KB

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