This commit is contained in:
tooomm
2026-08-05 09:52:11 -07:00
committed by GitHub
6 changed files with 97 additions and 50 deletions

View File

@@ -124,19 +124,27 @@ set -e
# Setup
./servatrice/check_schema_version.sh
if [[ ! $USE_CCACHE ]]; then
USE_CCACHE=0
fi
if [[ ! $BUILDTYPE ]]; then
BUILDTYPE=Release
fi
if [[ ! $BUILD_DIR ]]; then
BUILD_DIR="build"
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"
cd "$BUILD_DIR"
# Set minimum CMake Version
export CMAKE_POLICY_VERSION_MINIMUM=3.10
# Add cmake flags
# Add CMake flags
flags=("-DCMAKE_BUILD_TYPE=$BUILDTYPE")
if [[ $MAKE_SERVER ]]; then
flags+=("-DWITH_SERVER=1")
@@ -147,24 +155,30 @@ fi
if [[ $MAKE_TEST ]]; then
flags+=("-DTEST=1")
fi
if [[ $USE_CCACHE ]]; then
if [[ $USE_CCACHE == "1" ]]; then
flags+=("-DUSE_CCACHE=1")
if [[ $CCACHE_SIZE ]]; then
# note, this setting persists after running the script
if [[ -n $CCACHE_SIZE ]]; then
# Note, this setting persists after running the script
ccache --max-size "$CCACHE_SIZE"
fi
else
flags+=("-DUSE_CCACHE=0")
fi
if [[ $PACKAGE_TYPE ]]; then
if [[ -n $PACKAGE_TYPE ]]; then
flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE")
fi
if [[ $USE_VCPKG ]]; then
flags+=("-DUSE_VCPKG=1")
# if [[ $MAKE_PACKAGE && $RUNNER_OS == Windows ]]; then
# flags+=("-DVCPKG_APPLOCAL_DEPS=OFF") # disable copying of runtime DLLs into build output
# fi
fi
# Add cmake --build flags
# Add CMake --build flags
buildflags=(--config "$BUILDTYPE")
function ccachestatsverbose() {
ccache --version
# note, verbose only works on newer ccache, discard the error
local got
if got="$(ccache --show-stats --verbose 2>/dev/null)"; then
@@ -174,7 +188,7 @@ function ccachestatsverbose() {
fi
}
# Compile
# Prepare compilation
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,
# which sets a few environment variables
@@ -252,30 +266,38 @@ if [[ $RUNNER_OS == macOS ]]; then
fi
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
buildflags+=(-- -p:UseMultiToolTask=true -p:EnableClServerMode=true)
fi
fi
if [[ $USE_CCACHE ]]; then
if [[ $USE_CCACHE == "1" ]]; then
echo "::group::Show ccache stats"
ccachestatsverbose
echo "::endgroup::"
fi
echo "::group::Configure cmake"
# Configure CMake
echo "::group::Configure CMake"
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[@]}"
echo "::endgroup::"
# Build
echo "::group::Build project"
echo "Running cmake --build with flags: ${buildflags[*]}"
echo "Running CMake with these build flags: ${buildflags[*]}"
cmake --build . "${buildflags[@]}"
echo "::endgroup::"
if [[ $USE_CCACHE ]]; then
if [[ $CCACHE_EVICTION_AGE ]]; then
if [[ $USE_CCACHE == "1" ]]; then
if [[ -n $CCACHE_EVICTION_AGE ]]; then
echo "::group::evict ccache files older than $CCACHE_EVICTION_AGE"
ccache --evict-older-than "$CCACHE_EVICTION_AGE"
echo "::endgroup::"
@@ -300,24 +322,30 @@ if [[ $RUNNER_OS == macOS ]]; then
echo "::endgroup::"
fi
# Test
if [[ $MAKE_TEST ]]; then
echo "::group::Run tests"
ctest -C "$BUILDTYPE" --output-on-failure
ctest --version
ctest --build-config "$BUILDTYPE" --output-on-failure
echo "::endgroup::"
fi
# Install
if [[ $MAKE_INSTALL ]]; then
echo "::group::Install"
# Equivalent to modern "cmake --install ."
cmake --build . --target install --config "$BUILDTYPE"
echo "::endgroup::"
fi
# Package
if [[ $MAKE_PACKAGE ]]; then
echo "::group::Create package"
cpack --version
cmake --build . --target package --config "$BUILDTYPE"
echo "::endgroup::"
if [[ $PACKAGE_SUFFIX ]]; then
if [[ -n $PACKAGE_SUFFIX ]]; then
echo "::group::Update package name"
cd ..
BUILD_DIR="$BUILD_DIR" .ci/name_build.sh "$PACKAGE_SUFFIX"

View File

@@ -324,15 +324,26 @@ jobs:
target: 10
runner: windows-2025
cmake_generator: "Visual Studio 18 2026"
cmake_generator_platform: x64
cmake_generator: Ninja
make_package: 1
package_suffix: "-Win10"
qt_version: 6.11.0
qt_modules: qtimageformats qtmultimedia qtwebsockets
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.0
qt_modules: qtimageformats qtmultimedia qtwebsockets
type: Release
name: ${{ matrix.os }} ${{ matrix.target }}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}${{ matrix.cmake_generator != 'Ninja' && ' VS' || '' }}
needs: configure
runs-on: ${{ matrix.runner }}
timeout-minutes: 100
@@ -346,12 +357,11 @@ jobs:
with:
submodules: recursive
- name: "[Windows] Add msbuild to PATH"
- name: "[Windows] Setup MSVC"
if: matrix.os == 'Windows'
id: add-msbuild
uses: microsoft/setup-msbuild@v3
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
msbuild-architecture: x64
arch: x64
- name: "[macOS] Setup ccache"
if: matrix.os == 'macOS' && matrix.use_ccache == 1
@@ -422,7 +432,7 @@ jobs:
- name: "[Windows] Install NSIS"
if: matrix.os == 'Windows'
shell: bash
run: choco install nsis
run: choco install nsis --no-progress
- name: "Setup vcpkg cache"
id: vcpkg-cache
@@ -528,15 +538,15 @@ jobs:
path: ${{ steps.build.outputs.path }}
- 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
with:
if-no-files-found: error
name: ${{ steps.build.outputs.name }}-PDBs
path: |
build/cockatrice/Release/*.pdb
build/oracle/Release/*.pdb
build/servatrice/Release/*.pdb
build/cockatrice/*.pdb
build/oracle/*.pdb
build/servatrice/*.pdb
- name: "Upload to release"
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
# User-provided value for CMAKE_BUILD_TYPE must be checked before the PROJECT() call
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
${CMAKE_BUILD_TYPE}
CACHE STRING "Type of build"
)
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Release
CACHE STRING "Type of build"
CACHE STRING "Build type"
)
endif()
@@ -87,6 +82,7 @@ set(CMAKE_CXX_STANDARD
CACHE STRING "C++ ISO Standard"
)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set conventional loops
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
@@ -102,8 +98,7 @@ include(createversionfile)
# Define a proper install path
if(UNIX)
if(APPLE)
# macOS
if(APPLE) # macOS
# Due to the special bundle structure ignore
# the prefix eventually set by the user.
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/release)
@@ -139,12 +134,25 @@ elseif(WIN32)
endif()
# Define proper compilation flags
if(MSVC)
# Disable Warning C4251, C++20 compatibility, Multi-threaded Builds, Warn Detection, Unwind Semantics, Debug Symbols
set(CMAKE_CXX_FLAGS "/wd4251 /Zc:__cplusplus /std:c++20 /permissive- /W4 /MP /EHsc /Zi")
# Visual Studio: Maximum Optimization, Multi-threaded DLL
if(MSVC) # MS Visual C++ compiler
# /wd4251 Suppress C4251 (DLL interface) warnings
# /W4 Enable warning level 4
# /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")
# 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")
# Generate PDB, even when in release (So developers can better analyze crash logs)
@@ -174,7 +182,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
-Wno-error=delete-non-virtual-dtor
-Wno-error=sign-compare
-Wno-error=missing-declarations
-Wno-error=sfinae-incomplete # GCC 16+: Qt MOC + protobuf forward decls trigger this
-Wno-error=sfinae-incomplete # GCC 16+: Qt MOC + protobuf forward decls trigger this
)
foreach(FLAG ${ADDITIONAL_DEBUG_FLAGS})
@@ -312,7 +320,7 @@ if(UNIX)
endif()
elseif(WIN32)
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)
else()
set(TRICE_IS_64_BIT 0)

View File

@@ -233,6 +233,7 @@ if(WIN32)
set(plugin_dest_dir Plugins)
set(qtconf_dest_dir .)
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
list(APPEND libSearchDirs "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/bin")
install(
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)"
xtoysql="${latest_migration#servatrice_}"
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_}"
if ((old_ver >= new_ver)); then

View File

@@ -11,10 +11,9 @@ add_test(NAME server_card_counter_test COMMAND server_card_counter_test)
add_test(NAME server_counter_test COMMAND server_counter_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 5)
# Find GTest
add_executable(dummy_test dummy_test.cpp)
add_executable(expression_test expression_test.cpp)
add_executable(clamped_arithmetic_test clamped_arithmetic_test.cpp)
@@ -24,6 +23,7 @@ add_executable(deck_hash_performance_test deck_hash_performance_test.cpp)
add_executable(server_card_counter_test server_card_counter_test.cpp)
add_executable(server_counter_test server_counter_test.cpp)
# Find GTest
find_package(GTest)
if(NOT GTEST_FOUND)