generic.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. name: 'Build'
  2. run-name: 'Configure, Build and Test SDL'
  3. on:
  4. workflow_call:
  5. inputs:
  6. platforms:
  7. description: 'JSON-encoded test properties'
  8. type: string
  9. required: true
  10. jobs:
  11. build:
  12. name: ${{ matrix.platform.name }}
  13. runs-on: ${{ matrix.platform.os }}
  14. container: ${{ matrix.platform.container }}
  15. defaults:
  16. run:
  17. shell: ${{ matrix.platform.shell }}
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. platform: ${{ fromJSON(inputs.platforms) }}
  22. steps:
  23. - name: 'Set up MSYS2'
  24. if: ${{ matrix.platform.platform == 'msys2' }}
  25. uses: msys2/setup-msys2@v2
  26. with:
  27. msystem: ${{ matrix.platform.msys2-msystem }}
  28. install: >-
  29. ${{ matrix.platform.msys2-env }}-cc
  30. ${{ matrix.platform.msys2-env }}-cmake
  31. ${{ matrix.platform.msys2-env }}-ninja
  32. ${{ (!matrix.platform.msys2-no-perl && format('{0}-perl', matrix.platform.msys2-env)) || '' }}
  33. ${{ matrix.platform.msys2-env }}-pkg-config
  34. - name: 'About this job'
  35. run: |
  36. echo "key=${{ matrix.platform.key }}"
  37. echo "name=${{ matrix.platform.name }}"
  38. echo "os=${{ matrix.platform.os }}"
  39. echo ""
  40. echo "Add [sdl-ci-filter ${{ matrix.platform.key }}] to your commit message to reduce the number of jobs."
  41. - uses: actions/checkout@v4
  42. - name: 'Set up ninja'
  43. if: ${{ matrix.platform.setup-ninja }}
  44. uses: ./.github/actions/setup-ninja
  45. - uses: mymindstorm/setup-emsdk@v14
  46. if: ${{ matrix.platform.platform == 'emscripten' }}
  47. with:
  48. version: 3.1.35
  49. - uses: nttld/setup-ndk@v1
  50. if: ${{ matrix.platform.android-ndk }}
  51. id: setup-ndk
  52. with:
  53. local-cache: true
  54. ndk-version: r21e
  55. - uses: ilammy/msvc-dev-cmd@v1
  56. if: ${{ matrix.platform.platform == 'msvc' }}
  57. with:
  58. arch: ${{ matrix.platform.msvc-vcvars-arch }}
  59. sdk: ${{ matrix.platform.msvc-vcvars-sdk }}
  60. - name: 'Set up Windows GDK Desktop'
  61. uses: ./.github/actions/setup-gdk-desktop
  62. if: ${{ matrix.platform.setup-gdk-folder != '' }}
  63. with:
  64. folder: '${{ matrix.platform.setup-gdk-folder }}'
  65. - name: 'Setup Intel oneAPI toolchain'
  66. id: intel
  67. if: ${{ matrix.platform.intel }}
  68. run: |
  69. # Download the key to system keyring
  70. wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
  71. | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
  72. # Add signed entry to apt sources and configure the APT client to use Intel repository:
  73. 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
  74. # Update package list
  75. sudo apt-get update -y
  76. # Install oneAPI
  77. sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
  78. - name: 'Install apk packages'
  79. if: ${{ matrix.platform.apk-packages != '' }}
  80. run: |
  81. ${{ matrix.platform.sudo }} apk update
  82. ${{ matrix.platform.sudo }} apk add ${{ matrix.platform.apk-packages }}
  83. - name: 'Install apt packages'
  84. if: ${{ matrix.platform.apt-packages != '' }}
  85. run: |
  86. ${{ matrix.platform.sudo }} apt-get update
  87. ${{ matrix.platform.sudo }} apt-get install -y ${{ matrix.platform.apt-packages }}
  88. - name: 'Install brew packages'
  89. if: ${{ matrix.platform.brew-packages != '' }}
  90. run: |
  91. export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
  92. brew update
  93. brew install ${{ matrix.platform.brew-packages }}
  94. - name: 'Set up GLES for VITA' # Must be after apk
  95. if: ${{ matrix.platform.setup-vita-gles-type != '' }}
  96. uses: ./.github/actions/setup-vita-gles
  97. with:
  98. type: ${{ matrix.platform.setup-vita-gles-type }}
  99. - name: 'Configure (Autotools)'
  100. if: ${{ !matrix.platform.no-autotools }}
  101. run: |
  102. ${{ matrix.platform.source_cmd }}
  103. set -eu
  104. rm -rf build-autotools
  105. mkdir build-autotools
  106. ./autogen.sh
  107. (
  108. cd build-autotools
  109. ../configure \
  110. --enable-vendor-info="Github Workflow" \
  111. --enable-werror \
  112. --prefix=${{ github.workspace }}/autotools_prefix \
  113. )
  114. if test "x${{ (matrix.platform.build-autotools-tests && 'yes') || 'no' }}" = "xyes" ; then
  115. curdir="$(pwd)"
  116. multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
  117. (
  118. mkdir -p build-autotools/test
  119. cd build-autotools/test
  120. ../../test/configure \
  121. --enable-werror \
  122. --x-includes=/usr/include \
  123. --x-libraries="/usr/lib/${multiarch}" \
  124. --prefix=${{ github.workspace }}/autotools_prefix \
  125. SDL_CFLAGS="-I${curdir}/include" \
  126. SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
  127. ac_cv_lib_SDL2_ttf_TTF_Init=no \
  128. ${NULL+}
  129. )
  130. fi
  131. - name: 'Build (Autotools)'
  132. if: ${{ !matrix.platform.no-autotools }}
  133. run: |
  134. ${{ matrix.platform.source_cmd }}
  135. set -eu
  136. parallel="$(getconf _NPROCESSORS_ONLN)"
  137. make -j"${parallel}" -C build-autotools V=1
  138. if test "x${{ (matrix.platform.build-autotools-tests && 'yes') || 'no' }}" = "xyes" ; then
  139. make -j"${parallel}" -C build-autotools/test V=1
  140. fi
  141. - name: 'Run build-time tests (Autotools)'
  142. if: ${{ !matrix.platform.no-autotools && matrix.platform.build-autotools-tests && matrix.platform.run-tests }}
  143. run: |
  144. ${{ matrix.platform.source_cmd }}
  145. set -eu
  146. curdir="$(pwd)"
  147. parallel="$(getconf _NPROCESSORS_ONLN)"
  148. export SDL_TESTS_QUICK=1
  149. make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
  150. if test "${{ runner.os }}" = "Linux"; then
  151. # This should show us the SDL_REVISION
  152. strings "${curdir}/build-autotools/build/.libs/libSDL2-2.0.so.0" | grep SDL-
  153. fi
  154. - name: 'Install (Autotools)'
  155. if: ${{ !matrix.platform.no-autotools }}
  156. run: |
  157. ${{ matrix.platform.source_cmd }}
  158. set -eu
  159. curdir="$(pwd)"
  160. parallel="$(getconf _NPROCESSORS_ONLN)"
  161. make -j"${parallel}" -C build-autotools install V=1
  162. if test "x${{ (matrix.platform.build-autotools-tests && 'yes') || 'no' }}" = "xyes" ; then
  163. make -j"${parallel}" -C build-autotools/test install V=1
  164. fi
  165. ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
  166. echo "prefix=$(pwd)/autotools_prefix" >> $GITHUB_OUTPUT
  167. - name: 'Configure (CMake)'
  168. if: ${{ !matrix.platform.no-cmake }}
  169. #shell: ${{ matrix.platform.shell }}
  170. run: |
  171. ${{ matrix.platform.source-cmd }}
  172. ${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -G "${{ matrix.platform.cmake-generator }}" \
  173. -Wdeprecated -Wdev -Werror \
  174. ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
  175. -DSDL_WERROR=${{ matrix.platform.werror }} \
  176. -DSDL_TESTS=${{ matrix.platform.build-tests }} \
  177. -DSDLTEST_TRACKMEM=OFF \
  178. -DSDL_INSTALL_TESTS=${{ matrix.platform.build-tests }} \
  179. -DSDL_DISABLE_INSTALL_DOCS=OFF \
  180. -DSDL_DISABLE_INSTALL_DOCS=OFF \
  181. ${{ matrix.platform.cmake-arguments }} \
  182. -DSDL_SHARED=${{ matrix.platform.shared }} \
  183. -DSDL_STATIC=${{ matrix.platform.static }} \
  184. -DSDL_TEST=ON \
  185. -DSDL_VENDOR_INFO="Github Workflow" \
  186. -DCMAKE_INSTALL_PREFIX=prefix \
  187. -DCMAKE_INSTALL_LIBDIR=lib \
  188. -DSDL_CMAKE_DEBUG_POSTFIX="" \
  189. -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
  190. - name: 'Build (CMake)'
  191. id: cmake-build
  192. if: ${{ !matrix.platform.no-cmake }}
  193. # shell: ${{ matrix.platform.shell }}
  194. run: |
  195. ${{ matrix.platform.source-cmd }}
  196. cmake --build build --config ${{ matrix.platform.cmake-build-type }} --verbose -- ${{ matrix.platform.cmake-build-arguments }}
  197. - name: 'Verify SDL_REVISION'
  198. if: ${{ !matrix.platform.no-cmake }}
  199. run: |
  200. echo "This should show us the SDL_REVISION"
  201. echo "Shared library:"
  202. ${{ (matrix.platform.shared-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
  203. echo "Static library:"
  204. ${{ (matrix.platform.static-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
  205. - name: 'Run build-time tests (CMake)'
  206. id: cmake-tests
  207. if: ${{ !matrix.platform.no-cmake && matrix.platform.run-tests }}
  208. # shell: ${{ matrix.platform.shell }}
  209. run: |
  210. ${{ matrix.platform.source-cmd }}
  211. ${{ matrix.platform.pretest-cmd }}
  212. set -eu
  213. export SDL_TESTS_QUICK=1
  214. ctest -VV --test-dir build/ -j2
  215. - name: 'Install (CMake)'
  216. id: cmake-install
  217. if: ${{ steps.build.outcome == 'success' }}
  218. # shell: ${{ matrix.platform.shell }}
  219. run: |
  220. ${{ matrix.platform.source-cmd }}
  221. cmake --install build --config ${{ matrix.platform.cmake-build-type }}
  222. echo "prefix=$(pwd)/prefix" >> $GITHUB_OUTPUT
  223. ( cd prefix; find . ) | LC_ALL=C sort -u
  224. - name: 'Verify CMake configuration files (CMake)'
  225. if: ${{ steps.cmake-install.outcome == 'success' }}
  226. # shell: ${{ matrix.platform.shell }}
  227. run: |
  228. ${{ matrix.platform.source-cmd }}
  229. ${{ matrix.platform.cmake-config-emulator }} cmake -S cmake/test -B cmake_test_build -GNinja \
  230. ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
  231. -DTEST_SHARED=${{ matrix.platform.shared }} \
  232. -DTEST_STATIC=${{ matrix.platform.static }} \
  233. ${{ matrix.platform.cmake-arguments }} \
  234. -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
  235. -DCMAKE_PREFIX_PATH="${{ steps.cmake-install.outputs.prefix }}"
  236. cmake --build cmake_test_build --verbose --config ${{ matrix.platform.cmake-build-type }} -- ${{ matrix.platform.cmake-build-arguments }}
  237. - name: 'Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain'
  238. if: ${{ steps.cmake-install.outcome == 'success' && matrix.platform.cc-from-cmake }}
  239. # shell: ${{ matrix.platform.shell }}
  240. run: |
  241. cmake -S .github/cmake -B /tmp/cmake_extract \
  242. ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
  243. -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }} \
  244. -DVAR_PATH=/tmp/env.txt
  245. cat /tmp/env.txt >> $GITHUB_ENV
  246. - name: 'Verify sdl2.pc (CMake)'
  247. # shell: ${{ matrix.platform.shell }}
  248. if: ${{ steps.cmake-install.outcome == 'success' && matrix.platform.test-pkg-config }}
  249. run: |
  250. ${{ matrix.platform.source-cmd }}
  251. ${{ matrix.platform.cc && format('export CC="{0}"', matrix.platform.cc) || '' }}
  252. ${{ matrix.platform.cflags && format('export CFLAGS="{0}"', matrix.platform.cflags) || '' }}
  253. ${{ matrix.platform.ldflags && format('export LDFLAGS="{0}"', matrix.platform.ldflags) || '' }}
  254. export PKG_CONFIG_PATH=${{ steps.cmake-install.outputs.prefix }}/lib/pkgconfig
  255. cmake/test/test_pkgconfig.sh
  256. - name: 'Build (cross-platform-actions, BSD)'
  257. id: cpactions
  258. if: ${{ matrix.platform.cpactions }}
  259. uses: cross-platform-actions/action@v0.29.0
  260. with:
  261. operating_system: '${{ matrix.platform.cpactions-os }}'
  262. architecture: '${{ matrix.platform.cpactions-arch }}'
  263. version: '${{ matrix.platform.cpactions-version }}'
  264. run: |
  265. ${{ matrix.platform.cpactions-setup-cmd }}
  266. ${{ matrix.platform.cpactions-install-cmd }}
  267. cmake -S . -B build -GNinja \
  268. ${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
  269. -Wdeprecated -Wdev -Werror \
  270. -DSDL_WERROR=${{ matrix.platform.werror }} \
  271. -DSDL_DISABLE_INSTALL_DOCS=OFF \
  272. ${{ matrix.platform.cmake-arguments }} \
  273. -DSDL_SHARED=${{ matrix.platform.shared }} \
  274. -DSDL_STATIC=${{ matrix.platform.static }} \
  275. -DSDL_TEST=ON \
  276. -DSDL_VENDOR_INFO="Github Workflow" \
  277. -DCMAKE_INSTALL_PREFIX=prefix \
  278. -DCMAKE_INSTALL_LIBDIR=lib \
  279. -DCMAKE_BUILD_TYPE=${{ matrix.platform.cmake-build-type }}
  280. cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --verbose
  281. cmake --build build/ --config ${{ matrix.platform.cmake-build-type }} --target clean
  282. rm -rf build/CMakeFiles
  283. rm -rf build/docs
  284. - name: 'Set up Watcom'
  285. uses: open-watcom/setup-watcom@v0
  286. if: ${{ matrix.platform.watcom-makefile != '' }}
  287. - name: 'Build (Watcom)'
  288. if: ${{ matrix.platform.watcom-makefile != '' }}
  289. run: |
  290. wmake -f ${{ matrix.platform.watcom-makefile }} ENABLE_WERROR=1
  291. - name: 'Build tests (Watcom)'
  292. if: ${{ matrix.platform.watcom-makefile != '' }}
  293. run: |
  294. cd test
  295. wmake -f ${{ matrix.platform.watcom-makefile }} ENABLE_WERROR=1
  296. - name: 'Run tests (Watcom)'
  297. if: ${{ matrix.platform.watcom-makefile != '' && matrix.platform.run-tests }}
  298. run: |
  299. cd test
  300. wmake -f ${{ matrix.platform.watcom-makefile }} check-quick
  301. - name: 'Distclean (Watcom)'
  302. if: ${{ matrix.platform.watcom-makefile != '' }}
  303. run: |
  304. wmake -f ${{ matrix.platform.watcom-makefile }} distclean
  305. cd test
  306. wmake -f ${{ matrix.platform.watcom-makefile }} distclean
  307. - name: 'Add msbuild to PATH'
  308. id: setup-msbuild
  309. if: ${{ matrix.platform.msvc-project != '' }}
  310. uses: microsoft/setup-msbuild@v2
  311. - name: Build msbuild
  312. if: ${{ matrix.platform.msvc-project != '' }}
  313. run: |
  314. "$(cygpath -u '${{ steps.setup-msbuild.outputs.msbuildPath }}\msbuild.exe')" ${{ matrix.platform.msvc-project }} -m -p:BuildInParallel=true -p:Configuration=Release ${{ matrix.platform.msvc-project-flags }}
  315. - name: 'Build (Android.mk)'
  316. if: ${{ matrix.platform.android-mk }}
  317. run: |
  318. ./build-scripts/androidbuildlibs.sh
  319. - name: 'Build (xcode)'
  320. if: ${{ matrix.platform.xcode-sdk != '' }}
  321. run: |
  322. xcodebuild -project Xcode/SDL/SDL.xcodeproj -target "${{ matrix.platform.xcode-target }}" -configuration Release -sdk ${{ matrix.platform.xcode-sdk }} clean build
  323. - name: 'Setup Python'
  324. uses: 'actions/setup-python@main'
  325. if: ${{ matrix.platform.check-sources }}
  326. with:
  327. python-version: '3.x'
  328. - name: 'Check Sources'
  329. if: ${{ matrix.platform.check-sources }}
  330. run: |
  331. set -e
  332. build-scripts/test-versioning.sh
  333. - name: 'Upload binary package'
  334. uses: actions/upload-artifact@v4
  335. if: ${{ always() && steps.cmake-tests.outcome == 'failure' }}
  336. with:
  337. if-no-files-found: ignore
  338. name: '${{ matrix.platform.artifact }}-minidumps'
  339. path: |
  340. build/**/*.dmp
  341. build/**/*.exe
  342. build/**/*.dll
  343. build/**/*.pdb