This commit is contained in:
tooomm 2026-09-20 18:20:11 +00:00 committed by GitHub
commit c781db90bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 96 additions and 48 deletions

View file

@ -124,19 +124,27 @@ set -e
# Setup # Setup
./servatrice/check_schema_version.sh ./servatrice/check_schema_version.sh
if [[ ! $USE_CCACHE ]]; then
USE_CCACHE=0
fi
if [[ ! $BUILDTYPE ]]; then if [[ ! $BUILDTYPE ]]; then
BUILDTYPE=Release BUILDTYPE=Release
fi fi
if [[ ! $BUILD_DIR ]]; then if [[ ! $BUILD_DIR ]]; then
BUILD_DIR="build" BUILD_DIR="build"
fi fi
# Can be omitted when using modern CMake config commands below for config and build (chceck BUILD_DIR logic above as well)
# cmake -S . -B "$BUILD_DIR" "${flags[@]}"
# cmake --build "$BUILD_DIR" "${buildflags[@]}"
# Required to update other commands with build folder as well:
# ctest --build-config "$BUILDTYPE" --test-dir "$BUILD_DIR" --output-on-failure
# cmake --build "$BUILD_DIR" --target install --config "$BUILDTYPE"
# cmake --build "$BUILD_DIR" --target package --config "$BUILDTYPE" (remove cd from renaming)
mkdir -p "$BUILD_DIR" mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
# Set minimum CMake Version # Add CMake flags
export CMAKE_POLICY_VERSION_MINIMUM=3.10
# Add cmake flags
flags=("-DCMAKE_BUILD_TYPE=$BUILDTYPE") flags=("-DCMAKE_BUILD_TYPE=$BUILDTYPE")
if [[ $MAKE_SERVER ]]; then if [[ $MAKE_SERVER ]]; then
flags+=("-DWITH_SERVER=1") flags+=("-DWITH_SERVER=1")
@ -147,28 +155,34 @@ fi
if [[ $MAKE_TEST ]]; then if [[ $MAKE_TEST ]]; then
flags+=("-DTEST=1") flags+=("-DTEST=1")
fi fi
if [[ $USE_CCACHE ]]; then if [[ $USE_CCACHE == "1" ]]; then
flags+=("-DUSE_CCACHE=1") flags+=("-DUSE_CCACHE=1")
# PCH-aware caching is required or ccache refuses to cache any TU that # PCH-aware caching is required or ccache refuses to cache any TU that
# consumes a precompiled header, silently recompiling everything on every run. # consumes a precompiled header, silently recompiling everything on every run.
ccache --set-config sloppiness=pch_defines,time_macros ccache --set-config sloppiness=pch_defines,time_macros
if [[ $CCACHE_SIZE ]]; then if [[ -n $CCACHE_SIZE ]]; then
# note, this setting persists after running the script # Note, this setting persists after running the script
ccache --max-size "$CCACHE_SIZE" ccache --max-size "$CCACHE_SIZE"
fi fi
else
flags+=("-DUSE_CCACHE=0")
fi fi
if [[ $PACKAGE_TYPE ]]; then if [[ -n $PACKAGE_TYPE ]]; then
flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE") flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE")
fi fi
if [[ $USE_VCPKG ]]; then if [[ $USE_VCPKG ]]; then
flags+=("-DUSE_VCPKG=1") flags+=("-DUSE_VCPKG=1")
flags+=("-DVCPKG_INSTALL_OPTIONS=--x-abi-tools-use-exact-versions") flags+=("-DVCPKG_INSTALL_OPTIONS=--x-abi-tools-use-exact-versions")
# if [[ $MAKE_PACKAGE && $RUNNER_OS == Windows ]]; then
# flags+=("-DVCPKG_APPLOCAL_DEPS=OFF") # disable copying of runtime DLLs into build output
# fi
fi fi
# Add cmake --build flags # Add CMake --build flags
buildflags=(--config "$BUILDTYPE") buildflags=(--config "$BUILDTYPE")
function ccachestatsverbose() { function ccachestatsverbose() {
ccache --version
# note, verbose only works on newer ccache, discard the error # note, verbose only works on newer ccache, discard the error
local got local got
if got="$(ccache --show-stats --verbose 2>/dev/null)"; then if got="$(ccache --show-stats --verbose 2>/dev/null)"; then
@ -178,7 +192,7 @@ function ccachestatsverbose() {
fi fi
} }
# Compile # Prepare compilation
if [[ $RUNNER_OS == macOS ]]; then if [[ $RUNNER_OS == macOS ]]; then
# QTDIR is needed for macOS since we actually only use the cached thin Qt binaries instead of the install-qt-action, # QTDIR is needed for macOS since we actually only use the cached thin Qt binaries instead of the install-qt-action,
# which sets a few environment variables # which sets a few environment variables
@ -256,30 +270,38 @@ if [[ $RUNNER_OS == macOS ]]; then
fi fi
elif [[ $RUNNER_OS == Windows ]]; then elif [[ $RUNNER_OS == Windows ]]; then
# Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/ if [[ "$CMAKE_GENERATOR" =~ ^Visual\ Studio ]]; then
# Enable MSBuild switches for 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 # 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 fi
if [[ $USE_CCACHE ]]; then if [[ $USE_CCACHE == "1" ]]; then
echo "::group::Show ccache stats" echo "::group::Show ccache stats"
ccachestatsverbose ccachestatsverbose
echo "::endgroup::" echo "::endgroup::"
fi fi
echo "::group::Configure cmake" # Configure CMake
echo "::group::Configure CMake"
cmake --version cmake --version
echo "Running cmake with flags: ${flags[*]}" if [[ "$CMAKE_GENERATOR" =~ ^Ninja ]]; then
echo "ninja $(ninja --version)"
fi
echo "Running CMake with these flags: ${flags[*]}"
# Equivalent to modern and more explicit "cmake -S .. -B build"
cmake .. "${flags[@]}" cmake .. "${flags[@]}"
echo "::endgroup::" echo "::endgroup::"
# Build
echo "::group::Build project" echo "::group::Build project"
echo "Running cmake --build with flags: ${buildflags[*]}" echo "Running CMake with these build flags: ${buildflags[*]}"
cmake --build . "${buildflags[@]}" cmake --build . "${buildflags[@]}"
echo "::endgroup::" echo "::endgroup::"
if [[ $USE_CCACHE ]]; then if [[ $USE_CCACHE == "1" ]]; then
if [[ $CCACHE_EVICTION_AGE ]]; then if [[ -n $CCACHE_EVICTION_AGE ]]; then
echo "::group::evict ccache files older than $CCACHE_EVICTION_AGE" echo "::group::evict ccache files older than $CCACHE_EVICTION_AGE"
ccache --evict-older-than "$CCACHE_EVICTION_AGE" ccache --evict-older-than "$CCACHE_EVICTION_AGE"
echo "::endgroup::" echo "::endgroup::"
@ -304,24 +326,30 @@ if [[ $RUNNER_OS == macOS ]]; then
echo "::endgroup::" echo "::endgroup::"
fi fi
# Test
if [[ $MAKE_TEST ]]; then if [[ $MAKE_TEST ]]; then
echo "::group::Run tests" echo "::group::Run tests"
ctest -C "$BUILDTYPE" --output-on-failure ctest --version
ctest --build-config "$BUILDTYPE" --output-on-failure
echo "::endgroup::" echo "::endgroup::"
fi fi
# Install
if [[ $MAKE_INSTALL ]]; then if [[ $MAKE_INSTALL ]]; then
echo "::group::Install" echo "::group::Install"
# Equivalent to modern "cmake --install ."
cmake --build . --target install --config "$BUILDTYPE" cmake --build . --target install --config "$BUILDTYPE"
echo "::endgroup::" echo "::endgroup::"
fi fi
# Package
if [[ $MAKE_PACKAGE ]]; then if [[ $MAKE_PACKAGE ]]; then
echo "::group::Create package" echo "::group::Create package"
cpack --version
cmake --build . --target package --config "$BUILDTYPE" cmake --build . --target package --config "$BUILDTYPE"
echo "::endgroup::" echo "::endgroup::"
if [[ $PACKAGE_SUFFIX ]]; then if [[ -n $PACKAGE_SUFFIX ]]; then
echo "::group::Update package name" echo "::group::Update package name"
cd .. cd ..
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX" BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"

View file

@ -328,15 +328,26 @@ jobs:
target: 10 target: 10
runner: windows-2025 # https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-VS2026-Readme.md runner: windows-2025 # https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-VS2026-Readme.md
cmake_generator: "Visual Studio 18 2026" cmake_generator: Ninja
cmake_generator_platform: x64
make_package: 1 make_package: 1
package_suffix: "-Win10" package_suffix: "-Win10"
qt_version: 6.11.* qt_version: 6.11.*
qt_modules: qtimageformats qtmultimedia qtshadertools qtwebsockets qt_modules: qtimageformats qtmultimedia qtshadertools qtwebsockets
type: Release type: Release
name: ${{ matrix.os }} ${{ matrix.target }}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} - os: Windows
target: 10
runner: windows-2025
cmake_generator: "Visual Studio 18 2026"
cmake_generator_platform: x64
make_package: 1
package_suffix: "-Win10_VS"
qt_version: 6.11.*
qt_modules: qtimageformats qtmultimedia qtshadertools qtwebsockets
type: Release
name: ${{ matrix.os }} ${{ matrix.target }}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}${{ matrix.cmake_generator != 'Ninja' && ' VS' || '' }}
needs: configure needs: configure
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}
timeout-minutes: 100 timeout-minutes: 100
@ -350,11 +361,11 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: "[Windows] Add msbuild to PATH" - name: "[Windows] Setup MSVC"
if: matrix.os == 'Windows' if: matrix.os == 'Windows'
uses: microsoft/setup-msbuild@v3 uses: TheMrMilchmann/setup-msvc-dev@v4
with: with:
msbuild-architecture: x64 arch: x64
- name: "[macOS] Setup ccache" - name: "[macOS] Setup ccache"
if: matrix.os == 'macOS' && matrix.use_ccache == 1 if: matrix.os == 'macOS' && matrix.use_ccache == 1
@ -426,7 +437,7 @@ jobs:
- name: "[Windows] Install NSIS" - name: "[Windows] Install NSIS"
if: matrix.os == 'Windows' if: matrix.os == 'Windows'
shell: bash shell: bash
run: choco install nsis run: choco install nsis --no-progress
- name: "Setup vcpkg cache" - name: "Setup vcpkg cache"
id: vcpkg-cache id: vcpkg-cache
@ -534,15 +545,15 @@ jobs:
path: ${{ steps.build.outputs.path }} path: ${{ steps.build.outputs.path }}
- name: "[Windows] Upload PDBs (Program Databases)" - name: "[Windows] Upload PDBs (Program Databases)"
if: matrix.os == 'Windows' && github.ref_type != 'tag' if: matrix.os == 'Windows' && github.ref_type != 'tag' && matrix.cmake_generator == 'Ninja'
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
if-no-files-found: error if-no-files-found: error
name: ${{ steps.build.outputs.name }}-PDBs name: ${{ steps.build.outputs.name }}-PDBs
path: | path: |
build/cockatrice/Release/*.pdb build/cockatrice/*.pdb
build/oracle/Release/*.pdb build/oracle/*.pdb
build/servatrice/Release/*.pdb build/servatrice/*.pdb
- name: "Upload to release" - name: "Upload to release"
if: needs.configure.outputs.tag != null && matrix.make_package == '1' if: needs.configure.outputs.tag != null && matrix.make_package == '1'

View file

@ -27,15 +27,10 @@ option(USE_VCPKG "Use vcpkg regardless of OS" OFF)
# Default to "Release" build type # Default to "Release" build type
# User-provided value for CMAKE_BUILD_TYPE must be checked before the PROJECT() call # User-provided value for CMAKE_BUILD_TYPE must be checked before the PROJECT() call
if(DEFINED CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
${CMAKE_BUILD_TYPE}
CACHE STRING "Type of build"
)
else()
set(CMAKE_BUILD_TYPE set(CMAKE_BUILD_TYPE
Release Release
CACHE STRING "Type of build" CACHE STRING "Build type"
) )
endif() endif()
@ -99,6 +94,7 @@ set(CMAKE_CXX_STANDARD
CACHE STRING "C++ ISO Standard" CACHE STRING "C++ ISO Standard"
) )
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set conventional loops # Set conventional loops
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
@ -114,8 +110,7 @@ include(createversionfile)
# Define a proper install path # Define a proper install path
if(UNIX) if(UNIX)
if(APPLE) if(APPLE) # macOS
# macOS
# Due to the special bundle structure ignore # Due to the special bundle structure ignore
# the prefix eventually set by the user. # the prefix eventually set by the user.
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/release) set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/release)
@ -151,12 +146,25 @@ elseif(WIN32)
endif() endif()
# Define proper compilation flags # Define proper compilation flags
if(MSVC) if(MSVC) # MS Visual C++ compiler
# Disable Warning C4251, C++20 compatibility, Multi-threaded Builds, Warn Detection, Unwind Semantics, Debug Symbols # /wd4251 Suppress C4251 (DLL interface) warnings
set(CMAKE_CXX_FLAGS "/wd4251 /Zc:__cplusplus /std:c++20 /permissive- /W4 /MP /EHsc /Zi") # /W4 Enable warning level 4
# Visual Studio: Maximum Optimization, Multi-threaded DLL # /EHsc Enable standard C++ exception handling
# /Zi Generate debugging information (Program Database, PDB)
set(CMAKE_CXX_FLAGS "/wd4251 /W4 /EHsc /Zi")
# Visual Studio generator: Append parallelisation flag (not needed with Ninja)
# /MP Enable parallel compilation
if(CMAKE_GENERATOR MATCHES "^Visual Studio")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
# /Ox Enable maximum optimization
# /MD Link against the multi-threaded DLL runtime library (Release CRT)
set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MD") set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MD")
# Visual Studio: No Optimization, Multi-threaded Debug DLL
# /Od Disable optimization
# /MDd Link against the multi-threaded Debug DLL runtime library (Debug CRT)
set(CMAKE_CXX_FLAGS_DEBUG "/Od /MDd") set(CMAKE_CXX_FLAGS_DEBUG "/Od /MDd")
# Generate PDB, even when in release (So developers can better analyze crash logs) # Generate PDB, even when in release (So developers can better analyze crash logs)
@ -317,7 +325,7 @@ if(UNIX)
endif() endif()
elseif(WIN32) elseif(WIN32)
set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "(x64)") if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TRICE_IS_64_BIT 1) set(TRICE_IS_64_BIT 1)
else() else()
set(TRICE_IS_64_BIT 0) set(TRICE_IS_64_BIT 0)

View file

@ -211,6 +211,7 @@ if(WIN32)
set(plugin_dest_dir Plugins) set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .) set(qtconf_dest_dir .)
list(APPEND libSearchDirs ${QT_LIBRARY_DIR}) list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
list(APPEND libSearchDirs "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/bin")
install( install(
DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/"

View file

@ -10,7 +10,7 @@ declare -i schema_ver="${version_line%%)*}"
latest_migration="$(ls -1 servatrice/migrations/ | tail -n1)" latest_migration="$(ls -1 servatrice/migrations/ | tail -n1)"
xtoysql="${latest_migration#servatrice_}" xtoysql="${latest_migration#servatrice_}"
xtoy="${xtoysql%.sql}" xtoy="${xtoysql%.sql}"
declare -i old_ver="10#${xtoy%_to_*}" #declare as integer with base 10, numbers with a leading 0 are normally interpreted as base 16 declare -i old_ver="10#${xtoy%_to_*}" # declare as integer with base 10, numbers with a leading 0 are normally interpreted as base 16
declare -i new_ver="10#${xtoy#*_to_}" declare -i new_ver="10#${xtoy#*_to_}"
if ((old_ver >= new_ver)); then if ((old_ver >= new_ver)); then

View file

@ -20,10 +20,9 @@ add_test(NAME metrics_registry_test COMMAND metrics_registry_test)
add_test(NAME loader_local_matching_test COMMAND loader_local_matching_test) add_test(NAME loader_local_matching_test COMMAND loader_local_matching_test)
add_test(NAME deck_hash_performance_test COMMAND deck_hash_performance_test) add_test(NAME deck_hash_performance_test COMMAND deck_hash_performance_test)
set_tests_properties(dummy_test PROPERTIES TIMEOUT 5)
set_tests_properties(deck_hash_performance_test PROPERTIES TIMEOUT 15) set_tests_properties(deck_hash_performance_test PROPERTIES TIMEOUT 15)
# Find GTest
add_executable(dummy_test dummy_test.cpp) add_executable(dummy_test dummy_test.cpp)
add_executable(expression_test expression_test.cpp) add_executable(expression_test expression_test.cpp)
add_executable(clamped_arithmetic_test clamped_arithmetic_test.cpp) add_executable(clamped_arithmetic_test clamped_arithmetic_test.cpp)
@ -53,6 +52,7 @@ add_executable(
) )
target_include_directories(loader_local_matching_test PRIVATE ${CMAKE_SOURCE_DIR}/cockatrice/src) target_include_directories(loader_local_matching_test PRIVATE ${CMAKE_SOURCE_DIR}/cockatrice/src)
# Find GTest
find_package(GTest) find_package(GTest)
if(NOT GTEST_FOUND) if(NOT GTEST_FOUND)