| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
- name: Build
- on:
- push:
- pull_request:
- workflow_dispatch:
- # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
- defaults:
- run:
- shell: bash
- jobs:
- ###########################################################
- build:
- ###########################################################
- runs-on: ${{ matrix.runner }}
- strategy:
- fail-fast: false
- matrix:
- target: [linux, darwin, windows]
- architecture: [32, 64, arm64]
- build_system: [make, cmake, cmake-mingw, vs2019, makegcc14]
- include:
- - target: linux
- runner: ubuntu-latest
- haxe_nightly_dir: linux64
- archive_ext: tar.gz
- - target: darwin
- haxe_nightly_dir: mac
- archive_ext: tar.gz
- - target: darwin
- architecture: 64
- runner: macos-latest
- - target: darwin
- architecture: arm64
- runner: macos-latest
- - build_system: cmake
- cmake_configuration: RelWithDebInfo
- - build_system: cmake-mingw
- cmake_configuration: RelWithDebInfo
- - build_system: vs2019
- msbuild_configuration: Release
- - target: windows
- runner: windows-2022 # has VS 2022 preinstalled which supports PlatformToolset <= v142, WindowsTargetPlatformVersion 10
- haxe_nightly_dir: windows64
- archive_ext: zip
- - target: windows
- build_system: cmake
- cmake_generator: Visual Studio 17 2022
- - target: windows
- architecture: 64
- runner: windows-2025
- build_system: cmake-mingw
- - target: windows
- architecture: 32
- ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648055/ffmpeg-3.4.2-win32-dev.zip
- architecture_string: Win32
- - target: windows
- architecture: 64
- ffmpeg_url: https://github.com/HaxeFoundation/hashlink/files/5648056/ffmpeg-3.4.2-win64-dev.zip
- architecture_string: x64
- exclude:
- - target: linux
- build_system: vs2019
- - target: darwin
- build_system: vs2019
- - target: linux
- architecture: 32
- - target: darwin
- architecture: 32
- - target: linux
- architecture: arm64
- - target: windows
- architecture: arm64
- - target: windows
- build_system: make
- - target: darwin
- architecture: 64
- build_system: make
- - target: darwin
- build_system: makegcc14
- - target: windows
- build_system: makegcc14
- - target: windows
- architecture: 32
- build_system: cmake-mingw
- - target: darwin
- build_system: cmake-mingw
- - target: linux
- build_system: cmake-mingw
- steps:
- - name: "SCM Checkout"
- uses: actions/checkout@v6
- - name: "Add msbuild to PATH"
- if: matrix.build_system == 'vs2019'
- uses: microsoft/setup-msbuild@v2
- - name: "Mac homebrew workaround"
- if: matrix.target == 'darwin'
- run: |
- # see https://github.com/Homebrew/homebrew-core/issues/165793#issuecomment-1989441193
- # see https://github.com/Homebrew/brew/blob/master/.github/workflows/tests.yml
- brew unlink python && brew link --overwrite python
- - name: "Install: Required Dev Packages"
- run: |
- set -eux
- case "${{ matrix.target }}${{ matrix.architecture }}" in
- linux64)
- echo "MARCH=64" >> $GITHUB_ENV
- sudo apt-get update -y
- sudo apt-get install --no-install-recommends -y \
- libmbedtls-dev \
- libopenal-dev \
- libpng-dev \
- libsdl2-dev \
- libturbojpeg-dev \
- libuv1-dev \
- libvorbis-dev \
- libsqlite3-dev
- ;;
- darwin*)
- if [ "${{matrix.build_system}}" != "cmake" ]; then
- brew update
- brew bundle
- fi
- ;;
- windows*)
- if [[ ${{ matrix.build_system }} == cmake-mingw ]]; then
- SDL_SUFFIX=mingw
- else
- SDL_SUFFIX=VC
- fi
- curl -fsSL --retry 3 --retry-delay 5 -o /tmp/sdl.zip https://www.libsdl.org/release/SDL2-devel-2.30.2-${SDL_SUFFIX}.zip
- 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
- curl -fsSL --retry 3 --retry-delay 5 -o /tmp/ffmpeg.zip ${{ matrix.ffmpeg_url }}
- 7z x /tmp/sdl.zip -oinclude; mv include/SDL2* include/sdl
- 7z x /tmp/openal.zip -oinclude; mv include/openal* include/openal
- 7z x /tmp/ffmpeg.zip -oinclude; mv include/ffmpeg* include/ffmpeg
- ;;
- esac
- - name: "Download: DirectX binaries for windows + make"
- if: matrix.target == 'windows' && matrix.build_system != 'cmake' && matrix.build_system != 'cmake-mingw'
- run: |
- 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
- 7z x /tmp/dx.zip -oinclude/dx
- - name: "Install: GCC 14"
- if: matrix.build_system == 'makegcc14'
- run: |
- sudo add-apt-repository universe
- sudo apt update
- sudo apt install -y gcc-14 g++-14
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14
- gcc --version
- - name: Install haxe
- uses: krdlab/setup-haxe@v2
- with:
- haxe-version: latest
- - name: "Configure: Haxelib"
- run: |
- set -eux
- haxelib setup ~/haxelib
- haxelib install hashlink
- haxelib list
- - name: "Build: HashLink"
- run: |
- set -eux
- case "${{ matrix.build_system }}" in
- cmake)
- case "${{ matrix.target }}${{ matrix.architecture }}" in
- windows*)
- cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
- -G "${{ matrix.cmake_generator }}" \
- -A ${{ matrix.architecture_string }}
- ;;
- darwin64)
- cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
- -DDOWNLOAD_DEPENDENCIES=ON \
- -DCMAKE_OSX_ARCHITECTURES=x86_64 \
- -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
- -DFLAT_INSTALL_TREE=ON
- ;;
- darwinarm64)
- cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
- -DDOWNLOAD_DEPENDENCIES=ON \
- -DCMAKE_OSX_ARCHITECTURES=arm64 \
- -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
- -DFLAT_INSTALL_TREE=ON
- ;;
- linux64)
- cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} ;;
- esac
- cmake --build build --config ${{ matrix.cmake_configuration }}
- BUILD_FOLDER=build/bin
- ;;
- cmake-mingw)
- cmake -B build -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} \
- -DWITH_DX12=OFF
- cmake --build build --config ${{ matrix.cmake_configuration }} --parallel
- BUILD_FOLDER=build/bin
- ;;
- vs2019)
- MSBuild.exe hl.sln //nologo //m //clp:ErrorsOnly \
- //p:Configuration=${{ matrix.msbuild_configuration }} \
- //p:Platform=${{ matrix.architecture_string }}
- case "${{ matrix.architecture }}" in
- 64) BUILD_FOLDER=x64/${{ matrix.msbuild_configuration }} ;;
- 32) BUILD_FOLDER=${{ matrix.msbuild_configuration }} ;;
- esac
- echo "WINDOWS_BUILD_FOLDER=$BUILD_FOLDER" >> $GITHUB_ENV
- ;;
- make*)
- make
- sudo make install
- if [[ ${{ matrix.target }} == linux ]]; then
- sudo ldconfig
- fi
- BUILD_FOLDER=.
- ;;
- esac
- ls -l $BUILD_FOLDER
- - name: "Test"
- run: |
- set -eux
- case "${{ matrix.build_system }}" in
- cmake*)
- case "${{matrix.target}}" in
- linux)
- cmake --install build --prefix /tmp/hashlink
- /tmp/hashlink/bin/hl --version
- ;;
- darwin)
- cmake --install build --prefix /tmp/hashlink
- if [ -f /tmp/hashlink/hl ]; then /tmp/hashlink/hl --version; fi
- ;;
- windows)
- export PATH=$(pwd)/build/bin:$PATH
- ;;
- esac
- cd build && ctest --verbose --build-config ${{ matrix.cmake_configuration }}
- ;;
- vs2019)
- ${{ env.WINDOWS_BUILD_FOLDER }}/hl.exe --version
- ;;
- make*)
- if [[ ${{ matrix.architecture }} != arm64 ]]; then
- ./hl --version
- case ${{ matrix.target }} in
- linux) ldd -v ./hl ;;
- darwin) otool -L ./hl ;;
- esac
- haxe -hl hello.hl -cp other/tests -main HelloWorld -D interp
- ./hl hello.hl
- # ensure the executable still works when installed globally
- cp hello.hl /tmp
- pushd /tmp
- hl hello.hl
- popd
- fi
- haxe -hl src/_main.c -cp other/tests -main HelloWorld
- make hlc
- ./hlc
- ;;
- esac
- - name: "Test haxelib build"
- run: |
- haxelib git format https://github.com/HaxeFoundation/format
- cd other/haxelib
- haxe memory.hxml
- haxe profiler.hxml
- cd ../..
- - name: "Package"
- run: |
- set -eux
- case "${{ matrix.target }}${{matrix.architecture}}" in
- darwinarm64) platform_name=darwin-arm64 ;;
- darwin64) platform_name=darwin ;;
- windows*) platform_name=win${{matrix.architecture}} ;;
- linux64) platform_name=linux-amd64 ;;
- esac
- short_commit=$(git rev-parse --short HEAD)
- case "${{ matrix.build_system }}" in
- cmake*)
- dist_folder=hashlink-${short_commit}-${platform_name}-${{ matrix.build_system }}
- cd build && cpack -D CPACK_PACKAGE_FILE_NAME=$dist_folder -C ${{ matrix.cmake_configuration }}
- echo "HASHLINK_DISTRIBUTION=build/bin/$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
- ;;
- *)
- dist_folder=hashlink-${short_commit}-${platform_name}
- make PACKAGE_NAME=$dist_folder MARCH=${{ matrix.architecture }} release
- echo "HASHLINK_DISTRIBUTION=$dist_folder.${{ matrix.archive_ext }}" >> $GITHUB_ENV
- ;;
- esac
- - name: "Share: build artifact"
- uses: actions/upload-artifact@v6
- with:
- name: ${{ matrix.target }}-${{ matrix.build_system }}-${{ matrix.architecture }}
- path: ${{ env.HASHLINK_DISTRIBUTION }}
- build-android:
- runs-on: ubuntu-latest
- steps:
- - name: "SCM Checkout"
- uses: actions/checkout@v6
- - name: Install haxe
- uses: krdlab/setup-haxe@v2
- with:
- haxe-version: latest
- - name: "Configure: Haxelib"
- run: |
- set -eux
- haxelib setup ~/haxelib
- haxelib install hashlink
- haxelib list
- - name: "Build: Hashlink"
- run: |
- set -ex
- cmake -B build -G Ninja --toolchain $ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
- -DANDROID_PLATFORM=24 -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -DWITH_VM=OFF
- cmake --build build
- ###########################################################
- publish-latest-release:
- ###########################################################
- runs-on: ubuntu-latest
- needs:
- - build
- if: github.ref == 'refs/heads/master'
- concurrency: publish-latest-release # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idconcurrency
- steps:
- - name: "SCM Checkout"
- uses: actions/checkout@v6
- - name: "Get: all build artifacts"
- uses: actions/download-artifact@v7
- - name: "Delete previous 'latest' release"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- set -eu
- gh release delete latest --cleanup-tag --yes || true
- - name: "Create 'latest' Release"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- set -eux
- # https://hub.github.com/hub-release.1.html
- short_commit=$(git rev-parse --short HEAD)
- gh release create latest \
- --prerelease \
- --title "HashLink Nightly Build" \
- "darwin-cmake-64/hashlink-${short_commit}-darwin-cmake.tar.gz#hashlink-latest-darwin.tar.gz" \
- "darwin-cmake-arm64/hashlink-${short_commit}-darwin-arm64-cmake.tar.gz#hashlink-latest-darwin-arm64.tar.gz" \
- "linux-make-64/hashlink-${short_commit}-linux-amd64.tar.gz#hashlink-latest-linux-amd64.tar.gz" \
- "windows-vs2019-32/hashlink-${short_commit}-win32.zip#hashlink-latest-win32.zip" \
- "windows-vs2019-64/hashlink-${short_commit}-win64.zip#hashlink-latest-win64.zip" \
- "windows-cmake-mingw-64/hashlink-${short_commit}-win64-cmake-mingw.zip#hashlink-latest-win64-mingw.zip"
|