diff --git a/.github/ci/allocator-smoke.sh b/.github/ci/allocator-smoke.sh new file mode 100755 index 0000000000..48301280a9 --- /dev/null +++ b/.github/ci/allocator-smoke.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# Build a support-only package with scoped mimalloc, check that neither library +# exports allocator symbols, and run the installed coexistence consumers. +set -euxo pipefail + +source_dir="${1:?usage: allocator-smoke.sh }" +work_dir="${2:?usage: allocator-smoke.sh }" +build_type="${BUILD_TYPE:-Release}" +build="$work_dir/build" +install="$work_dir/install" + +rm -rf "$work_dir" +mkdir -p "$work_dir" + +cmake -S "$source_dir" -B "$build" \ + -DCMAKE_BUILD_TYPE="$build_type" \ + -DGECODE_BUILD_SHARED=ON -DGECODE_BUILD_STATIC=ON \ + -DGECODE_ENABLE_MIMALLOC=ON \ + -DGECODE_ENABLE_GCC_VISIBILITY=OFF \ + -DBUILD_TESTING=OFF -DGECODE_ENABLE_EXAMPLES=OFF \ + -DGECODE_ENABLE_SEARCH=OFF -DGECODE_ENABLE_INT_VARS=OFF \ + -DGECODE_ENABLE_SET_VARS=OFF -DGECODE_ENABLE_FLOAT_VARS=OFF \ + -DGECODE_ENABLE_MINIMODEL=OFF -DGECODE_ENABLE_DRIVER=OFF \ + -DGECODE_ENABLE_FLATZINC=OFF -DGECODE_ENABLE_QT=OFF -DGECODE_ENABLE_GIST=OFF +cmake --build "$build" --parallel 4 +cmake --install "$build" --prefix "$install" + +nm -D --defined-only "$install/lib/libgecodesupport.so" > "$work_dir/exports.txt" +if grep -E '[[:space:]](_*mi_[[:alnum:]_]+|gecode_+mi_[[:alnum:]_]+|malloc|calloc|realloc|free|aligned_alloc|posix_memalign)$' \ + "$work_dir/exports.txt"; then + echo "Allocator implementation or malloc replacement exported by gecodesupport" >&2 + exit 1 +fi +nm -g --defined-only "$install/lib/libgecodesupport.a" > "$work_dir/symbols.txt" +if grep -E '[[:space:]](_*mi_[[:alnum:]_]+|malloc|calloc|realloc|free|aligned_alloc|posix_memalign)$' \ + "$work_dir/symbols.txt"; then + echo "Unprefixed allocator symbol in static gecodesupport" >&2 + exit 1 +fi +grep -q '[[:space:]]gecode_mi_malloc$' "$work_dir/symbols.txt" + +# Unsupported allocator combinations must fail at configure time. +if cmake -S "$source_dir" -B "$work_dir/mimalloc-custom" \ + -DGECODE_ENABLE_MIMALLOC=ON -DGECODE_ENABLE_ALLOCATOR=OFF > "$work_dir/mimalloc-custom.log" 2>&1; then + exit 1 +fi +grep -q 'requires GECODE_ENABLE_ALLOCATOR=ON' "$work_dir/mimalloc-custom.log" +if cmake -S "$source_dir" -B "$work_dir/mimalloc-sanitizer" \ + -DGECODE_ENABLE_MIMALLOC=ON -DGECODE_SANITIZER=address > "$work_dir/mimalloc-sanitizer.log" 2>&1; then + exit 1 +fi +grep -q 'does not support GECODE_SANITIZER' "$work_dir/mimalloc-sanitizer.log" + +for variant in shared static; do + consumer="$work_dir/consumer-$variant" + cmake -S "$source_dir/test/package/allocator" -B "$consumer" \ + -DCMAKE_BUILD_TYPE="$build_type" \ + -DCMAKE_PREFIX_PATH="$install" \ + -DGECODE_LINK_VARIANT="$variant" -DGECODE_EXPECT_MIMALLOC=ON \ + -DGECODE_HOST_MIMALLOC_OVERRIDE=ON \ + -DMIMALLOC_SOURCE_DIR="$build/_deps/gecode_mimalloc-src" + cmake --build "$consumer" --parallel 4 + ctest --test-dir "$consumer" --output-on-failure +done +test -f "$install/share/licenses/gecode/mimalloc-LICENSE" +test ! -f "$install/include/mimalloc.h" diff --git a/.github/ci/cmake-consumer-smoke-msys2.sh b/.github/ci/cmake-consumer-smoke-msys2.sh deleted file mode 100755 index 3ae83ab693..0000000000 --- a/.github/ci/cmake-consumer-smoke-msys2.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -prefix="${1:?usage: cmake-consumer-smoke-msys2.sh }" -work_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}" -work="$work_root/gecode-consumer-msys2" - -rm -rf "$work" -mkdir -p "$work" - -cat > "$work/CMakeLists.txt" <<'EOF' -cmake_minimum_required(VERSION 3.21) -project(msys2_static_consumer LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED) -if(NOT TARGET Gecode::gecode) - message(FATAL_ERROR "Expected installed package to export Gecode::gecode") -endif() -add_executable(msys2_static_consumer main.cpp) -target_link_libraries(msys2_static_consumer PRIVATE Gecode::gecode) -EOF - -cat > "$work/main.cpp" <<'EOF' -#include -#include - -int main(void) { - Gecode::IntArgs values(1); - values[0] = 0; - return values[0]; -} -EOF - -cmake -S "$work" -B "$work/build" -G Ninja -DCMAKE_PREFIX_PATH="$prefix" -cmake --build "$work/build" diff --git a/.github/ci/cmake-consumer-smoke-vcpkg.ps1 b/.github/ci/cmake-consumer-smoke-vcpkg.ps1 deleted file mode 100644 index 8f6d9fb2d7..0000000000 --- a/.github/ci/cmake-consumer-smoke-vcpkg.ps1 +++ /dev/null @@ -1,156 +0,0 @@ -$ErrorActionPreference = "Stop" - -function Assert-NativeCommandSucceeded { - param( - [int] $ExitCode, - [string] $Description - ) - if ($ExitCode -ne 0) { - throw "$Description failed with exit code $ExitCode." - } -} - -$prefix = $args[0] -if (-not $prefix) { - throw "usage: cmake-consumer-smoke-vcpkg.ps1 " -} - -$work = Join-Path $env:RUNNER_TEMP "gecode-consumers-win-vcpkg" -$toolchain = "$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" -$manifest = Join-Path $work "manifest" -$consumerVcpkgInstalled = Join-Path $work "vcpkg_installed" -if (Test-Path $work) { Remove-Item -Recurse -Force $work } -New-Item -ItemType Directory -Force -Path ` - (Join-Path $work "a"), ` - (Join-Path $work "b"), ` - (Join-Path $work "c"), ` - (Join-Path $work "d"), ` - $manifest | Out-Null - -$baseline = (Get-Content "$env:GITHUB_WORKSPACE\vcpkg.json" | ConvertFrom-Json).'builtin-baseline' -@" -{ - "name": "gecode-consumer-smoke", - "version-string": "0", - "builtin-baseline": "$baseline", - "dependencies": [ - "mpfr" - ] -} -"@ | Set-Content -Encoding utf8 (Join-Path $manifest "vcpkg.json") - -@' -cmake_minimum_required(VERSION 3.21) -project(consumer_a LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED) -message(STATUS "Gecode_VERSION=${Gecode_VERSION}") -add_executable(consumer_a main.cpp) -target_link_libraries(consumer_a PRIVATE Gecode::gecode) -'@ | Set-Content -Encoding utf8 (Join-Path $work "a\CMakeLists.txt") -@' -#include -int main(void) { return 0; } -'@ | Set-Content -Encoding utf8 (Join-Path $work "a\main.cpp") - -@' -cmake_minimum_required(VERSION 3.21) -project(consumer_b LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED COMPONENTS driver) -add_executable(consumer_b main.cpp) -target_link_libraries(consumer_b PRIVATE Gecode::gecodedriver) -'@ | Set-Content -Encoding utf8 (Join-Path $work "b\CMakeLists.txt") -@' -#include -int main(void) { - Gecode::Options options("consumer_b"); - return options.model(); -} -'@ | Set-Content -Encoding utf8 (Join-Path $work "b\main.cpp") - -@' -cmake_minimum_required(VERSION 3.21) -project(consumer_c LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED COMPONENTS gecodedriver) -if(NOT TARGET Gecode::gecodedriver OR - NOT Gecode_LIBRARIES STREQUAL "Gecode::gecodedriver") - message(FATAL_ERROR "Expected canonical library for legacy component, got: ${Gecode_LIBRARIES}") -endif() -'@ | Set-Content -Encoding utf8 (Join-Path $work "c\CMakeLists.txt") - -@' -cmake_minimum_required(VERSION 3.21) -project(consumer_d LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED COMPONENTS float) -if(NOT TARGET MPFR::MPFR) - message(FATAL_ERROR "Expected Gecode package to provide MPFR::MPFR") -endif() -if(TARGET Gecode::gecodefloat_shared) - get_target_property(gecodefloat_links Gecode::gecodefloat_shared INTERFACE_LINK_LIBRARIES) -elseif(TARGET Gecode::gecodefloat_static) - get_target_property(gecodefloat_links Gecode::gecodefloat_static INTERFACE_LINK_LIBRARIES) -else() - message(FATAL_ERROR "Expected an exported gecodefloat library target") -endif() -if(NOT gecodefloat_links MATCHES "MPFR::MPFR") - message(FATAL_ERROR "Expected gecodefloat to link MPFR::MPFR, got: ${gecodefloat_links}") -endif() -add_executable(consumer_d main.cpp) -target_link_libraries(consumer_d PRIVATE Gecode::gecodefloat) -'@ | Set-Content -Encoding utf8 (Join-Path $work "d\CMakeLists.txt") -@' -#include -#ifndef GECODE_HAS_MPFR -#error "Expected installed Gecode package to enable MPFR" -#endif -#include -int main(void) { - Gecode::Float::Rounding rounding; - return rounding.exp_down(1.0) > 0.0 ? 0 : 1; -} -'@ | Set-Content -Encoding utf8 (Join-Path $work "d\main.cpp") - -cmake -S (Join-Path $work "a") -B (Join-Path $work "a\build") -G "Visual Studio 17 2022" -A x64 ` - "-DCMAKE_TOOLCHAIN_FILE=$toolchain" ` - "-DVCPKG_MANIFEST_MODE=ON" ` - "-DVCPKG_MANIFEST_DIR=$manifest" ` - "-DVCPKG_INSTALLED_DIR=$consumerVcpkgInstalled" ` - "-DVCPKG_TARGET_TRIPLET=x64-windows" ` - "-DCMAKE_PREFIX_PATH=$prefix" 2>&1 | Tee-Object -FilePath (Join-Path $work "a\configure.log") -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_a configure" -cmake --build (Join-Path $work "a\build") --config $env:BUILD_TYPE -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_a build" - -cmake -S (Join-Path $work "b") -B (Join-Path $work "b\build") -G "Visual Studio 17 2022" -A x64 ` - "-DCMAKE_TOOLCHAIN_FILE=$toolchain" ` - "-DVCPKG_MANIFEST_MODE=ON" ` - "-DVCPKG_MANIFEST_DIR=$manifest" ` - "-DVCPKG_INSTALLED_DIR=$consumerVcpkgInstalled" ` - "-DVCPKG_TARGET_TRIPLET=x64-windows" ` - "-DCMAKE_PREFIX_PATH=$prefix" -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_b configure" -cmake --build (Join-Path $work "b\build") --config $env:BUILD_TYPE -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_b build" - -cmake -S (Join-Path $work "c") -B (Join-Path $work "c\build") -G "Visual Studio 17 2022" -A x64 ` - "-DCMAKE_TOOLCHAIN_FILE=$toolchain" ` - "-DVCPKG_MANIFEST_MODE=ON" ` - "-DVCPKG_MANIFEST_DIR=$manifest" ` - "-DVCPKG_INSTALLED_DIR=$consumerVcpkgInstalled" ` - "-DVCPKG_TARGET_TRIPLET=x64-windows" ` - "-DCMAKE_PREFIX_PATH=$prefix" -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_c configure" - -cmake -S (Join-Path $work "d") -B (Join-Path $work "d\build") -G "Visual Studio 17 2022" -A x64 ` - "-DCMAKE_TOOLCHAIN_FILE=$toolchain" ` - "-DVCPKG_MANIFEST_MODE=ON" ` - "-DVCPKG_MANIFEST_DIR=$manifest" ` - "-DVCPKG_INSTALLED_DIR=$consumerVcpkgInstalled" ` - "-DVCPKG_TARGET_TRIPLET=x64-windows" ` - "-DCMAKE_PREFIX_PATH=$prefix" -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_d configure" -cmake --build (Join-Path $work "d\build") --config $env:BUILD_TYPE -Assert-NativeCommandSucceeded $LASTEXITCODE "consumer_d build" - -if (-not (Select-String -Path (Join-Path $work "a\configure.log") -Pattern "Gecode_VERSION=" -Quiet)) { - throw "Gecode_VERSION was not reported during consumer configure." -} diff --git a/.github/ci/cmake-consumer-smoke.sh b/.github/ci/cmake-consumer-smoke.sh index 673c80a379..9335f28edd 100644 --- a/.github/ci/cmake-consumer-smoke.sh +++ b/.github/ci/cmake-consumer-smoke.sh @@ -333,14 +333,12 @@ cmake -S "$work/c" -B "$work/c/build" -DCMAKE_PREFIX_PATH="$prefix" cmake -S "$work/f" -B "$work/f/build" \ -DCMAKE_PREFIX_PATH="$prefix" \ -DCMAKE_DISABLE_FIND_PACKAGE_MPFR=TRUE \ - -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=TRUE \ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=TRUE cmake --build "$work/f/build" -j4 cmake -S "$work/g" -B "$work/g/build" \ -DCMAKE_PREFIX_PATH="$prefix" \ -DCMAKE_DISABLE_FIND_PACKAGE_MPFR=TRUE \ - -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=TRUE \ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=TRUE if cmake -S "$work/h" -B "$work/h/build" -DCMAKE_PREFIX_PATH="$prefix"; then @@ -370,7 +368,6 @@ targets_file="$(find "$prefix" -name GecodeTargets.cmake -print -quit)" if grep -q 'add_library(Gecode::gecodegist ' "$targets_file"; then if cmake -S "$work/j" -B "$work/j/no-qt-build" \ -DCMAKE_PREFIX_PATH="$prefix" \ - -DCMAKE_DISABLE_FIND_PACKAGE_Qt5=TRUE \ -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=TRUE; then echo "Gist component unexpectedly succeeded without Qt" >&2 exit 1 diff --git a/.github/ci/qt-minimum-version-checks.sh b/.github/ci/qt-minimum-version-checks.sh deleted file mode 100644 index deb557c2d9..0000000000 --- a/.github/ci/qt-minimum-version-checks.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -fake_qt="$RUNNER_TEMP/fake-qt5-old" -fake_qt_config="$fake_qt/lib/cmake/Qt5" -mkdir -p "$fake_qt_config" -cat > "$fake_qt_config/Qt5Config.cmake" <<'EOF' -set(QT_VERSION "5.12.0") -set(QT_VERSION_MAJOR 5) -set(Qt5Core_VERSION "5.12.0") -set(Qt5_FOUND TRUE) -set(Qt5Core_FOUND TRUE) -if(NOT TARGET Qt5::Core) - add_library(Qt5::Core INTERFACE IMPORTED) -endif() -EOF - -cmake -S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP/gecode-old-qt-default" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DCMAKE_PREFIX_PATH="$fake_qt" \ - -DGECODE_ENABLE_GIST=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF \ - -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_MPFR=OFF -cmake -S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP/gecode-old-qt-default" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DCMAKE_PREFIX_PATH="$fake_qt" \ - -DGECODE_ENABLE_GIST=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF \ - -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_MPFR=OFF -grep -q '^GECODE_ENABLE_QT:STRING=AUTO' "$RUNNER_TEMP/gecode-old-qt-default/CMakeCache.txt" -grep -Fq '/* #undef GECODE_HAS_QT */' "$RUNNER_TEMP/gecode-old-qt-default/gecode/support/config.hpp" - -if cmake -S "$GITHUB_WORKSPACE" -B "$RUNNER_TEMP/gecode-old-qt-explicit" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DCMAKE_PREFIX_PATH="$fake_qt" \ - -DGECODE_ENABLE_QT=ON \ - -DGECODE_ENABLE_GIST=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF \ - -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_MPFR=OFF; then - echo "Expected explicit GECODE_ENABLE_QT=ON with old Qt to fail" >&2 - exit 1 -fi diff --git a/.github/ci/qt5-gist-consumer-smoke.sh b/.github/ci/qt5-gist-consumer-smoke.sh deleted file mode 100644 index 9978dc9c60..0000000000 --- a/.github/ci/qt5-gist-consumer-smoke.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -prefix="${1:?usage: qt5-gist-consumer-smoke.sh }" -work="$RUNNER_TEMP/gecode-qt5-gist-consumer" -rm -rf "$work" -mkdir -p "$work" - -cat > "$work/CMakeLists.txt" <<'EOF' -cmake_minimum_required(VERSION 3.21) -project(qt5_gist_consumer LANGUAGES CXX) -find_package(Gecode CONFIG REQUIRED COMPONENTS gist) -add_executable(qt5_gist_consumer main.cpp) -target_link_libraries(qt5_gist_consumer PRIVATE Gecode::gecodegist) - -function(expect_interface_dependency target expected) - get_target_property(links "${target}" INTERFACE_LINK_LIBRARIES) - if(NOT links) - set(links "") - endif() - set(found FALSE) - foreach(link IN LISTS links) - if(link STREQUAL "${expected}" OR link STREQUAL "$") - set(found TRUE) - endif() - endforeach() - if(NOT found) - message(FATAL_ERROR "Expected ${target} to link ${expected}, got: ${links}") - endif() -endfunction() - -function(expect_gist_variant_dependencies kind qt_widgets_target) - set(gist_target "Gecode::gecodegist_${kind}") - if(NOT TARGET "${gist_target}") - return() - endif() - expect_interface_dependency("${gist_target}" "${qt_widgets_target}") - expect_interface_dependency("${gist_target}" "Gecode::gecodesearch_${kind}") - expect_interface_dependency("${gist_target}" "Gecode::gecodeint_${kind}") - if(TARGET "Gecode::gecodeset_${kind}") - expect_interface_dependency("${gist_target}" "Gecode::gecodeset_${kind}") - endif() - if(TARGET "Gecode::gecodefloat_${kind}") - expect_interface_dependency("${gist_target}" "Gecode::gecodefloat_${kind}") - endif() -endfunction() - -expect_gist_variant_dependencies(shared Qt5::Widgets) -expect_gist_variant_dependencies(static Qt5::Widgets) -EOF -cat > "$work/main.cpp" <<'EOF' -#include -#include - -#ifdef GECODE_HAS_SET_VARS -using SetCompare = std::string (*)(std::string, Gecode::SetVar, Gecode::SetVar); -SetCompare set_compare = &Gecode::Gist::Comparator::compare; -#endif - -#ifdef GECODE_HAS_FLOAT_VARS -using FloatCompare = std::string (*)(std::string, Gecode::FloatVar, Gecode::FloatVar); -FloatCompare float_compare = &Gecode::Gist::Comparator::compare; -#endif - -int main(void) { -#ifdef GECODE_HAS_SET_VARS - if (set_compare == nullptr) - return 1; -#endif -#ifdef GECODE_HAS_FLOAT_VARS - if (float_compare == nullptr) - return 1; -#endif - return 0; -} -EOF - -cmake -S "$work" -B "$work/build" -DCMAKE_PREFIX_PATH="$prefix" -cmake --build "$work/build" -j4 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b78f1d119..0f2a6559ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,39 +10,18 @@ on: permissions: contents: read +# A new push to a pull request supersedes its running checks. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: - tidy: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 - with: - enable-cache: false - - - name: Install clang-format 22 - shell: bash - run: | - curl --fail --location --retry 3 https://apt.llvm.org/llvm-snapshot.gpg.key -o "$RUNNER_TEMP/llvm.asc" - sudo install -m 644 "$RUNNER_TEMP/llvm.asc" /usr/share/keyrings/llvm.asc - echo 'deb [signed-by=/usr/share/keyrings/llvm.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main' | sudo tee /etc/apt/sources.list.d/llvm.list - sudo apt-get update - sudo apt-get install -y clang-format-22 - - - name: Formatting check - shell: bash - run: uv run misc/check.py format-check - - - name: Tidy checks - shell: bash - run: uv run misc/tidy.py --check - + # Formatting, changelog, generated sources, Clang build, clang-tidy, the + # full test suite with audit and fault injection, packages, and docs. check-extended: runs-on: ubuntu-24.04 @@ -60,6 +39,8 @@ jobs: curl --fail --location --retry 3 https://apt.llvm.org/llvm-snapshot.gpg.key -o "$RUNNER_TEMP/llvm.asc" sudo install -m 644 "$RUNNER_TEMP/llvm.asc" /usr/share/keyrings/llvm.asc echo 'deb [signed-by=/usr/share/keyrings/llvm.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main' | sudo tee /etc/apt/sources.list.d/llvm.list + # The runner's packages.microsoft.com source has failed apt-get update with 403; no job needs it. + sudo find /etc/apt/sources.list.d -type f -exec grep -q packages.microsoft.com {} \; -delete sudo apt-get update sudo apt-get install -y clang-22 clang-format-22 clang-tidy-22 clang-tools-22 \ ninja-build bison flex graphviz libgmp-dev libmpfr-dev \ @@ -69,7 +50,9 @@ jobs: shell: bash run: | archive="$RUNNER_TEMP/doxygen-1.18.0.linux.bin.tar.gz" - curl --fail --location --retry 3 https://www.doxygen.nl/files/doxygen-1.18.0.linux.bin.tar.gz -o "$archive" + # doxygen.nl has served runners a small HTML page instead of the archive. + curl --fail --location --retry 3 -o "$archive" \ + https://github.com/doxygen/doxygen/releases/download/Release_1_18_0/doxygen-1.18.0.linux.bin.tar.gz printf '%s %s\n' 14fa81bdc34171edb5f1f02b1d60e74802f0439b77fa44e592565d517d72df90 "$archive" | sha256sum --check mkdir -p "$RUNNER_TEMP/doxygen" tar -xzf "$archive" -C "$RUNNER_TEMP/doxygen" --strip-components=1 @@ -93,135 +76,19 @@ jobs: shell: bash run: uv run misc/check.py all --build-dir build/check-extended --jobs 4 - build-cmake-unix: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: macos-15 - regenerate_varimp: OFF - - os: ubuntu-24.04 - regenerate_varimp: ON - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 - with: - enable-cache: false - - - name: Install clang-format 22 - if: runner.os == 'Linux' - shell: bash - run: | - curl --fail --location --retry 3 https://apt.llvm.org/llvm-snapshot.gpg.key -o "$RUNNER_TEMP/llvm.asc" - sudo install -m 644 "$RUNNER_TEMP/llvm.asc" /usr/share/keyrings/llvm.asc - echo 'deb [signed-by=/usr/share/keyrings/llvm.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-22 main' | sudo tee /etc/apt/sources.list.d/llvm.list - sudo apt-get update - sudo apt-get install -y clang-format-22 - - - name: Install Ubuntu build deps - if: runner.os == 'Linux' - shell: bash - run: | - sudo apt-get update - sudo apt-get install -y flex bison libgmp-dev libmpfr-dev - - - name: Check generated source freshness - # Ubuntu LTS keeps Bison 3.8.2 and Flex 2.6.4, while Homebrew moves on. - if: runner.os == 'Linux' - shell: bash - run: bash .github/ci/generated-source-freshness.sh - - - name: Create Build Environment - run: cmake -E make_directory ${{github.workspace}}/build - - - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}}/build - run: | - set -euxo pipefail - cmake_args=( - "$GITHUB_WORKSPACE" - "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" - "-DGECODE_REGENERATE_VARIMP=${{ matrix.regenerate_varimp }}" - ) - if [ "${{ matrix.os }}" = "ubuntu-24.04" ]; then - # Keep this path absolute to validate package config handling for absolute install dirs. - cmake_args+=( - "-DCMAKE_INSTALL_INCLUDEDIR=/tmp/gecode-install-abs-include" - "-DGECODE_ENABLE_FAULT_INJECTION=ON" - ) - fi - cmake "${cmake_args[@]}" - - - name: Build - working-directory: ${{github.workspace}}/build - shell: bash - run: cmake --build . --config $BUILD_TYPE - - - name: Check - working-directory: ${{github.workspace}}/build - shell: bash - run: | - set -euxo pipefail - cmake --build . --config $BUILD_TYPE --target check - - - name: Run public test harness smokes - if: matrix.os == 'ubuntu-24.04' - working-directory: ${{github.workspace}}/build - shell: bash - run: ctest --build-config "$BUILD_TYPE" --output-on-failure -R '^public-.*-smoke$' - - - name: Install CMake package - working-directory: ${{github.workspace}}/build - shell: bash - run: cmake --install . --config $BUILD_TYPE --prefix "$GITHUB_WORKSPACE/install" - - - name: Consumer smoke tests - shell: bash - run: | - set -euxo pipefail - if [ "${{ matrix.os }}" = "ubuntu-24.04" ]; then - bash .github/ci/cmake-consumer-smoke.sh \ - "$GITHUB_WORKSPACE/install" \ - "/tmp/gecode-install-abs-include" \ - mpfr - else - bash .github/ci/cmake-consumer-smoke.sh \ - "$GITHUB_WORKSPACE/install" \ - "$GITHUB_WORKSPACE/install/include" \ - core - fi - - - name: Package version checks - shell: bash - run: bash .github/ci/cmake-package-version-checks.sh "$GITHUB_WORKSPACE/install" - - - name: Disabled module closure checks - if: matrix.os == 'ubuntu-24.04' - shell: bash - run: bash .github/ci/cmake-closure-checks.sh - - - name: CMake custom VIS checks - if: matrix.os == 'ubuntu-24.04' - shell: bash - run: bash .github/ci/cmake-custom-vis-smoke.sh - - - name: Gist static macro compatibility - if: matrix.os == 'ubuntu-24.04' - shell: bash - run: bash .github/ci/gist-static-macro-smoke.sh - - - name: Qt minimum version checks - if: matrix.os == 'ubuntu-24.04' + - name: Qt/Gist consumer smoke test shell: bash - run: bash .github/ci/qt-minimum-version-checks.sh + env: + CXX: clang++-22 + run: bash .github/ci/qt-gist-consumer-smoke.sh "$GITHUB_WORKSPACE/build/check-extended/check-install" - build-cmake-unix-ninja: - runs-on: ubuntu-latest + # GCC Release build without experimental APIs, plus the installed-package, + # FlatZinc, allocator, and 32-bit smokes. + build-linux: + runs-on: ubuntu-24.04 + env: + CC: gcc-14 + CXX: g++-14 steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 @@ -234,8 +101,10 @@ jobs: - name: Install build deps shell: bash run: | + # The runner's packages.microsoft.com source has failed apt-get update with 403; no job needs it. + sudo find /etc/apt/sources.list.d -type f -exec grep -q packages.microsoft.com {} \; -delete sudo apt-get update - sudo apt-get install -y libgmp-dev libmpfr-dev ninja-build + sudo apt-get install -y g++-14 g++-14-multilib libgmp-dev libmpfr-dev ninja-build - name: Install MiniZinc 2.10.1 shell: bash @@ -250,260 +119,76 @@ jobs: echo "$minizinc_dir/bin" >> "$GITHUB_PATH" "$minizinc_dir/bin/minizinc" --version - - name: Configure CMake with Ninja + - name: Configure CMake shell: bash + # The absolute include dir checks package config handling for absolute install dirs. run: > - cmake -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build-ninja" - -DGECODE_ENABLE_EXPERIMENTAL=ON - -G Ninja - -DCMAKE_BUILD_TYPE=$BUILD_TYPE - -DGECODE_ENABLE_QT=OFF - -DGECODE_ENABLE_GIST=OFF - -DGECODE_ENABLE_MPFR=OFF + cmake -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build" + "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" + -DGECODE_REGENERATE_VARIMP=ON + -DCMAKE_INSTALL_INCLUDEDIR=/tmp/gecode-install-abs-include - name: Build shell: bash - run: cmake --build "$GITHUB_WORKSPACE/build-ninja" - - - name: Example feature selection - shell: bash - run: bash .github/ci/cmake-example-feature-smoke.sh - - - name: Examples reading instance files - shell: bash - run: bash .github/ci/instance-example-smoke.sh "$GITHUB_WORKSPACE/build-ninja/bin" + run: cmake --build "$GITHUB_WORKSPACE/build" --parallel 4 - name: Check shell: bash - run: > - ctest --test-dir "$GITHUB_WORKSPACE/build-ninja" - --output-on-failure -R '^(build-gecode-test|test)$' - - - name: Configure CMake Debug audit smoke - shell: bash - run: > - cmake -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build-ninja-debug" - -G Ninja - -DCMAKE_BUILD_TYPE=Debug - -DGECODE_ENABLE_AUDIT=ON - -DGECODE_ENABLE_QT=OFF - -DGECODE_ENABLE_GIST=OFF - -DGECODE_ENABLE_MPFR=OFF - -DGECODE_ENABLE_EXAMPLES=OFF - -DGECODE_ENABLE_FLATZINC=OFF - - - name: Build Debug audit smoke - shell: bash - run: cmake --build "$GITHUB_WORKSPACE/build-ninja-debug" + run: cmake --build "$GITHUB_WORKSPACE/build" --target check - - name: Install and smoke test FlatZinc tools + - name: Run public test harness smokes shell: bash - run: | - set -euxo pipefail - cmake --install "$GITHUB_WORKSPACE/build-ninja" --prefix "$GITHUB_WORKSPACE/install-ninja" - bash .github/ci/flatzinc-tools-smoke.sh "$GITHUB_WORKSPACE/install-ninja" - - build-cmake-allocator: - runs-on: ubuntu-latest - strategy: - matrix: - variant: [static, both] + run: ctest --test-dir "$GITHUB_WORKSPACE/build" --output-on-failure -R '^public-.*-smoke$' - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Build and install allocator package - shell: bash - run: | - set -euxo pipefail - cmake -S . -B build-allocator \ - -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ - -DGECODE_BUILD_SHARED=${{ matrix.variant == 'both' }} \ - -DGECODE_BUILD_STATIC=ON \ - -DGECODE_ENABLE_MIMALLOC=ON \ - -DGECODE_ENABLE_GCC_VISIBILITY=OFF \ - -DBUILD_TESTING=OFF -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_SEARCH=OFF -DGECODE_ENABLE_INT_VARS=OFF \ - -DGECODE_ENABLE_SET_VARS=OFF -DGECODE_ENABLE_FLOAT_VARS=OFF \ - -DGECODE_ENABLE_MINIMODEL=OFF -DGECODE_ENABLE_DRIVER=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF -DGECODE_ENABLE_QT=OFF -DGECODE_ENABLE_GIST=OFF - cmake --build build-allocator --config "$BUILD_TYPE" --parallel 2 - cmake --install build-allocator --config "$BUILD_TYPE" --prefix "$GITHUB_WORKSPACE/install-allocator" - - - name: Check private allocator exports - shell: bash - run: | - set -euxo pipefail - if test -f install-allocator/lib/libgecodesupport.so; then - nm -D --defined-only install-allocator/lib/libgecodesupport.so > build-allocator/exports.txt - if grep -E '[[:space:]](_*mi_[[:alnum:]_]+|gecode_+mi_[[:alnum:]_]+|malloc|calloc|realloc|free|aligned_alloc|posix_memalign)$' build-allocator/exports.txt; then - echo "Allocator implementation or malloc replacement exported by gecodesupport" - exit 1 - fi - fi - if test -f install-allocator/lib/libgecodesupport.a; then - nm -g --defined-only install-allocator/lib/libgecodesupport.a > build-allocator/symbols.txt - if grep -E '[[:space:]](_*mi_[[:alnum:]_]+|malloc|calloc|realloc|free|aligned_alloc|posix_memalign)$' build-allocator/symbols.txt; then - echo "Unprefixed allocator symbol in static gecodesupport" - exit 1 - fi - grep -q '[[:space:]]gecode_mi_malloc$' build-allocator/symbols.txt - fi - - - name: Reject unsupported allocator combinations - shell: bash - run: | - set -euxo pipefail - if cmake -S . -B "$RUNNER_TEMP/mimalloc-custom" \ - -DGECODE_ENABLE_MIMALLOC=ON -DGECODE_ENABLE_ALLOCATOR=OFF > "$RUNNER_TEMP/mimalloc-custom.log" 2>&1; then - exit 1 - fi - grep -q 'requires GECODE_ENABLE_ALLOCATOR=ON' "$RUNNER_TEMP/mimalloc-custom.log" - if cmake -S . -B "$RUNNER_TEMP/mimalloc-sanitizer" \ - -DGECODE_ENABLE_MIMALLOC=ON -DGECODE_SANITIZER=address > "$RUNNER_TEMP/mimalloc-sanitizer.log" 2>&1; then - exit 1 - fi - grep -q 'does not support GECODE_SANITIZER' "$RUNNER_TEMP/mimalloc-sanitizer.log" - - - name: Installed allocator coexistence and thread transfer + - name: Examples reading instance files shell: bash - run: | - set -euxo pipefail - for variant in shared static; do - if test "$variant" = "shared" && ! test -f install-allocator/lib/libgecodesupport.so; then continue; fi - if test "$variant" = "static" && ! test -f install-allocator/lib/libgecodesupport.a; then continue; fi - cmake -S test/package/allocator -B "build-allocator-consumer-$variant" \ - -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ - -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/install-allocator" \ - -DGECODE_LINK_VARIANT="$variant" -DGECODE_EXPECT_MIMALLOC=ON \ - -DGECODE_HOST_MIMALLOC_OVERRIDE=ON \ - -DMIMALLOC_SOURCE_DIR="$GITHUB_WORKSPACE/build-allocator/_deps/gecode_mimalloc-src" - cmake --build "build-allocator-consumer-$variant" --config "$BUILD_TYPE" --parallel 2 - ctest --test-dir "build-allocator-consumer-$variant" --build-config "$BUILD_TYPE" --output-on-failure - done - test -f install-allocator/share/licenses/gecode/mimalloc-LICENSE - test ! -f install-allocator/include/mimalloc.h - - build-32-bit-linkage: - # g++-multilib had no installation candidate on ubuntu-latest (Ubuntu - # 26.04) in November 2026, so this job stays on Ubuntu 24.04 and GCC 14. - runs-on: ubuntu-24.04 - env: - CC: gcc-14 - CXX: g++-14 - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 + run: bash .github/ci/instance-example-smoke.sh "$GITHUB_WORKSPACE/build/bin" - - name: Install 32-bit toolchain + - name: Install CMake package shell: bash - run: | - sudo apt-get update - sudo apt-get install -y g++-14-multilib + run: cmake --install "$GITHUB_WORKSPACE/build" --prefix "$GITHUB_WORKSPACE/install" - - name: Build and link 32-bit stop consumer + - name: Consumer smoke tests shell: bash - run: bash .github/ci/32-bit-linkage-smoke.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP/gecode-32-bit-linkage" - - build-cmake-qt-gist: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 - with: - enable-cache: false + run: > + bash .github/ci/cmake-consumer-smoke.sh + "$GITHUB_WORKSPACE/install" /tmp/gecode-install-abs-include mpfr - - name: Install Qt build deps + - name: Package version checks shell: bash - run: | - sudo apt-get update - sudo apt-get install -y qt6-base-dev qt6-base-dev-tools libgl1-mesa-dev + run: bash .github/ci/cmake-package-version-checks.sh "$GITHUB_WORKSPACE/install" - - name: Configure CMake with Qt/Gist + - name: FlatZinc tools smoke test shell: bash - run: > - cmake -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build-qt-gist" - -DCMAKE_BUILD_TYPE=$BUILD_TYPE - -DGECODE_ENABLE_QT=ON - -DGECODE_ENABLE_GIST=ON - -DGECODE_ENABLE_MPFR=OFF - -DGECODE_ENABLE_EXAMPLES=OFF - -DGECODE_ENABLE_FLATZINC=ON + run: bash .github/ci/flatzinc-tools-smoke.sh "$GITHUB_WORKSPACE/install" - - name: Build and install Qt/Gist package + - name: Example feature selection shell: bash - run: | - set -euxo pipefail - cmake --build "$GITHUB_WORKSPACE/build-qt-gist" --config $BUILD_TYPE -j4 - cmake --install "$GITHUB_WORKSPACE/build-qt-gist" --config $BUILD_TYPE --prefix "$GITHUB_WORKSPACE/install-qt-gist" + run: bash .github/ci/cmake-example-feature-smoke.sh - - name: Qt/Gist consumer smoke test + - name: Disabled module closure checks shell: bash - run: bash .github/ci/qt-gist-consumer-smoke.sh "$GITHUB_WORKSPACE/install-qt-gist" - - build-cmake-qt5-gist-smoke: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 - with: - enable-cache: false + run: bash .github/ci/cmake-closure-checks.sh - - name: Install Qt 5 build deps + - name: CMake custom VIS checks shell: bash - run: | - sudo apt-get update - sudo apt-get install -y qtbase5-dev qtbase5-dev-tools libgl1-mesa-dev + run: bash .github/ci/cmake-custom-vis-smoke.sh - - name: Configure CMake with Qt 5/Gist + - name: Gist static macro compatibility shell: bash - run: | - set -euxo pipefail - - qt5_config="$(dpkg-query -L qtbase5-dev | grep '/Qt5Config.cmake$')" - qt5_dir="${qt5_config%/*}" - - cmake -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build-qt5-gist" \ - -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ - -DQt5_DIR="$qt5_dir" \ - -DGECODE_ENABLE_QT=ON \ - -DGECODE_ENABLE_GIST=ON \ - -DGECODE_ENABLE_MPFR=OFF \ - -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF - - grep -Eq '^Qt5_DIR:[^=]*=.*/Qt5$' "$GITHUB_WORKSPACE/build-qt5-gist/CMakeCache.txt" - grep -q '^Qt5Core_DIR:PATH=' "$GITHUB_WORKSPACE/build-qt5-gist/CMakeCache.txt" + run: bash .github/ci/gist-static-macro-smoke.sh - - name: Build and install Qt 5/Gist package + - name: Scoped mimalloc allocator shell: bash - run: | - set -euxo pipefail - cmake --build "$GITHUB_WORKSPACE/build-qt5-gist" --config $BUILD_TYPE -j4 - cmake --install "$GITHUB_WORKSPACE/build-qt5-gist" --config $BUILD_TYPE --prefix "$GITHUB_WORKSPACE/install-qt5-gist" + run: bash .github/ci/allocator-smoke.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP/gecode-allocator" - - name: Qt 5/Gist consumer smoke test + - name: 32-bit linkage shell: bash - run: bash .github/ci/qt5-gist-consumer-smoke.sh "$GITHUB_WORKSPACE/install-qt5-gist" + run: bash .github/ci/32-bit-linkage-smoke.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP/gecode-32-bit-linkage" - build-cmake-windows: + # MSVC shared build: catches MSVC-only compile errors and missing DLL exports. + build-windows: runs-on: windows-2022 - strategy: - fail-fast: false - matrix: - include: - - name: shared - build_shared: ON - build_static: OFF - - name: static - build_shared: OFF - build_static: ON steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 @@ -513,11 +198,6 @@ jobs: with: enable-cache: false - - name: Create Build Environment - shell: pwsh - run: cmake -E make_directory "${{ github.workspace }}\\build" - - # Experimental APIs follow build_shared, so both settings are built - name: Configure CMake shell: pwsh run: > @@ -526,9 +206,7 @@ jobs: -DGECODE_ENABLE_QT=OFF -DGECODE_ENABLE_GIST=OFF -DGECODE_ENABLE_MPFR=OFF - -DGECODE_BUILD_SHARED=${{ matrix.build_shared }} - -DGECODE_BUILD_STATIC=${{ matrix.build_static }} - -DGECODE_ENABLE_EXPERIMENTAL=${{ matrix.build_shared }} + -DGECODE_ENABLE_EXPERIMENTAL=ON - name: Build shell: pwsh @@ -561,98 +239,3 @@ jobs: if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $env:PATH = "$prefix\bin;$env:PATH" ctest --test-dir $build -C $env:BUILD_TYPE --output-on-failure - - build-cmake-windows-vcpkg: - runs-on: windows-2022 - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 - with: - enable-cache: false - - - name: Cache vcpkg binary packages - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 - with: - path: ${{ runner.temp }}\vcpkg-binary-cache - key: vcpkg-${{ runner.os }}-x64-windows-37bb045f3c7a747d3e5d1c13b6fe6a0aec4b5d00-${{ hashFiles('vcpkg.json') }} - restore-keys: | - vcpkg-${{ runner.os }}-x64-windows-37bb045f3c7a747d3e5d1c13b6fe6a0aec4b5d00- - - - name: Setup vcpkg - shell: pwsh - run: | - $vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg" - $vcpkgBinaryCache = Join-Path $env:RUNNER_TEMP "vcpkg-binary-cache" - New-Item -ItemType Directory -Force -Path $vcpkgBinaryCache | Out-Null - git clone https://github.com/microsoft/vcpkg $vcpkgRoot - git -C $vcpkgRoot checkout 37bb045f3c7a747d3e5d1c13b6fe6a0aec4b5d00 - & (Join-Path $vcpkgRoot "bootstrap-vcpkg.bat") -disableMetrics - "VCPKG_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - "VCPKG_DEFAULT_BINARY_CACHE=$vcpkgBinaryCache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - - name: Configure CMake (preset) - shell: pwsh - run: cmake --preset vs2022-vcpkg - - - name: Build - shell: pwsh - run: cmake --build --preset vs2022-vcpkg-release - - - name: Check - shell: pwsh - run: cmake --build --preset vs2022-vcpkg-check - - - name: Install CMake package - shell: pwsh - run: cmake --install "${{ github.workspace }}\\build\\vs2022-vcpkg" --config ${{ env.BUILD_TYPE }} --prefix "${{ github.workspace }}\\install-vcpkg" - - - name: Consumer smoke tests - shell: pwsh - run: .\.github\ci\cmake-consumer-smoke-vcpkg.ps1 "${{ github.workspace }}\install-vcpkg" - - build-cmake-windows-msys2: - runs-on: windows-2022 - - steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - - - name: Setup MSYS2 - uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c - with: - msystem: UCRT64 - update: true - install: >- - mingw-w64-ucrt-x86_64-cmake - mingw-w64-ucrt-x86_64-gcc - mingw-w64-ucrt-x86_64-ninja - - - name: Configure CMake - shell: msys2 {0} - run: | - workspace=$(cygpath -u "$GITHUB_WORKSPACE") - cmake -S "$workspace" -B "$workspace/build-msys2" -G Ninja \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DGECODE_ENABLE_QT=OFF \ - -DGECODE_ENABLE_GIST=OFF \ - -DGECODE_ENABLE_MPFR=OFF \ - -DGECODE_BUILD_SHARED=OFF \ - -DGECODE_BUILD_STATIC=ON \ - -DGECODE_ENABLE_EXPERIMENTAL=ON \ - -DGECODE_ENABLE_EXAMPLES=OFF \ - -DGECODE_ENABLE_FLATZINC=OFF - - - name: Build and install static package - shell: msys2 {0} - run: | - workspace=$(cygpath -u "$GITHUB_WORKSPACE") - cmake --build "$workspace/build-msys2" - cmake --install "$workspace/build-msys2" --prefix "$workspace/install-msys2" - - - name: Static package consumer smoke - shell: msys2 {0} - run: | - workspace=$(cygpath -u "$GITHUB_WORKSPACE") - bash "$workspace/.github/ci/cmake-consumer-smoke-msys2.sh" "$workspace/install-msys2" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f023b91ce..2965606675 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,8 +335,6 @@ int main() { unset(_gecode_atomic_probe_source) endif() -set(GECODE_QT_MIN_VERSION "5.15") - if(GECODE_REGENERATE_VARIMP) find_program(GECODE_UV_EXECUTABLE NAMES uv) if(NOT GECODE_UV_EXECUTABLE) @@ -480,99 +478,22 @@ endif() set(GECODE_HAS_QT_RUNTIME FALSE) set(GECODE_HAS_QT_WIDGETS FALSE) -set(GECODE_QT_MAJOR) set(GECODE_QT_CORE) set(GECODE_QT_WIDGETS) set(GECODE_QT_VERSION) if(GECODE_WANT_QT) - set(_gecode_qt_runtime_candidate_major) - set(_gecode_qt_runtime_candidate_version) - set(_gecode_qt_widgets_candidate_major) - set(_gecode_qt_widgets_candidate_version) - set(_gecode_qt_old_version) - - foreach(_gecode_qt_major 6 5) - find_package(Qt${_gecode_qt_major} QUIET COMPONENTS Core - OPTIONAL_COMPONENTS Gui Widgets PrintSupport) - if(NOT TARGET Qt${_gecode_qt_major}::Core) - continue() - endif() - - if(_gecode_qt_major EQUAL 6) - set(_gecode_qt_version "${Qt6Core_VERSION}") - else() - set(_gecode_qt_version "${Qt5Core_VERSION}") - endif() - - if(_gecode_qt_version VERSION_LESS GECODE_QT_MIN_VERSION) - if(NOT _gecode_qt_old_version) - set(_gecode_qt_old_version "${_gecode_qt_version}") - endif() - continue() - endif() - - if(NOT _gecode_qt_runtime_candidate_major) - set(_gecode_qt_runtime_candidate_major "${_gecode_qt_major}") - set(_gecode_qt_runtime_candidate_version "${_gecode_qt_version}") - endif() - - set(_gecode_qt_has_widgets TRUE) - foreach(_gecode_qt_target - Qt${_gecode_qt_major}::Widgets - Qt${_gecode_qt_major}::Gui - Qt${_gecode_qt_major}::PrintSupport) - if(NOT TARGET ${_gecode_qt_target}) - set(_gecode_qt_has_widgets FALSE) - endif() - endforeach() - if(_gecode_qt_has_widgets AND NOT _gecode_qt_widgets_candidate_major) - set(_gecode_qt_widgets_candidate_major "${_gecode_qt_major}") - set(_gecode_qt_widgets_candidate_version "${_gecode_qt_version}") - endif() - endforeach() - - if(GECODE_WANT_GIST AND _gecode_qt_widgets_candidate_major) - set(GECODE_QT_MAJOR "${_gecode_qt_widgets_candidate_major}") - set(GECODE_QT_VERSION "${_gecode_qt_widgets_candidate_version}") - elseif(_gecode_qt_runtime_candidate_major) - set(GECODE_QT_MAJOR "${_gecode_qt_runtime_candidate_major}") - set(GECODE_QT_VERSION "${_gecode_qt_runtime_candidate_version}") - endif() - - if(GECODE_QT_MAJOR) + find_package(Qt6 QUIET COMPONENTS Core OPTIONAL_COMPONENTS Gui Widgets PrintSupport) + if(TARGET Qt6::Core) set(GECODE_HAS_QT_RUNTIME TRUE) - set(GECODE_QT_CORE Qt${GECODE_QT_MAJOR}::Core) - set(GECODE_QT_WIDGETS - Qt${GECODE_QT_MAJOR}::Widgets - Qt${GECODE_QT_MAJOR}::Gui - Qt${GECODE_QT_MAJOR}::PrintSupport) - set(GECODE_HAS_QT_WIDGETS TRUE) - foreach(qt_target ${GECODE_QT_WIDGETS}) - if(NOT TARGET ${qt_target}) - set(GECODE_HAS_QT_WIDGETS FALSE) - endif() - endforeach() - elseif(GECODE_ENABLE_QT_REQUIRED) - if(_gecode_qt_old_version) - message(FATAL_ERROR - "GECODE_ENABLE_QT=ON requires Qt ${GECODE_QT_MIN_VERSION} or newer; found ${_gecode_qt_old_version}") + set(GECODE_QT_CORE Qt6::Core) + set(GECODE_QT_VERSION "${Qt6Core_VERSION}") + if(TARGET Qt6::Widgets AND TARGET Qt6::Gui AND TARGET Qt6::PrintSupport) + set(GECODE_HAS_QT_WIDGETS TRUE) + set(GECODE_QT_WIDGETS Qt6::Widgets Qt6::Gui Qt6::PrintSupport) endif() - message(FATAL_ERROR "GECODE_ENABLE_QT=ON requires Qt ${GECODE_QT_MIN_VERSION} or newer") - elseif(_gecode_qt_old_version) - message(WARNING - "Qt ${_gecode_qt_old_version} was found, but Gecode requires Qt ${GECODE_QT_MIN_VERSION} or newer. " - "Disabling Qt support.") + elseif(GECODE_ENABLE_QT_REQUIRED) + message(FATAL_ERROR "GECODE_ENABLE_QT=ON requires Qt 6") endif() - - unset(_gecode_qt_has_widgets) - unset(_gecode_qt_major) - unset(_gecode_qt_old_version) - unset(_gecode_qt_runtime_candidate_major) - unset(_gecode_qt_runtime_candidate_version) - unset(_gecode_qt_target) - unset(_gecode_qt_version) - unset(_gecode_qt_widgets_candidate_major) - unset(_gecode_qt_widgets_candidate_version) endif() set(GECODE_BUILD_GIST_TARGET ${GECODE_WANT_GIST}) @@ -1721,7 +1642,6 @@ if(GECODE_INSTALL) list(APPEND GECODE_PACKAGE_TEST_TYPES float) endif() endif() - set(GECODE_PACKAGE_QT_MAJOR "") set(GECODE_PACKAGE_QT_COMPONENTS "") set(GECODE_PACKAGE_QT_VERSION "") if(GECODE_BUILD_GIST_TARGET) @@ -1730,7 +1650,6 @@ if(GECODE_INSTALL) set(GECODE_PACKAGE_QT_COMPONENTS "Core") endif() if(NOT GECODE_PACKAGE_QT_COMPONENTS STREQUAL "") - set(GECODE_PACKAGE_QT_MAJOR "${GECODE_QT_MAJOR}") string(REGEX MATCH "^[0-9]+\\.[0-9]+" GECODE_PACKAGE_QT_VERSION "${GECODE_QT_VERSION}") endif() diff --git a/changelog.in b/changelog.in index 1789773007..885fb9aae4 100644 --- a/changelog.in +++ b/changelog.in @@ -76,6 +76,14 @@ Date: unreleased This release contains breaking changes. See the entries below for the changes downstream code needs. +[ENTRY] +Module: gist +What: removed +Rank: minor +[DESCRIPTION] +Remove Qt 5 support. Gist and the Qt-backed FlatZinc features now +require Qt 6. + [ENTRY] Module: support What: removed diff --git a/cmake/GecodeConfig.cmake.in b/cmake/GecodeConfig.cmake.in index 7079bd39c9..7009a5e7a1 100644 --- a/cmake/GecodeConfig.cmake.in +++ b/cmake/GecodeConfig.cmake.in @@ -210,15 +210,12 @@ endif() set(_gecode_qt_components "@GECODE_PACKAGE_QT_COMPONENTS@") set(_gecode_qt_version "@GECODE_PACKAGE_QT_VERSION@") set(_gecode_needs_qt FALSE) -if(gist IN_LIST _gecode_component_closure OR - (flatzinc IN_LIST _gecode_component_closure AND - NOT "@GECODE_PACKAGE_QT_MAJOR@" STREQUAL "")) +if(NOT _gecode_qt_components STREQUAL "" AND + (gist IN_LIST _gecode_component_closure OR flatzinc IN_LIST _gecode_component_closure)) set(_gecode_needs_qt TRUE) endif() -if(_gecode_needs_qt AND "@GECODE_PACKAGE_QT_MAJOR@" STREQUAL "6") +if(_gecode_needs_qt) find_dependency(Qt6 ${_gecode_qt_version} COMPONENTS ${_gecode_qt_components}) -elseif(_gecode_needs_qt AND "@GECODE_PACKAGE_QT_MAJOR@" STREQUAL "5") - find_dependency(Qt5 ${_gecode_qt_version} COMPONENTS ${_gecode_qt_components}) endif() unset(_gecode_qt_version) diff --git a/docs/cmake-build.md b/docs/cmake-build.md index c75aa025c4..e6e06ce4a7 100644 --- a/docs/cmake-build.md +++ b/docs/cmake-build.md @@ -16,10 +16,9 @@ For modelling and search, use MPG and the API reference linked from the - Python 3.11 or newer for helper scripts run through `uv`. - Optional dependencies based on enabled modules: - MPFR for float support with MPFR - - Qt 6 Core, or Qt 5.15+ Core, for FlatZinc plugin support when Qt support - is enabled or auto-detected - - Qt 6 Gui, Widgets, and PrintSupport, or the matching Qt 5.15+ components, - for Gist + - Qt 6 Core for FlatZinc plugin support when Qt support is enabled or + auto-detected + - Qt 6 Gui, Widgets, and PrintSupport for Gist ## Quick Start @@ -132,7 +131,7 @@ to inspect test assignments. | `GECODE_BUILD_STATIC` | Default `OFF` | | `GECODE_ENABLE_THREAD` | Default `ON` | | `GECODE_ENABLE_OSX_UNFAIR_MUTEX` | Default `ON` | -| `GECODE_ENABLE_QT` | `AUTO` by default; Qt 6 preferred; Qt 5.15+ supported | +| `GECODE_ENABLE_QT` | `AUTO` by default; requires Qt 6 | | `GECODE_ENABLE_GIST` | `AUTO` by default except macOS; disabled automatically if Qt GUI support is unavailable | | `GECODE_ENABLE_CPPROFILER` | Default `ON` | | `GECODE_ENABLE_CBS` | Default `OFF` | @@ -364,7 +363,7 @@ Deprecation horizon: use `AUTO` when dependency discovery should be best-effort. - `GECODE_ENABLE_GIST=ON` requires Qt discovery and a usable Qt link interface. - - Gecode requires Qt 5.15 or newer. Qt 6 is preferred for new builds. + - Gecode requires Qt 6. - On macOS, Gist defaults to `OFF`; enable it explicitly once the local Qt/OpenGL framework setup is known to link. Current macOS SDKs require a current Qt 6 build; older Qt packages can still reference removed system diff --git a/examples/knights.cpp b/examples/knights.cpp index b6ceb06be5..53b0e80654 100644 --- a/examples/knights.cpp +++ b/examples/knights.cpp @@ -38,10 +38,8 @@ #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) #include -#if QT_VERSION >= 0x050000 #include #endif -#endif using namespace Gecode; diff --git a/examples/queens.cpp b/examples/queens.cpp index 3e8c00e51a..0afa9e8c5b 100644 --- a/examples/queens.cpp +++ b/examples/queens.cpp @@ -36,10 +36,8 @@ #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST) #include -#if QT_VERSION >= 0x050000 #include #endif -#endif using namespace Gecode; diff --git a/gecode/flatzinc/exampleplugin/CMakeLists.txt b/gecode/flatzinc/exampleplugin/CMakeLists.txt index 41c92ef41f..ec98eff65c 100644 --- a/gecode/flatzinc/exampleplugin/CMakeLists.txt +++ b/gecode/flatzinc/exampleplugin/CMakeLists.txt @@ -11,7 +11,7 @@ endif() if(NOT TARGET ${gecode_plugin_library}) message(FATAL_ERROR "The branch plugin example requires shared Gecode libraries") endif() -if(NOT TARGET Qt6::Core AND NOT TARGET Qt5::Core) +if(NOT TARGET Qt6::Core) message(FATAL_ERROR "The branch plugin example requires Gecode built with Qt") endif() diff --git a/gecode/gist/drawingcursor.cpp b/gecode/gist/drawingcursor.cpp index 3d6fa298e1..9d8713fe1d 100644 --- a/gecode/gist/drawingcursor.cpp +++ b/gecode/gist/drawingcursor.cpp @@ -99,11 +99,7 @@ namespace Gecode { namespace Gist { QString label = na.get_label(n); int alt = n->get_alternative(na); int n_alt = n->get_parent(na)->get_number_of_children(); -#if QT_VERSION >= 0x060000 int tw = fm.horizontalAdvance(label); -#else - int tw = fm.width(label); -#endif int lx; if (alt == 0 && n_alt > 1) { lx = myx - tw - 4; diff --git a/gecode/gist/mainwindow.cpp b/gecode/gist/mainwindow.cpp index 285992673a..0a84a8a74d 100644 --- a/gecode/gist/mainwindow.cpp +++ b/gecode/gist/mainwindow.cpp @@ -88,9 +88,7 @@ namespace Gecode { namespace Gist { QMenu* file_menu = menu_bar->addMenu(tr("&File")); file_menu->addAction(c->print); -#if QT_VERSION >= 0x040400 file_menu->addAction(c->export_whole_tree_pdf); -#endif QAction* quit_action = file_menu->addAction(tr("Quit")); quit_action->setShortcut(QKeySequence("Ctrl+Q")); connect(quit_action, SIGNAL(triggered()), this, SLOT(close())); @@ -138,9 +136,7 @@ namespace Gecode { namespace Gist { node_menu->addSeparator(); node_menu->addAction(c->zoom_to_fit); node_menu->addAction(c->center); -#if QT_VERSION >= 0x040400 node_menu->addAction(c->export_pdf); -#endif QMenu* search_menu = menu_bar->addMenu(tr("&Search")); search_menu->addAction(c->search_next); diff --git a/gecode/gist/nodestats.hh b/gecode/gist/nodestats.hh index 48f33ab1ee..7c388683e7 100644 --- a/gecode/gist/nodestats.hh +++ b/gecode/gist/nodestats.hh @@ -36,9 +36,7 @@ #include #include -#if QT_VERSION >= 0x050000 #include -#endif namespace Gecode { namespace Gist { diff --git a/gecode/gist/preferences.hh b/gecode/gist/preferences.hh index 12e6628d22..3ace552f79 100644 --- a/gecode/gist/preferences.hh +++ b/gecode/gist/preferences.hh @@ -34,9 +34,7 @@ #define GECODE_GIST_PREFERENCES_HH #include -#if QT_VERSION >= 0x050000 #include -#endif #include namespace Gecode { namespace Gist { diff --git a/gecode/gist/textoutput.cpp b/gecode/gist/textoutput.cpp index 5114fc03c3..53199083ec 100644 --- a/gecode/gist/textoutput.cpp +++ b/gecode/gist/textoutput.cpp @@ -31,9 +31,7 @@ */ #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include diff --git a/gecode/gist/treecanvas.cpp b/gecode/gist/treecanvas.cpp index 6cc91c62f0..99dbbd1c61 100644 --- a/gecode/gist/treecanvas.cpp +++ b/gecode/gist/treecanvas.cpp @@ -49,16 +49,10 @@ namespace Gecode { namespace Gist { TreeCanvas::TreeCanvas(Space* root_space, bool bab, QWidget* parent, const Options& opt) - : QWidget(parent) -#if QT_VERSION < 0x060000 - , - mutex(QMutex::Recursive), layout_mutex(QMutex::Recursive) -#endif - , - finished_flag(false), compare_nodes(false), compare_nodes_before_fp(false), auto_hide_failed(true), - auto_zoom(false), refresh(500), refresh_pause(0), smooth_scroll_and_zoom(false), move_during_search(false), - zoom_time_line(500), scroll_time_line(1000), target_x(0), source_x(0), target_y(0), source_y(0), target_w(0), - target_h(0), target_scale(0), layout_done_timer_id(0) { + : QWidget(parent), finished_flag(false), compare_nodes(false), compare_nodes_before_fp(false), + auto_hide_failed(true), auto_zoom(false), refresh(500), refresh_pause(0), smooth_scroll_and_zoom(false), + move_during_search(false), zoom_time_line(500), scroll_time_line(1000), target_x(0), source_x(0), target_y(0), + source_y(0), target_w(0), target_h(0), target_scale(0), layout_done_timer_id(0) { QMutexLocker locker(&mutex); cur_best = (bab ? new BestNode(nullptr) : nullptr); if (root_space->status() == SS_FAILED) { @@ -94,11 +88,7 @@ namespace Gecode { namespace Gist { connect(&searcher, SIGNAL(search_finished(void)), this, SIGNAL(search_finished(void))); connect(&scroll_time_line, SIGNAL(frameChanged(int)), this, SLOT(scroll(int))); -#if QT_VERSION >= 0x060000 scroll_time_line.setEasingCurve(QEasingCurve::InOutSine); -#else - scroll_time_line.setCurveShape(QTimeLine::EaseInOutCurve); -#endif scale_bar = new QSlider(Qt::Vertical, this); scale_bar->setObjectName("scaleBar"); @@ -110,11 +100,7 @@ namespace Gecode { namespace Gist { connect(&searcher, SIGNAL(scale_changed(int)), scale_bar, SLOT(setValue(int))); connect(&zoom_time_line, SIGNAL(frameChanged(int)), scale_bar, SLOT(setValue(int))); -#if QT_VERSION >= 0x060000 zoom_time_line.setEasingCurve(QEasingCurve::InOutSine); -#else - zoom_time_line.setCurveShape(QTimeLine::EaseInOutCurve); -#endif qRegisterMetaType("Statistics"); update(); @@ -962,7 +948,6 @@ namespace Gecode { namespace Gist { void TreeCanvas::export_node_pdf(VisualNode* n) { -#if QT_VERSION >= 0x040400 QString filename = QFileDialog::getSaveFileName(this, tr("Export tree as pdf"), "", tr("PDF (*.pdf)")); if (filename != "") { QPrinter printer(QPrinter::ScreenResolution); @@ -970,24 +955,14 @@ namespace Gecode { namespace Gist { BoundingBox bb = n->get_bounding_box(); printer.setFullPage(true); -#if QT_VERSION >= 0x060000 printer.setPageSize(QPageSize( QSizeF(bb.right - bb.left + Layout::extent, n->get_shape()->depth() * Layout::dist_y + Layout::extent), QPageSize::Point)); -#else - printer.setPaperSize( - QSizeF(bb.right - bb.left + Layout::extent, n->get_shape()->depth() * Layout::dist_y + Layout::extent), - QPrinter::Point); -#endif printer.setOutputFileName(filename); QPainter painter(&printer); painter.setRenderHint(QPainter::Antialiasing); -#if QT_VERSION >= 0x060000 QRect page_rect = printer.pageLayout().paintRectPixels(printer.resolution()); -#else - QRect page_rect = printer.pageRect(); -#endif double new_x_scale = static_cast(page_rect.width()) / (bb.right - bb.left + Layout::extent); double new_y_scale = static_cast(page_rect.height()) / (n->get_shape()->depth() * Layout::dist_y + Layout::extent); @@ -1004,23 +979,16 @@ namespace Gecode { namespace Gist { PreorderNodeVisitor(dc).run(); current_node->set_marked(true); } -#else - (void)n; -#endif } void TreeCanvas::export_whole_tree_pdf(void) { -#if QT_VERSION >= 0x040400 export_node_pdf(root); -#endif } void TreeCanvas::export_pdf(void) { -#if QT_VERSION >= 0x040400 export_node_pdf(current_node); -#endif } void @@ -1030,11 +998,7 @@ namespace Gecode { namespace Gist { QMutexLocker locker(&mutex); BoundingBox bb = root->get_bounding_box(); -#if QT_VERSION >= 0x060000 QRect page_rect = printer.pageLayout().paintRectPixels(printer.resolution()); -#else - QRect page_rect = printer.pageRect(); -#endif double new_x_scale = static_cast(page_rect.width()) / (bb.right - bb.left + Layout::extent); double new_y_scale = static_cast(page_rect.height()) / (root->get_shape()->depth() * Layout::dist_y + 2 * Layout::extent); @@ -1071,13 +1035,8 @@ namespace Gecode { namespace Gist { case QEvent::MouseButtonRelease: case QEvent::MouseMove: { QMouseEvent* me = static_cast(event); -#if QT_VERSION >= 0x060000 x = me->position().x(); y = me->position().y(); -#else - x = me->x(); - y = me->y(); -#endif break; } case QEvent::ContextMenu: { @@ -1212,14 +1171,9 @@ namespace Gecode { namespace Gist { TreeCanvas::wheelEvent(QWheelEvent* event) { if (event->modifiers() & Qt::ShiftModifier) { event->accept(); -#if QT_VERSION >= 0x060000 if (event->angleDelta().y() != 0 && !auto_zoom) scale_tree(scale * 100 + ceil(static_cast(event->angleDelta().y()) / 4.0), event->position().x(), event->position().y()); -#else - if (event->orientation() == Qt::Vertical && !auto_zoom) - scale_tree(scale * 100 + ceil(static_cast(event->delta()) / 4.0), event->x(), event->y()); -#endif } else { event->ignore(); } diff --git a/gecode/gist/treecanvas.hh b/gecode/gist/treecanvas.hh index 0bf679cb76..80456aba77 100644 --- a/gecode/gist/treecanvas.hh +++ b/gecode/gist/treecanvas.hh @@ -34,20 +34,14 @@ #define GECODE_GIST_TREECANVAS_HH #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include #include -#if QT_VERSION >= 0x060000 typedef QRecursiveMutex GecodeQMutex; -#else -typedef QMutex GecodeQMutex; -#endif namespace Gecode { namespace Gist {