]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
ci: Add jobs for building binaries for Windows and Linux 1598/head
authorMartin Storsjö <martin@martin.st>
Tue, 10 Jun 2025 10:53:41 +0000 (13:53 +0300)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 5 Aug 2025 17:38:01 +0000 (19:38 +0200)
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.)

.github/workflows/build.yaml
ci/build-binary [new file with mode: 0755]

index 37ae9065636eb8327965521fc6a33927ee305b19..d3335a37e82ebf616f4593494a0fcde0b9807675 100644 (file)
@@ -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 (executable)
index 0000000..ff72a0e
--- /dev/null
@@ -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