mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[CI] Cache the Windows compile results with sccache
A pull request that touches one file rebuilds it, but sccache can hand back the objects for everything else, and the GitHub Actions cache keeps them between runs, so the second build of a branch costs about what the first one stored and nothing more. sccache has to wrap the compiler, and cmake only wraps it for the generators that run the compiler themselves: the Visual Studio generator drives MSBuild, which would drop a launcher on the floor without a word. The cache therefore goes on the Ninja job, and compile.sh now refuses --sccache on any other generator instead of pretending to cache, and prints the sccache statistics next to the existing ccache ones so the hit rate is visible in the log. For MSVC, a cacheable object has to carry its debug information inside, which is /Z7 rather than /Zi; sccache cannot restore the latter, it can only restore a whole object file. Ask CMake for the format by name through CMP0141 and CMAKE_MSVC_DEBUG_INFORMATION_FORMAT instead of hardcoding /Zi in the flags, where it would end up next to /Z7, and keep the format as it was for every build that does not cache. The linker still gets /DEBUG, so the release PDBs are written either way, which is what that flag is there for. The policy is set before project(), since that is when it takes effect, and behind an if(POLICY) guard because it does not exist before CMake 3.25 - where the old defaults remain the only option.
This commit is contained in:
parent
24bb1de9b0
commit
8c38885b44
3 changed files with 64 additions and 5 deletions
18
.github/workflows/desktop-build.yml
vendored
18
.github/workflows/desktop-build.yml
vendored
|
|
@ -415,6 +415,7 @@ jobs:
|
|||
qt_version: 6.11.*
|
||||
qt_modules: qtimageformats qtmultimedia qtshadertools qtwebsockets
|
||||
type: Release
|
||||
use_sccache: 1
|
||||
variant: ' (Ninja)'
|
||||
# The same scope as the Visual Studio leg, so both halves of the A/B
|
||||
# start from the same vcpkg cache and the comparison is about the
|
||||
|
|
@ -521,6 +522,20 @@ jobs:
|
|||
with:
|
||||
arch: x64
|
||||
|
||||
# sccache is only useful for the Ninja job: a compiler cache has to wrap the
|
||||
# compiler, and MSBuild is driven by cmake instead of running it, so a
|
||||
# launcher handed to MSBuild is ignored without a word.
|
||||
- name: "[Windows/Ninja] Set up sccache"
|
||||
if: matrix.os == 'Windows' && matrix.cmake_generator == 'Ninja'
|
||||
uses: mozilla-actions/sccache-action@v0.0.11
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
# A fork pull request can read the cache, but the token it runs with
|
||||
# cannot write to the base branch's scope.
|
||||
SCCACHE_GHA_RW_MODE: ${{ github.event.pull_request.head.repo.fork && 'READ_ONLY' || 'READ_WRITE' }}
|
||||
# A cache that cannot be reached must not fail the build.
|
||||
SCCACHE_IGNORE_SERVER_IO_ERROR: "1"
|
||||
|
||||
- name: "[Windows] Install NSIS"
|
||||
if: matrix.os == 'Windows'
|
||||
shell: bash
|
||||
|
|
@ -569,8 +584,9 @@ jobs:
|
|||
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
||||
MAKE_PACKAGE: '${{ matrix.make_package }}'
|
||||
PACKAGE_SUFFIX: '${{ matrix.package_suffix }}'
|
||||
TARGET_MACOS_VERSION: ${{ matrix.override_target }}
|
||||
TARGET_MACOS_VERSION: '${{ matrix.override_target }}'
|
||||
USE_CCACHE: ${{ matrix.use_ccache }}
|
||||
USE_SCCACHE: ${{ matrix.use_sccache }}
|
||||
# Only pushes to the default branch may write the shared binary cache: the
|
||||
# archives a run compiles are only as trustworthy as the code they were
|
||||
# built from, and only merged code may populate the scope that master and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue