From: Martin Storsjö Date: Tue, 10 Jun 2025 10:53:41 +0000 (+0300) Subject: ci: Add jobs for building binaries for Windows and Linux X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c468dad88177217484d0508ee783c440ecf9deb2;p=thirdparty%2Fccache.git ci: Add jobs for building binaries for Windows and Linux Build binaries for x86_64 and aarch64 on Linux, and i686, x86_64 and aarch64 for Windows. The Windows binaries are cross compiled from Linux. For x86, it uses distro provided compilers, while it uses llvm-mingw installed separately for targeting aarch64. (Most distros don't have packages for mingw cross compilers for targeting Windows on aarch64 yet. GCC isn't mature for this target yet, but Clang has supported this target for many years now. Llvm-mingw is essentially the same toolchain setup as MSYS2 uses in their clangarm64 environment, but available as a standalone cross compiler too.) --- diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 37ae9065..d3335a37 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -271,6 +271,78 @@ jobs: name: macOS-binary path: build_universal/ccache + build_linux_binary: + timeout-minutes: 30 + name: Linux ${{ matrix.arch }} binary + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-22.04 + arch: x86_64 + + - os: ubuntu-22.04-arm + arch: aarch64 + + env: + CMAKE_GENERATOR: Ninja + steps: + - name: Get source + uses: actions/checkout@v4 + - name: Build binary + run: ci/build-binary + - name: Archive binary + uses: actions/upload-artifact@v4 + with: + name: linux-binary-${{ matrix.arch }} + path: install/bin/ccache + + build_windows_binary: + timeout-minutes: 30 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: i686 + toolchain: i686-w64-mingw32-posix + apt_get: g++-mingw-w64-i686-posix + + - arch: x86_64 + toolchain: x86_64-w64-mingw32-posix + apt_get: g++-mingw-w64-x86-64-posix + + - arch: aarch64 + toolchain: aarch64-w64-mingw32 + llvm_mingw: true + + name: Windows ${{ matrix.arch }} binary + steps: + - name: Run apt-get + if: matrix.apt_get != '' + run: sudo apt-get update && sudo apt-get install ${{ matrix.apt_get }} + - name: Install llvm-mingw + if: matrix.llvm_mingw != '' + run: | + curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250709/llvm-mingw-20250709-ucrt-ubuntu-22.04-x86_64.tar.xz + tar -Jxf llvm-mingw-*.tar.xz + rm *.tar.xz + sudo mkdir -p /opt + sudo mv llvm-mingw-* /opt/llvm-mingw + echo /opt/llvm-mingw/bin >> $GITHUB_PATH + - name: Get source + uses: actions/checkout@v4 + - name: Build binary + env: + CMAKE_PARAMS: -D CMAKE_TOOLCHAIN_FILE=../toolchains/${{ matrix.toolchain }}.cmake + run: ci/build-binary + - name: Archive binary + uses: actions/upload-artifact@v4 + with: + name: windows-binary-${{ matrix.arch }} + path: install/bin/ccache.exe + specific_tests: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} diff --git a/ci/build-binary b/ci/build-binary new file mode 100755 index 00000000..ff72a0e6 --- /dev/null +++ b/ci/build-binary @@ -0,0 +1,17 @@ +#!/bin/sh + +set -eu + +: ${CMAKE_PARAMS:=} + +mkdir -p "build" +cd "build" +cmake \ + -D CMAKE_BUILD_TYPE=Release \ + -D DEPS=DOWNLOAD \ + -D ENABLE_TESTING=OFF \ + -D CMAKE_INSTALL_PREFIX=$(pwd)/../install \ + ${CMAKE_PARAMS} \ + .. +cmake --build . +cmake --install . --strip