build.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
  2. name: Build
  3. on:
  4. push:
  5. pull_request:
  6. workflow_dispatch:
  7. # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
  8. defaults:
  9. run:
  10. shell: bash
  11. jobs:
  12. ###########################################################
  13. build:
  14. ###########################################################
  15. runs-on: ${{ matrix.runner }}
  16. strategy:
  17. fail-fast: false
  18. matrix:
  19. target: [linux, darwin, windows]
  20. architecture: [32, 64, arm64]
  21. build_system: [make, cmake, cmake-mingw, vs2019, makegcc14]
  22. include:
  23. - target: linux
  24. runner: ubuntu-latest
  25. haxe_nightly_dir: linux64
  26. archive_ext: tar.gz
  27. - target: darwin
  28. haxe_nightly_dir: mac
  29. archive_ext: tar.gz
  30. - target: darwin
  31. architecture: 64
  32. runner: macos-latest
  33. - target: darwin
  34. architecture: arm64
  35. runner: macos-latest
  36. - build_system: cmake
  37. cmake_configuration: RelWithDebInfo
  38. - build_system: cmake-mingw
  39. cmake_configuration: RelWithDebInfo
  40. - build_system: vs2019
  41. msbuild_configuration: Release
  42. - target: windows
  43. runner: windows-2022 # has VS 2022 preinstalled which supports PlatformToolset <= v142, WindowsTargetPlatformVersion 10
  44. haxe_nightly_dir: windows64
  45. archive_ext: zip
  46. - target: windows
  47. build_system: cmake
  48. cmake_generator: Visual Studio 17 2022
  49. - target: windows
  50. architecture: 64
  51. runner: windows-2025
  52. build_system: cmake-mingw
  53. - target: windows
  54. architecture: 32
  55. ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648055/ffmpeg-3.4.2-win32-dev.zip
  56. architecture_string: Win32
  57. - target: windows
  58. architecture: 64
  59. ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648056/ffmpeg-3.4.2-win64-dev.zip
  60. architecture_string: x64
  61. exclude:
  62. - target: linux
  63. build_system: vs2019
  64. - target: darwin
  65. build_system: vs2019
  66. - target: linux
  67. architecture: 32
  68. - target: darwin
  69. architecture: 32
  70. - target: linux
  71. architecture: arm64
  72. - target: windows
  73. architecture: arm64
  74. - target: windows
  75. build_system: make
  76. - target: darwin
  77. architecture: 64
  78. build_system: make
  79. - target: darwin
  80. build_system: makegcc14
  81. - target: windows
  82. build_system: makegcc14
  83. - target: windows
  84. architecture: 32
  85. build_system: cmake-mingw
  86. - target: darwin
  87. build_system: cmake-mingw
  88. - target: linux
  89. build_system: cmake-mingw
  90. steps:
  91. - name: "SCM Checkout"
  92. uses: actions/checkout@v6
  93. - name: "Add msbuild to PATH"
  94. if: matrix.build_system == 'vs2019'
  95. uses: microsoft/setup-msbuild@v2
  96. - name: "Mac homebrew workaround"
  97. if: matrix.target == 'darwin'
  98. run: |
  99. # see https://github.com/Homebrew/homebrew-core/issues/165793#issuecomment-1989441193
  100. # see https://github.com/Homebrew/brew/blob/master/.github/workflows/tests.yml
  101. brew unlink python && brew link --overwrite python
  102. - name: "Install: Required Dev Packages"
  103. run: |
  104. set -eux
  105. case "${{ matrix.target }}${{ matrix.architecture }}" in
  106. linux64)
  107. echo "MARCH=64" >> $GITHUB_ENV
  108. sudo apt-get update -y
  109. sudo apt-get install --no-install-recommends -y \
  110. libmbedtls-dev \
  111. libopenal-dev \
  112. libpng-dev \
  113. libsdl2-dev \
  114. libturbojpeg-dev \
  115. libuv1-dev \
  116. libvorbis-dev \
  117. libsqlite3-dev
  118. ;;
  119. darwin*)
  120. if [ "${{matrix.build_system}}" != "cmake" ]; then
  121. brew update
  122. brew bundle
  123. fi
  124. ;;
  125. windows*)
  126. if [[ ${{ matrix.build_system }} == cmake-mingw ]]; then
  127. SDL_SUFFIX=mingw
  128. else
  129. SDL_SUFFIX=VC
  130. fi
  131. curl -fsSL --retry 3 --retry-delay 5 -o /tmp/sdl.zip https://www.libsdl.org/release/SDL2-devel-2.30.2-${SDL_SUFFIX}.zip
  132. curl -fsSL --retry 3 --retry-delay 5 -o /tmp/openal.zip https://github.com/kcat/openal-soft/releases/download/1.23.1/openal-soft-1.23.1-bin.zip
  133. curl -fsSL --retry 3 --retry-delay 5 -o /tmp/ffmpeg.zip ${{ matrix.ffmpeg_url }}
  134. 7z x /tmp/sdl.zip -oinclude; mv include/SDL2* include/sdl
  135. 7z x /tmp/openal.zip -oinclude; mv include/openal* include/openal
  136. 7z x /tmp/ffmpeg.zip -oinclude; mv include/ffmpeg* include/ffmpeg
  137. ;;
  138. esac
  139. - name: "Download: DirectX binaries for windows + make"
  140. if: matrix.target == 'windows' && matrix.build_system != 'cmake' && matrix.build_system != 'cmake-mingw'
  141. run: |
  142. curl -fsSL --retry 3 --retry-delay 5 -o /tmp/dx.zip https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2505.1/dxc_2025_07_14.zip
  143. 7z x /tmp/dx.zip -oinclude/dx
  144. - name: "Install: GCC 14"
  145. if: matrix.build_system == 'makegcc14'
  146. run: |
  147. sudo add-apt-repository universe
  148. sudo apt update
  149. sudo apt install -y gcc-14 g++-14
  150. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14
  151. gcc --version
  152. - name: Install haxe
  153. uses: krdlab/setup-haxe@v2
  154. with:
  155. haxe-version: latest
  156. - name: "Configure: Haxelib"
  157. run: |
  158. set -eux
  159. haxelib setup ~/haxelib
  160. haxelib install hashlink
  161. haxelib list
  162. - name: "Build: HashLink"
  163. run: |
  164. set -eux
  165. case "${{ matrix.build_system }}" in
  166. cmake)
  167. case "${{ matrix.target }}${{ matrix.architecture }}" in
  168. windows*)
  169. cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
  170. -G "${{ matrix.cmake_generator }}" \
  171. -A ${{ matrix.architecture_string }}
  172. ;;
  173. darwin64)
  174. cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
  175. -DDOWNLOAD_DEPENDENCIES=ON \
  176. -DCMAKE_OSX_ARCHITECTURES=x86_64 \
  177. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
  178. -DFLAT_INSTALL_TREE=ON
  179. ;;
  180. darwinarm64)
  181. cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
  182. -DDOWNLOAD_DEPENDENCIES=ON \
  183. -DCMAKE_OSX_ARCHITECTURES=arm64 \
  184. -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
  185. -DFLAT_INSTALL_TREE=ON
  186. ;;
  187. linux64)
  188. cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} ;;
  189. esac
  190. cmake --build build --config ${{ matrix.cmake_configuration }}
  191. BUILD_FOLDER=build/bin
  192. ;;
  193. cmake-mingw)
  194. cmake -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
  195. -DWITH_DX12=OFF
  196. cmake --build build --config ${{ matrix.cmake_configuration }} --parallel
  197. BUILD_FOLDER=build/bin
  198. ;;
  199. vs2019)
  200. MSBuild.exe hl.sln //nologo //m //clp:ErrorsOnly \
  201. //p:Configuration=${{ matrix.msbuild_configuration }} \
  202. //p:Platform=${{ matrix.architecture_string }}
  203. case "${{ matrix.architecture }}" in
  204. 64) BUILD_FOLDER=x64/${{ matrix.msbuild_configuration }} ;;
  205. 32) BUILD_FOLDER=${{ matrix.msbuild_configuration }} ;;
  206. esac
  207. echo "WINDOWS_BUILD_FOLDER=$BUILD_FOLDER" >> $GITHUB_ENV
  208. ;;
  209. make*)
  210. make
  211. sudo make install
  212. if [[ ${{ matrix.target }} == linux ]]; then
  213. sudo ldconfig
  214. fi
  215. BUILD_FOLDER=.
  216. ;;
  217. esac
  218. ls -l $BUILD_FOLDER
  219. - name: "Test"
  220. run: |
  221. set -eux
  222. case "${{ matrix.build_system }}" in
  223. cmake*)
  224. case "${{matrix.target}}" in
  225. linux)
  226. cmake --install build --prefix /tmp/hashlink
  227. /tmp/hashlink/bin/hl --version
  228. ;;
  229. darwin)
  230. cmake --install build --prefix /tmp/hashlink
  231. if [ -f /tmp/hashlink/hl ]; then /tmp/hashlink/hl --version; fi
  232. ;;
  233. windows)
  234. export PATH=$(pwd)/build/bin:$PATH
  235. ;;
  236. esac
  237. cd build && ctest --verbose --build-config ${{ matrix.cmake_configuration }}
  238. ;;
  239. vs2019)
  240. ${{ env.WINDOWS_BUILD_FOLDER }}/hl.exe --version
  241. ;;
  242. make*)
  243. if [[ ${{ matrix.architecture }} != arm64 ]]; then
  244. ./hl --version
  245. case ${{ matrix.target }} in
  246. linux) ldd -v ./hl ;;
  247. darwin) otool -L ./hl ;;
  248. esac
  249. haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp
  250. ./hl hello.hl
  251. # ensure the executable still works when installed globally
  252. cp hello.hl /tmp
  253. pushd /tmp
  254. hl hello.hl
  255. popd
  256. fi
  257. haxe -hl src/_main.c -cp other/tests -main HelloWorld
  258. make hlc
  259. ./hlc
  260. ;;
  261. esac
  262. - name: "Test haxelib build"
  263. run: |
  264. haxelib git format https://github.com/HaxeFoundation/format
  265. cd other/haxelib
  266. haxe memory.hxml
  267. haxe profiler.hxml
  268. cd ../..
  269. - name: "Package"
  270. run: |
  271. set -eux
  272. case "${{ matrix.target }}${{matrix.architecture}}" in
  273. darwinarm64) platform_name=darwin-arm64 ;;
  274. darwin64) platform_name=darwin ;;
  275. windows*) platform_name=win${{matrix.architecture}} ;;
  276. linux64) platform_name=linux-amd64 ;;
  277. esac
  278. short_commit=$(git rev-parse --short HEAD)
  279. case "${{ matrix.build_system }}" in
  280. cmake*)
  281. dist_folder=hashlink-${short_commit}-${platform_name}-${{ matrix.build_system }}
  282. cd build && cpack -D CPACK_PACKAGE_FILE_NAME=$dist_folder -C ${{ matrix.cmake_configuration }}
  283. echo "HASHLINK_DISTRIBUTION=build/bin/$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
  284. ;;
  285. *)
  286. dist_folder=hashlink-${short_commit}-${platform_name}
  287. make PACKAGE_NAME=$dist_folder MARCH=${{ matrix.architecture }} release
  288. echo "HASHLINK_DISTRIBUTION=$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
  289. ;;
  290. esac
  291. - name: "Share: build artifact"
  292. uses: actions/upload-artifact@v6
  293. with:
  294. name: ${{ matrix.target }}-${{ matrix.build_system }}-${{ matrix.architecture }}
  295. path: ${{ env.HASHLINK_DISTRIBUTION }}
  296. build-android:
  297. runs-on: ubuntu-latest
  298. steps:
  299. - name: "SCM Checkout"
  300. uses: actions/checkout@v6
  301. - name: Install haxe
  302. uses: krdlab/setup-haxe@v2
  303. with:
  304. haxe-version: latest
  305. - name: "Configure: Haxelib"
  306. run: |
  307. set -eux
  308. haxelib setup ~/haxelib
  309. haxelib install hashlink
  310. haxelib list
  311. - name: "Build: Hashlink"
  312. run: |
  313. set -ex
  314. cmake -B build -G Ninja --toolchain $ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
  315. -DANDROID_PLATFORM=24 -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -DWITH_VM=OFF
  316. cmake --build build
  317. ###########################################################
  318. publish-latest-release:
  319. ###########################################################
  320. runs-on: ubuntu-latest
  321. needs:
  322. - build
  323. if: github.ref == 'refs/heads/master'
  324. concurrency: publish-latest-release # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idconcurrency
  325. steps:
  326. - name: "SCM Checkout"
  327. uses: actions/checkout@v6
  328. - name: "Get: all build artifacts"
  329. uses: actions/download-artifact@v7
  330. - name: "Delete previous 'latest' release"
  331. env:
  332. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  333. run: |
  334. set -eu
  335. gh release delete latest --cleanup-tag --yes || true
  336. - name: "Create 'latest' Release"
  337. env:
  338. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  339. run: |
  340. set -eux
  341. # https://hub.github.com/hub-release.1.html
  342. short_commit=$(git rev-parse --short HEAD)
  343. gh release create latest \
  344. --prerelease \
  345. --title "HashLink Nightly Build" \
  346. "darwin-cmake-64/hashlink-${short_commit}-darwin-cmake.tar.gz#hashlink-latest-darwin.tar.gz" \
  347. "darwin-cmake-arm64/hashlink-${short_commit}-darwin-arm64-cmake.tar.gz#hashlink-latest-darwin-arm64.tar.gz" \
  348. "linux-make-64/hashlink-${short_commit}-linux-amd64.tar.gz#hashlink-latest-linux-amd64.tar.gz" \
  349. "windows-vs2019-32/hashlink-${short_commit}-win32.zip#hashlink-latest-win32.zip" \
  350. "windows-vs2019-64/hashlink-${short_commit}-win64.zip#hashlink-latest-win64.zip" \
  351. "windows-cmake-mingw-64/hashlink-${short_commit}-win64-cmake-mingw.zip#hashlink-latest-win64-mingw.zip"