1
0

main.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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: Intel oneAPI (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
  22. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
  23. - { name: Intel Compiler (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
  24. source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
  25. - { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
  26. - { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
  27. - { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
  28. - { name: MacOS (autotools), os: macos-latest, shell: sh, autotools: true }
  29. steps:
  30. - name: Set up MSYS2
  31. if: matrix.platform.shell == 'msys2 {0}'
  32. uses: msys2/setup-msys2@v2
  33. with:
  34. msystem: ${{ matrix.platform.msystem }}
  35. install: >-
  36. ${{ matrix.platform.msys-env }}-cc
  37. ${{ matrix.platform.msys-env }}-cmake
  38. ${{ matrix.platform.msys-env }}-ninja
  39. ${{ matrix.platform.msys-env }}-pkg-config
  40. - name: Setup Linux dependencies
  41. if: runner.os == 'Linux'
  42. run: |
  43. sudo apt-get update
  44. sudo apt-get install build-essential git make autoconf automake libtool \
  45. pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
  46. libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
  47. libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
  48. libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
  49. libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
  50. - name: Setup extra Ubuntu 22.04 dependencies
  51. if: matrix.platform.os == 'ubuntu-22.04'
  52. run: |
  53. sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
  54. - name: Setup Macos dependencies
  55. if: runner.os == 'macOS'
  56. run: |
  57. brew install \
  58. ninja \
  59. pkg-config
  60. - name: Setup Intel oneAPI
  61. if: matrix.platform.intel
  62. run: |
  63. # Download the key to system keyring
  64. wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
  65. | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
  66. # Add signed entry to apt sources and configure the APT client to use Intel repository:
  67. echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
  68. # Update package list
  69. sudo apt-get update -y
  70. # Install oneAPI
  71. sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
  72. - uses: actions/checkout@v3
  73. - name: Check that versioning is consistent
  74. # We only need to run this once: arbitrarily use the Linux/CMake build
  75. if: "runner.os == 'Linux' && ! matrix.platform.autotools"
  76. run: ./build-scripts/test-versioning.sh
  77. - name: Configure (CMake)
  78. if: "! matrix.platform.autotools"
  79. run: |
  80. ${{ matrix.platform.source_cmd }}
  81. cmake -S . -B build -G Ninja \
  82. -DSDL_TESTS=ON \
  83. -DSDL_WERROR=ON \
  84. -DSDL_INSTALL_TESTS=ON \
  85. -DSDL_VENDOR_INFO="Github Workflow" \
  86. -DCMAKE_INSTALL_PREFIX=cmake_prefix \
  87. -DCMAKE_BUILD_TYPE=Release \
  88. ${{ matrix.platform.cmake }}
  89. - name: Build (CMake)
  90. if: "! matrix.platform.autotools"
  91. run: |
  92. ${{ matrix.platform.source_cmd }}
  93. cmake --build build/ --config Release --verbose --parallel
  94. - name: Run build-time tests (CMake)
  95. if: "! matrix.platform.autotools"
  96. run: |
  97. ${{ matrix.platform.source_cmd }}
  98. set -eu
  99. export SDL_TESTS_QUICK=1
  100. ctest -VV --test-dir build/ -j2
  101. if test "${{ runner.os }}" = "Linux"; then
  102. # This should show us the SDL_REVISION
  103. strings build/libSDL2-2.0.so.0 | grep SDL-
  104. fi
  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. ${{ matrix.platform.source_cmd }}
  116. set -eu
  117. rm -fr build-autotools
  118. mkdir build-autotools
  119. ./autogen.sh
  120. (
  121. cd build-autotools
  122. ${{ github.workspace }}/configure \
  123. --enable-vendor-info="Github Workflow" \
  124. --enable-werror \
  125. --prefix=${{ github.workspace }}/autotools_prefix \
  126. )
  127. if test "${{ runner.os }}" != "macOS" ; then
  128. curdir="$(pwd)"
  129. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  130. (
  131. mkdir -p build-autotools/test
  132. cd build-autotools/test
  133. ${{ github.workspace }}/test/configure \
  134. --enable-werror \
  135. --x-includes=/usr/include \
  136. --x-libraries="/usr/lib/${multiarch}" \
  137. --prefix=${{ github.workspace }}/autotools_prefix \
  138. SDL_CFLAGS="-I${curdir}/include" \
  139. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  140. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  141. ${NULL+}
  142. )
  143. fi
  144. - name: Build (Autotools)
  145. if: matrix.platform.autotools
  146. run: |
  147. ${{ matrix.platform.source_cmd }}
  148. set -eu
  149. parallel="$(getconf _NPROCESSORS_ONLN)"
  150. make -j"${parallel}" -C build-autotools V=1
  151. if test "${{ runner.os }}" != "macOS" ; then
  152. make -j"${parallel}" -C build-autotools/test V=1
  153. fi
  154. - name: Run build-time tests (Autotools)
  155. if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
  156. run: |
  157. ${{ matrix.platform.source_cmd }}
  158. set -eu
  159. curdir="$(pwd)"
  160. parallel="$(getconf _NPROCESSORS_ONLN)"
  161. export SDL_TESTS_QUICK=1
  162. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  163. if test "${{ runner.os }}" = "Linux"; then
  164. # This should show us the SDL_REVISION
  165. strings "${curdir}/build-autotools/build/.libs/libSDL2-2.0.so.0" | grep SDL-
  166. fi
  167. - name: Install (Autotools)
  168. if: matrix.platform.autotools
  169. run: |
  170. ${{ matrix.platform.source_cmd }}
  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. ${{ matrix.platform.source_cmd }}
  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. ${{ matrix.platform.source_cmd }}
  190. export PATH=${{ env.SDL2_DIR }}/bin:$PATH
  191. cmake/test/test_sdlconfig.sh
  192. - name: Verify sdl2.pc
  193. run: |
  194. ${{ matrix.platform.source_cmd }}
  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. ${{ matrix.platform.source_cmd }}
  213. set -eu
  214. parallel="$(getconf _NPROCESSORS_ONLN)"
  215. sudo make -j"${parallel}" -C build-autotools install
  216. sudo make -j"${parallel}" -C build-autotools/test install
  217. export SDL_TESTS_QUICK=1
  218. # We need to set LD_LIBRARY_PATH because it isn't in the default
  219. # linker search path. We don't need to set XDG_DATA_DIRS for
  220. # ginsttest-runner, because /usr/local/share *is* in the default
  221. # search path for that.
  222. env --chdir=/ \
  223. LD_LIBRARY_PATH=/usr/local/lib \
  224. SDL_AUDIODRIVER=dummy \
  225. SDL_VIDEODRIVER=dummy \
  226. ginsttest-runner --tap SDL2