generic.yml 16 KB

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