mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-07 05:53:59 -07:00
use ccache on win
This commit is contained in:
parent
aacd4ae548
commit
119f1b5305
5 changed files with 47 additions and 58 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
||||||
# --dir <dir> sets the name of the build dir, default is "build"
|
# --dir <dir> sets the name of the build dir, default is "build"
|
||||||
# --target-macos-version <version> sets the min os version - only used for macOS builds
|
# --target-macos-version <version> sets the min os version - only used for macOS builds
|
||||||
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_NO_CLIENT MAKE_TEST USE_CCACHE CCACHE_SIZE BUILD_DIR CMAKE_GENERATOR TARGET_MACOS_VERSION
|
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_NO_CLIENT MAKE_TEST USE_CCACHE CCACHE_SIZE CCACHE_VARIANT BUILD_DIR CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM TARGET_MACOS_VERSION
|
||||||
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir>)
|
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir>)
|
||||||
# exitcode: 1 for failure, 3 for invalid arguments
|
# exitcode: 1 for failure, 3 for invalid arguments
|
||||||
|
|
||||||
|
|
@ -129,9 +129,12 @@ if [[ $MAKE_TEST ]]; then
|
||||||
fi
|
fi
|
||||||
if [[ $USE_CCACHE ]]; then
|
if [[ $USE_CCACHE ]]; then
|
||||||
flags+=("-DUSE_CCACHE=1")
|
flags+=("-DUSE_CCACHE=1")
|
||||||
if [[ $CCACHE_SIZE ]]; then
|
if [[ $CCACHE_VARIANT ]]; then
|
||||||
|
flags+=("-DCMAKE_C_COMPILER_LAUNCHER=$CCACHE_VARIANT" "-DCMAKE_CXX_COMPILER_LAUNCHER=$CCACHE_VARIANT")
|
||||||
|
fi
|
||||||
|
if [[ $CCACHE_SIZE && "$CCACHE_VARIANT" != "sccache" ]]; then
|
||||||
# note, this setting persists after running the script
|
# note, this setting persists after running the script
|
||||||
ccache --max-size "$CCACHE_SIZE"
|
"${CCACHE_VARIANT:-ccache}" --max-size "$CCACHE_SIZE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ $PACKAGE_TYPE ]]; then
|
if [[ $PACKAGE_TYPE ]]; then
|
||||||
|
|
@ -141,16 +144,28 @@ if [[ $USE_VCPKG ]]; then
|
||||||
flags+=("-DUSE_VCPKG=1")
|
flags+=("-DUSE_VCPKG=1")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cmake_args=()
|
||||||
|
if [[ $CMAKE_GENERATOR ]]; then
|
||||||
|
cmake_args+=(-G "$CMAKE_GENERATOR")
|
||||||
|
if [[ $CMAKE_GENERATOR_PLATFORM ]]; then
|
||||||
|
cmake_args+=(-A "$CMAKE_GENERATOR_PLATFORM")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Add cmake --build flags
|
# Add cmake --build flags
|
||||||
buildflags=(--config "$BUILDTYPE")
|
buildflags=(--config "$BUILDTYPE")
|
||||||
|
|
||||||
function ccachestatsverbose() {
|
function ccachestatsverbose() {
|
||||||
# note, verbose only works on newer ccache, discard the error
|
local launcher="${CCACHE_VARIANT:-ccache}"
|
||||||
|
if [[ $launcher == "sccache" ]]; then
|
||||||
|
sccache -s
|
||||||
|
else
|
||||||
local got
|
local got
|
||||||
if got="$(ccache --show-stats --verbose 2>/dev/null)"; then
|
if got="$("$launcher" --show-stats --verbose 2>/dev/null)"; then
|
||||||
echo "$got"
|
echo "$got"
|
||||||
else
|
else
|
||||||
ccache --show-stats
|
"$launcher" --show-stats
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +244,6 @@ if [[ $RUNNER_OS == macOS ]]; then
|
||||||
|
|
||||||
elif [[ $RUNNER_OS == Windows ]] && [[ "$CMAKE_GENERATOR" != *Ninja* ]]; then
|
elif [[ $RUNNER_OS == Windows ]] && [[ "$CMAKE_GENERATOR" != *Ninja* ]]; then
|
||||||
# Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
|
# Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
|
||||||
# and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt
|
|
||||||
buildflags+=(-- -p:UseMultiToolTask=true -p:EnableClServerMode=true)
|
buildflags+=(-- -p:UseMultiToolTask=true -p:EnableClServerMode=true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -242,7 +256,7 @@ fi
|
||||||
echo "::group::Configure cmake"
|
echo "::group::Configure cmake"
|
||||||
cmake --version
|
cmake --version
|
||||||
echo "Running cmake with flags: ${flags[*]}"
|
echo "Running cmake with flags: ${flags[*]}"
|
||||||
cmake .. "${flags[@]}"
|
cmake "${cmake_args[@]}" .. "${flags[@]}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
echo "::group::Build project"
|
echo "::group::Build project"
|
||||||
|
|
|
||||||
68
.github/workflows/desktop-build.yml
vendored
68
.github/workflows/desktop-build.yml
vendored
|
|
@ -264,7 +264,7 @@ jobs:
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
cmake_generator: Ninja
|
cmake_generator: Ninja
|
||||||
use_ccache: 1
|
ccache_variant: ccache
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 14
|
target: 14
|
||||||
|
|
@ -279,7 +279,7 @@ jobs:
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
cmake_generator: Ninja
|
cmake_generator: Ninja
|
||||||
use_ccache: 1
|
ccache_variant: ccache
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 15
|
target: 15
|
||||||
|
|
@ -294,7 +294,7 @@ jobs:
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
cmake_generator: Ninja
|
cmake_generator: Ninja
|
||||||
use_ccache: 1
|
ccache_variant: ccache
|
||||||
|
|
||||||
- os: macOS
|
- os: macOS
|
||||||
target: 15
|
target: 15
|
||||||
|
|
@ -306,7 +306,7 @@ jobs:
|
||||||
qt_arch: clang_64
|
qt_arch: clang_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
cmake_generator: Ninja
|
cmake_generator: Ninja
|
||||||
use_ccache: 1
|
ccache_variant: ccache
|
||||||
|
|
||||||
- os: Windows
|
- os: Windows
|
||||||
target: 10
|
target: 10
|
||||||
|
|
@ -319,43 +319,28 @@ jobs:
|
||||||
qt_arch: win64_msvc2022_64
|
qt_arch: win64_msvc2022_64
|
||||||
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
qt_modules: qtimageformats qtmultimedia qtwebsockets
|
||||||
cmake_generator: Ninja
|
cmake_generator: Ninja
|
||||||
|
ccache_variant: sccache
|
||||||
|
|
||||||
name: ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}
|
name: ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}
|
||||||
needs: configure
|
needs: configure
|
||||||
runs-on: ${{matrix.runner}}
|
runs-on: ${{matrix.runner}}
|
||||||
env:
|
|
||||||
CCACHE_DIR: ${{github.workspace}}/.cache/
|
|
||||||
# Cache size over the entire repo is 10Gi:
|
|
||||||
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
|
||||||
CCACHE_SIZE: 500M
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
# Ninja+MSVC requires developer environment; setup-msbuild does not add cl.exe
|
- name: Setup ${{ matrix.ccache_variant }}
|
||||||
- name: Setup MSVC developer environment
|
uses: hendrikmuhs/ccache-action@v1.2.20
|
||||||
|
with:
|
||||||
|
key: ${{ matrix.runner }}-${{ matrix.soc || 'Windows' }}-${{ matrix.type }}-${{ github.ref_name }}
|
||||||
|
restore-keys: ${{ matrix.runner }}-${{ matrix.soc || 'Windows' }}-${{ matrix.type }}-master
|
||||||
|
max-size: 500M
|
||||||
|
variant: ${{ matrix.ccache_variant }}
|
||||||
|
|
||||||
|
- name: Setup MSVC (Windows)
|
||||||
if: matrix.os == 'Windows'
|
if: matrix.os == 'Windows'
|
||||||
uses: ilammy/msvc-dev-cmd@v1
|
uses: ilammy/msvc-dev-cmd@v1.13.0
|
||||||
with:
|
|
||||||
arch: x64
|
|
||||||
|
|
||||||
- name: Setup ccache
|
|
||||||
if: matrix.use_ccache == 1 && matrix.os == 'macOS'
|
|
||||||
run: brew install ccache
|
|
||||||
|
|
||||||
- name: Restore compiler cache (ccache)
|
|
||||||
if: matrix.use_ccache == 1
|
|
||||||
id: ccache_restore
|
|
||||||
uses: actions/cache/restore@v5
|
|
||||||
env:
|
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
||||||
with:
|
|
||||||
path: ${{env.CCACHE_DIR}}
|
|
||||||
key: ccache-${{matrix.runner}}-${{matrix.soc}}-${{matrix.type}}-${{env.BRANCH_NAME}}
|
|
||||||
restore-keys: ccache-${{matrix.runner}}-${{matrix.soc}}-${{matrix.type}}-
|
|
||||||
|
|
||||||
- name: Install aqtinstall
|
- name: Install aqtinstall
|
||||||
if: matrix.os == 'macOS'
|
if: matrix.os == 'macOS'
|
||||||
|
|
@ -423,13 +408,15 @@ jobs:
|
||||||
# uses environment variables, see compile.sh for more details
|
# uses environment variables, see compile.sh for more details
|
||||||
- name: Build Cockatrice
|
- name: Build Cockatrice
|
||||||
id: build
|
id: build
|
||||||
|
shell: bash
|
||||||
env:
|
env:
|
||||||
BUILDTYPE: '${{matrix.type}}'
|
BUILDTYPE: '${{matrix.type}}'
|
||||||
MAKE_PACKAGE: '${{matrix.make_package}}'
|
MAKE_PACKAGE: '${{matrix.make_package}}'
|
||||||
PACKAGE_SUFFIX: '${{matrix.package_suffix}}'
|
PACKAGE_SUFFIX: '${{matrix.package_suffix}}'
|
||||||
CMAKE_GENERATOR: ${{matrix.cmake_generator}}
|
CMAKE_GENERATOR: ${{matrix.cmake_generator}}
|
||||||
CMAKE_GENERATOR_PLATFORM: ${{matrix.cmake_generator_platform}}
|
CMAKE_GENERATOR_PLATFORM: ${{ matrix.cmake_generator_platform || '' }}
|
||||||
USE_CCACHE: ${{matrix.use_ccache}}
|
USE_CCACHE: 1
|
||||||
|
CCACHE_VARIANT: ${{ matrix.ccache_variant }}
|
||||||
VCPKG_DISABLE_METRICS: 1
|
VCPKG_DISABLE_METRICS: 1
|
||||||
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
|
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
|
||||||
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
|
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
|
||||||
|
|
@ -438,16 +425,7 @@ jobs:
|
||||||
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
|
||||||
DEVELOPER_DIR: '/Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer'
|
DEVELOPER_DIR: '/Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer'
|
||||||
TARGET_MACOS_VERSION: ${{ matrix.override_target }}
|
TARGET_MACOS_VERSION: ${{ matrix.override_target }}
|
||||||
run: bash .ci/compile.sh --server --test --vcpkg
|
run: .ci/compile.sh --server --test --vcpkg --ccache 500M
|
||||||
|
|
||||||
- name: Save compiler cache (ccache)
|
|
||||||
if: github.ref == 'refs/heads/master' && matrix.use_ccache == 1
|
|
||||||
uses: actions/cache/save@v5
|
|
||||||
env:
|
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
||||||
with:
|
|
||||||
path: ${{env.CCACHE_DIR}}
|
|
||||||
key: ccache-${{matrix.runner}}-${{matrix.soc}}-${{matrix.type}}-${{env.BRANCH_NAME}}
|
|
||||||
|
|
||||||
- name: Sign app bundle
|
- name: Sign app bundle
|
||||||
if: matrix.os == 'macOS' && matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null)
|
if: matrix.os == 'macOS' && matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null)
|
||||||
|
|
@ -508,9 +486,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: Windows${{matrix.target}}-PDBs
|
name: Windows${{matrix.target}}-PDBs
|
||||||
path: |
|
path: |
|
||||||
build/cockatrice/*.pdb
|
build/cockatrice/**/*.pdb
|
||||||
build/oracle/*.pdb
|
build/oracle/**/*.pdb
|
||||||
build/servatrice/*.pdb
|
build/servatrice/**/*.pdb
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload to release
|
- name: Upload to release
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,6 @@ if(WIN32)
|
||||||
set(plugin_dest_dir Plugins)
|
set(plugin_dest_dir Plugins)
|
||||||
set(qtconf_dest_dir .)
|
set(qtconf_dest_dir .)
|
||||||
|
|
||||||
# Use target runtime dir for both multi-config (VS) and single-config (Ninja)
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "$<TARGET_FILE_DIR:cockatrice>/"
|
DIRECTORY "$<TARGET_FILE_DIR:cockatrice>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,6 @@ if(WIN32)
|
||||||
set(qtconf_dest_dir .)
|
set(qtconf_dest_dir .)
|
||||||
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
|
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
|
||||||
|
|
||||||
# Use target runtime dir for both multi-config (VS) and single-config (Ninja)
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "$<TARGET_FILE_DIR:oracle>/"
|
DIRECTORY "$<TARGET_FILE_DIR:oracle>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,6 @@ if(WIN32)
|
||||||
set(plugin_dest_dir Plugins)
|
set(plugin_dest_dir Plugins)
|
||||||
set(qtconf_dest_dir .)
|
set(qtconf_dest_dir .)
|
||||||
|
|
||||||
# Use target runtime dir for both multi-config (VS) and single-config (Ninja)
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "$<TARGET_FILE_DIR:servatrice>/"
|
DIRECTORY "$<TARGET_FILE_DIR:servatrice>/"
|
||||||
DESTINATION ./
|
DESTINATION ./
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue