diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f6b6cbb7..18c6bacd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,6 +17,45 @@ jobs: with: submodules: recursive + # ── ccache ──────────────────────────────────────────────────────────── + - name: Install ccache (Linux) + if: runner.os == 'Linux' + run: sudo apt-get install -y ccache + + - name: Install ccache (macOS) + if: runner.os == 'macOS' + run: brew install ccache + + - name: Install ccache (Windows) + if: runner.os == 'Windows' + run: choco install ccache --no-progress + + - name: Cache ccache + uses: actions/cache@v5 + with: + path: | + ~/.ccache + ~/AppData/Local/ccache + key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.build-type }}-${{ github.sha }} + restore-keys: | + ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.build-type }}- + + - name: Configure ccache + shell: bash + run: | + ccache --set-config=max_size=500M + ccache --set-config=compression=true + ccache -z # zero stats so we can see hit rate in logs + + # ── Linux setup ─────────────────────────────────────────────────────── + - name: Cache apt packages + if: runner.os == 'Linux' + uses: actions/cache@v5 + with: + path: /var/cache/apt/archives + key: apt-${{ runner.os }}-${{ hashFiles('.github/workflows/build.yml') }} + restore-keys: apt-${{ runner.os }}- + - name: Add GCC repository if: runner.os == 'Linux' run: | @@ -40,7 +79,9 @@ jobs: gcc-13 g++-13 \ libfontconfig1-dev \ autoconf automake libtool pkg-config libltdl-dev \ - libnotify-dev + libnotify-dev \ + ninja-build \ + gperf - name: Install GCC if: runner.os == 'Linux' @@ -48,12 +89,27 @@ jobs: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13 sudo update-alternatives --set gcc /usr/bin/gcc-13 - # - name: Cache dependencies (macOS) - # uses: actions/cache@v5 - # if: runner.os == 'macOS' - # with: - # path: dependencies - # key: ${{ runner.os }}-dependencies + # ── Project dependencies ────────────────────────────────────────────── + - name: Cache build dependencies (macOS) + if: runner.os == 'macOS' + uses: actions/cache@v5 + with: + path: ci/out + key: deps-macos-${{ runner.arch }}-${{ hashFiles('ci/build-dependencies-macos.sh') }} + + - name: Cache build dependencies (Linux) + if: runner.os == 'Linux' + uses: actions/cache@v5 + with: + path: ci/out + key: deps-linux-${{ runner.arch }}-${{ hashFiles('ci/build-dependencies-linux.sh') }} + + - name: Cache build dependencies (Windows) + if: runner.os == 'Windows' + uses: actions/cache@v5 + with: + path: ci/out + key: deps-windows-${{ runner.arch }}-${{ hashFiles('ci/build-dependencies-windows.ps1') }} - name: Collect dependencies (macOS) if: runner.os == 'macOS' @@ -74,6 +130,7 @@ jobs: cd ci bash build-dependencies-linux.sh + # ── vcpkg ───────────────────────────────────────────────────────────── - name: Set up vcpkg shell: bash run: | @@ -81,6 +138,11 @@ jobs: cd vcpkg ./bootstrap-vcpkg.sh + - name: Get vcpkg commit hash + id: vcpkg-commit + shell: bash + run: echo "hash=$(git -C vcpkg rev-parse HEAD)" >> $GITHUB_OUTPUT + - name: Cache vcpkg packages uses: actions/cache@v5 with: @@ -93,8 +155,10 @@ jobs: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ matrix.build-type }}-${{ steps.vcpkg-commit.outputs.hash }}- vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ matrix.build-type }}- + # ── Build ───────────────────────────────────────────────────────────── - name: Determine CMake Preset id: select-preset + shell: bash run: | if [ "${{ runner.os }}" == "Windows" ]; then prefix="win" @@ -105,7 +169,6 @@ jobs: fi preset="${prefix}-$(echo "${{ matrix.build-type }}" | tr '[:upper:]' '[:lower:]')" echo "preset=$preset" >> $GITHUB_OUTPUT - shell: bash - name: Use Developer Command Prompt for Microsoft Visual C++ if: runner.os == 'Windows' @@ -115,12 +178,19 @@ jobs: run: cmake --preset ${{ steps.select-preset.outputs.preset }} env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache - name: Build run: cmake --build . --preset ${{ steps.select-preset.outputs.preset }} env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg + - name: Print ccache stats + shell: bash + run: ccache -s + + # ── Package ─────────────────────────────────────────────────────────── - name: Prepare Binaries id: prep shell: bash