Skip to content

Commit 8338d9c

Browse files
author
Mikael Zayenz Lagerkvist
committed
Merge current main into clone-memory stability branch
2 parents a0dbbd4 + d86ed2f commit 8338d9c

28 files changed

Lines changed: 917 additions & 263 deletions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
destdir="${1:?usage: autoconf-install-smoke.sh <destdir> [logical-prefix]}"
5+
logical_prefix="${2:-/usr/local}"
6+
7+
case "$logical_prefix" in
8+
/*) ;;
9+
*)
10+
echo "logical prefix must be absolute: $logical_prefix" >&2
11+
exit 2
12+
;;
13+
esac
14+
15+
rm -rf "$destdir"
16+
mkdir -p "$destdir"
17+
18+
make install DESTDIR="$destdir"
19+
20+
install_prefix="${destdir%/}$logical_prefix"
21+
solver_dir="$install_prefix/share/minizinc/solvers"
22+
solver_config="$solver_dir/gecode.msc"
23+
mznlib_dir="$install_prefix/share/minizinc/gecode"
24+
25+
test -f "$install_prefix/include/gecode/support/config.hpp"
26+
test -x "$install_prefix/bin/fzn-gecode"
27+
test -x "$install_prefix/bin/mzn-gecode"
28+
! grep -q "/usr/local" "$install_prefix/bin/mzn-gecode"
29+
30+
test -f "$solver_config"
31+
test -f "$mznlib_dir/experimental/on_restart/fzn_on_restart_complete.mzn"
32+
33+
python3 - "$solver_config" "$solver_dir" <<'PY'
34+
import json
35+
import pathlib
36+
import sys
37+
38+
config_path = pathlib.Path(sys.argv[1])
39+
solver_dir = pathlib.Path(sys.argv[2])
40+
config = json.loads(config_path.read_text(encoding="utf-8"))
41+
42+
if config.get("id") != "org.gecode.gecode":
43+
raise SystemExit(f"unexpected solver id: {config.get('id')!r}")
44+
if config.get("supportsFzn") is not True:
45+
raise SystemExit("solver config should support FlatZinc")
46+
47+
for key, expected_kind in (("mznlib", "dir"), ("executable", "file")):
48+
value = config.get(key)
49+
if not isinstance(value, str) or not value:
50+
raise SystemExit(f"{key} must be a non-empty string")
51+
if value.startswith("/") or ":\\" in value:
52+
raise SystemExit(f"{key} should be relative, got {value!r}")
53+
resolved = (solver_dir / value).resolve()
54+
if expected_kind == "dir" and not resolved.is_dir():
55+
raise SystemExit(f"{key} does not resolve to a directory: {resolved}")
56+
if expected_kind == "file" and not resolved.is_file():
57+
raise SystemExit(f"{key} does not resolve to a file: {resolved}")
58+
PY
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
prefix="${1:?usage: cmake-consumer-smoke-msys2.sh <install-prefix>}"
5+
work_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
6+
work="$work_root/gecode-consumer-msys2"
7+
8+
rm -rf "$work"
9+
mkdir -p "$work"
10+
11+
cat > "$work/CMakeLists.txt" <<'EOF'
12+
cmake_minimum_required(VERSION 3.21)
13+
project(msys2_static_consumer LANGUAGES CXX)
14+
find_package(Gecode CONFIG REQUIRED)
15+
if(NOT TARGET Gecode::gecode)
16+
message(FATAL_ERROR "Expected installed package to export Gecode::gecode")
17+
endif()
18+
add_executable(msys2_static_consumer main.cpp)
19+
target_link_libraries(msys2_static_consumer PRIVATE Gecode::gecode)
20+
EOF
21+
22+
cat > "$work/main.cpp" <<'EOF'
23+
#include <gecode/int.hh>
24+
#include <gecode/support/config.hpp>
25+
26+
int main(void) {
27+
Gecode::IntArgs values(1);
28+
values[0] = 0;
29+
return values[0];
30+
}
31+
EOF
32+
33+
cmake -S "$work" -B "$work/build" -G Ninja -DCMAKE_PREFIX_PATH="$prefix"
34+
cmake --build "$work/build"

.github/ci/cmake-consumer-smoke-vcpkg.ps1

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ $toolchain = "$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
1010
$manifest = Join-Path $work "manifest"
1111
$consumerVcpkgInstalled = Join-Path $work "vcpkg_installed"
1212
if (Test-Path $work) { Remove-Item -Recurse -Force $work }
13-
New-Item -ItemType Directory -Force -Path (Join-Path $work "a"), (Join-Path $work "b"), (Join-Path $work "c"), $manifest | Out-Null
13+
New-Item -ItemType Directory -Force -Path `
14+
(Join-Path $work "a"), `
15+
(Join-Path $work "b"), `
16+
(Join-Path $work "c"), `
17+
(Join-Path $work "d"), `
18+
$manifest | Out-Null
1419

1520
$baseline = (Get-Content "$env:GITHUB_WORKSPACE\vcpkg.json" | ConvertFrom-Json).'builtin-baseline'
1621
@"
@@ -67,6 +72,38 @@ int main(void) {
6772
}
6873
'@ | Set-Content -Encoding utf8 (Join-Path $work "c\main.cpp")
6974

75+
@'
76+
cmake_minimum_required(VERSION 3.21)
77+
project(consumer_d LANGUAGES CXX)
78+
find_package(Gecode CONFIG REQUIRED COMPONENTS float)
79+
if(NOT TARGET MPFR::MPFR)
80+
message(FATAL_ERROR "Expected Gecode package to provide MPFR::MPFR")
81+
endif()
82+
if(TARGET Gecode::gecodefloat_shared)
83+
get_target_property(gecodefloat_links Gecode::gecodefloat_shared INTERFACE_LINK_LIBRARIES)
84+
elseif(TARGET Gecode::gecodefloat_static)
85+
get_target_property(gecodefloat_links Gecode::gecodefloat_static INTERFACE_LINK_LIBRARIES)
86+
else()
87+
message(FATAL_ERROR "Expected an exported gecodefloat library target")
88+
endif()
89+
if(NOT gecodefloat_links MATCHES "MPFR::MPFR")
90+
message(FATAL_ERROR "Expected gecodefloat to link MPFR::MPFR, got: ${gecodefloat_links}")
91+
endif()
92+
add_executable(consumer_d main.cpp)
93+
target_link_libraries(consumer_d PRIVATE Gecode::gecodefloat)
94+
'@ | Set-Content -Encoding utf8 (Join-Path $work "d\CMakeLists.txt")
95+
@'
96+
#include <gecode/support/config.hpp>
97+
#ifndef GECODE_HAS_MPFR
98+
#error "Expected installed Gecode package to enable MPFR"
99+
#endif
100+
#include <gecode/float.hh>
101+
int main(void) {
102+
Gecode::Float::Rounding rounding;
103+
return rounding.exp_down(1.0) > 0.0 ? 0 : 1;
104+
}
105+
'@ | Set-Content -Encoding utf8 (Join-Path $work "d\main.cpp")
106+
70107
cmake -S (Join-Path $work "a") -B (Join-Path $work "a\build") -G "Visual Studio 17 2022" -A x64 `
71108
"-DCMAKE_TOOLCHAIN_FILE=$toolchain" `
72109
"-DVCPKG_MANIFEST_MODE=ON" `
@@ -97,6 +134,15 @@ cmake -S (Join-Path $work "c") -B (Join-Path $work "c\build") -G "Visual Studio
97134
"-DCMAKE_PREFIX_PATH=$prefix"
98135
cmake --build (Join-Path $work "c\build") --config $env:BUILD_TYPE
99136

137+
cmake -S (Join-Path $work "d") -B (Join-Path $work "d\build") -G "Visual Studio 17 2022" -A x64 `
138+
"-DCMAKE_TOOLCHAIN_FILE=$toolchain" `
139+
"-DVCPKG_MANIFEST_MODE=ON" `
140+
"-DVCPKG_MANIFEST_DIR=$manifest" `
141+
"-DVCPKG_INSTALLED_DIR=$consumerVcpkgInstalled" `
142+
"-DVCPKG_TARGET_TRIPLET=x64-windows" `
143+
"-DCMAKE_PREFIX_PATH=$prefix"
144+
cmake --build (Join-Path $work "d\build") --config $env:BUILD_TYPE
145+
100146
if (-not (Select-String -Path (Join-Path $work "a\configure.log") -Pattern "Gecode_VERSION=" -Quiet)) {
101147
throw "Gecode_VERSION was not reported during consumer configure."
102148
}

.github/ci/cmake-consumer-smoke.sh

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
11
#!/usr/bin/env bash
22
set -euxo pipefail
33

4-
prefix="${1:?usage: cmake-consumer-smoke.sh <install-prefix> <expected-include-dir>}"
5-
expected_include="${2:?usage: cmake-consumer-smoke.sh <install-prefix> <expected-include-dir>}"
4+
usage="usage: cmake-consumer-smoke.sh <install-prefix> <expected-include-dir> [core|mpfr]"
5+
prefix="${1:?$usage}"
6+
expected_include="${2:?$usage}"
7+
mode="${3:-mpfr}"
8+
case "$mode" in
9+
core)
10+
expect_mpfr=OFF
11+
;;
12+
mpfr)
13+
expect_mpfr=ON
14+
;;
15+
*)
16+
echo "$usage" >&2
17+
exit 2
18+
;;
19+
esac
620
work="$RUNNER_TEMP/gecode-consumers"
721
rm -rf "$work"
8-
mkdir -p "$work/a" "$work/b" "$work/c" "$work/d/cmake" "$work/e/cmake" "$work/e/stale"
22+
mkdir -p "$work/a" "$work/b" "$work/c" "$work/d/cmake" "$work/e/cmake" "$work/e/stale" \
23+
"$work/mpfr-prefix/lib/cmake/MPFR"
924

1025
cat > "$work/a/CMakeLists.txt" <<'EOF'
1126
cmake_minimum_required(VERSION 3.21)
1227
project(consumer_a LANGUAGES CXX)
1328
find_package(Gecode CONFIG REQUIRED)
1429
message(STATUS "Gecode_VERSION=${Gecode_VERSION}")
1530
message(STATUS "Gecode_INCLUDE_DIRS=${Gecode_INCLUDE_DIRS}")
31+
set(EXPECTED_GECODE_INCLUDE_DIR "" CACHE PATH "Expected Gecode include directory")
32+
if(NOT Gecode_INCLUDE_DIRS STREQUAL EXPECTED_GECODE_INCLUDE_DIR)
33+
message(FATAL_ERROR
34+
"Expected Gecode_INCLUDE_DIRS=${EXPECTED_GECODE_INCLUDE_DIR}, got: ${Gecode_INCLUDE_DIRS}")
35+
endif()
36+
set(EXPECT_MPFR OFF CACHE BOOL "Expect Gecode package to require MPFR")
37+
if(EXPECT_MPFR)
38+
if(NOT TARGET MPFR::MPFR)
39+
message(FATAL_ERROR "Expected MPFR::MPFR from the fake MPFR config package")
40+
endif()
41+
get_target_property(mpfr_config_marker MPFR::MPFR INTERFACE_COMPILE_DEFINITIONS)
42+
if(NOT mpfr_config_marker)
43+
set(mpfr_config_marker)
44+
endif()
45+
if(NOT "GECODE_SMOKE_FAKE_MPFR_CONFIG" IN_LIST mpfr_config_marker)
46+
message(FATAL_ERROR "Expected fake MPFR config package, got marker: ${mpfr_config_marker}")
47+
endif()
48+
endif()
1649
add_executable(consumer_a main.cpp)
1750
target_link_libraries(consumer_a PRIVATE Gecode::gecode)
1851
EOF
@@ -122,7 +155,25 @@ set(MPFR_INCLUDE_DIRS "/bad/prior/mpfr/include")
122155
set(MPFR_LIBRARIES "/bad/prior/mpfr/lib/libmpfr.a")
123156
EOF
124157

125-
cmake -S "$work/a" -B "$work/a/build" -DCMAKE_PREFIX_PATH="$prefix" 2>&1 | tee "$work/a/configure.log"
158+
cat > "$work/mpfr-prefix/lib/cmake/MPFR/MPFRConfig.cmake" <<'EOF'
159+
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
160+
if(NOT TARGET MPFR::MPFR)
161+
add_library(MPFR::MPFR INTERFACE IMPORTED)
162+
endif()
163+
set_target_properties(MPFR::MPFR PROPERTIES
164+
INTERFACE_COMPILE_DEFINITIONS GECODE_SMOKE_FAKE_MPFR_CONFIG)
165+
set(MPFR_FOUND TRUE)
166+
EOF
167+
168+
cmake_prefix_path="$prefix"
169+
if [ "$mode" = "mpfr" ]; then
170+
cmake_prefix_path="$work/mpfr-prefix;$prefix"
171+
fi
172+
173+
cmake -S "$work/a" -B "$work/a/build" \
174+
-DCMAKE_PREFIX_PATH="$cmake_prefix_path" \
175+
-DEXPECTED_GECODE_INCLUDE_DIR="$expected_include" \
176+
-DEXPECT_MPFR="$expect_mpfr" 2>&1 | tee "$work/a/configure.log"
126177
cmake --build "$work/a/build" -j4
127178

128179
cmake -S "$work/b" -B "$work/b/build" -DCMAKE_PREFIX_PATH="$prefix"
@@ -131,15 +182,19 @@ cmake --build "$work/b/build" -j4
131182
cmake -S "$work/c" -B "$work/c/build" -DCMAKE_PREFIX_PATH="$prefix"
132183
cmake --build "$work/c/build" -j4
133184

134-
cmake -S "$work/d" -B "$work/d/build" -DCMAKE_PREFIX_PATH="$prefix"
135-
cmake --build "$work/d/build" -j4
185+
if [ "$mode" = "mpfr" ]; then
186+
cmake -S "$work/d" -B "$work/d/build" -DCMAKE_PREFIX_PATH="$prefix"
187+
cmake --build "$work/d/build" -j4
136188

137-
cmake -S "$work/e" -B "$work/e/build" -DCMAKE_PREFIX_PATH="$prefix"
138-
cmake --build "$work/e/build" -j4
189+
cmake -S "$work/e" -B "$work/e/build" -DCMAKE_PREFIX_PATH="$prefix"
190+
cmake --build "$work/e/build" -j4
191+
fi
139192

140193
grep -q "Gecode_VERSION=" "$work/a/configure.log"
141194
grep -q "Gecode_INCLUDE_DIRS=$expected_include" "$work/a/configure.log"
142-
grep -q '^#define GECODE_HAS_MPFR /\*\*/' "$expected_include/gecode/support/config.hpp"
195+
if [ "$mode" = "mpfr" ]; then
196+
grep -q '^#define GECODE_HAS_MPFR /\*\*/' "$expected_include/gecode/support/config.hpp"
197+
fi
143198
"$prefix/bin/fzn-gecode" --help
144199
test -x "$prefix/bin/mzn-gecode"
145200
! grep -q "/usr/local" "$prefix/bin/mzn-gecode"

.github/ci/custom-vis-smoke.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/usr/bin/env bash
22
set -euxo pipefail
33

4-
git clean -ffdx
4+
repo_root="$(git rev-parse --show-toplevel)"
5+
work_parent="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/gecode-custom-vis-smoke"
6+
work="$work_parent/worktree"
7+
8+
cleanup() {
9+
git -C "$repo_root" worktree remove --force "$work" >/dev/null 2>&1 || rm -rf "$work"
10+
}
11+
trap cleanup EXIT
12+
13+
rm -rf "$work_parent"
14+
mkdir -p "$work_parent"
15+
git -C "$repo_root" worktree prune
16+
git -C "$repo_root" worktree add --detach "$work" HEAD
17+
18+
cd "$work"
519
touch configure
620

721
awk '

.github/ci/qt-gist-consumer-smoke.sh

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,77 @@ project(qt_gist_consumer LANGUAGES CXX)
1212
find_package(Gecode CONFIG REQUIRED COMPONENTS gist flatzinc)
1313
add_executable(qt_gist_consumer main.cpp)
1414
target_link_libraries(qt_gist_consumer PRIVATE Gecode::gecodegist Gecode::gecodeflatzinc)
15-
get_target_property(gecodeflatzinc_links Gecode::gecodeflatzinc_shared INTERFACE_LINK_LIBRARIES)
16-
if(NOT gecodeflatzinc_links MATCHES "Qt6::Core")
17-
message(FATAL_ERROR "Expected Gecode::gecodeflatzinc_shared to link Qt6::Core, got: ${gecodeflatzinc_links}")
18-
endif()
15+
16+
function(expect_interface_dependency target expected)
17+
get_target_property(links "${target}" INTERFACE_LINK_LIBRARIES)
18+
if(NOT links)
19+
set(links "")
20+
endif()
21+
set(found FALSE)
22+
foreach(link IN LISTS links)
23+
if(link STREQUAL "${expected}" OR link STREQUAL "$<LINK_ONLY:${expected}>")
24+
set(found TRUE)
25+
endif()
26+
endforeach()
27+
if(NOT found)
28+
message(FATAL_ERROR "Expected ${target} to link ${expected}, got: ${links}")
29+
endif()
30+
endfunction()
31+
32+
function(expect_gist_variant_dependencies kind qt_widgets_target)
33+
set(gist_target "Gecode::gecodegist_${kind}")
34+
if(NOT TARGET "${gist_target}")
35+
return()
36+
endif()
37+
expect_interface_dependency("${gist_target}" "${qt_widgets_target}")
38+
expect_interface_dependency("${gist_target}" "Gecode::gecodesearch_${kind}")
39+
expect_interface_dependency("${gist_target}" "Gecode::gecodeint_${kind}")
40+
if(TARGET "Gecode::gecodeset_${kind}")
41+
expect_interface_dependency("${gist_target}" "Gecode::gecodeset_${kind}")
42+
endif()
43+
if(TARGET "Gecode::gecodefloat_${kind}")
44+
expect_interface_dependency("${gist_target}" "Gecode::gecodefloat_${kind}")
45+
endif()
46+
endfunction()
47+
48+
function(expect_variant_dependency component kind expected)
49+
set(target "Gecode::gecode${component}_${kind}")
50+
if(TARGET "${target}")
51+
expect_interface_dependency("${target}" "${expected}")
52+
endif()
53+
endfunction()
54+
55+
expect_gist_variant_dependencies(shared Qt6::Widgets)
56+
expect_gist_variant_dependencies(static Qt6::Widgets)
57+
expect_variant_dependency(flatzinc shared Qt6::Core)
58+
expect_variant_dependency(flatzinc static Qt6::Core)
1959
EOF
2060
cat > "$work/main.cpp" <<'EOF'
2161
#include <gecode/gist.hh>
2262
#include <gecode/flatzinc.hh>
23-
int main(void) { return 0; }
63+
#include <string>
64+
65+
#ifdef GECODE_HAS_SET_VARS
66+
using SetCompare = std::string (*)(std::string, Gecode::SetVar, Gecode::SetVar);
67+
SetCompare set_compare = &Gecode::Gist::Comparator::compare;
68+
#endif
69+
70+
#ifdef GECODE_HAS_FLOAT_VARS
71+
using FloatCompare = std::string (*)(std::string, Gecode::FloatVar, Gecode::FloatVar);
72+
FloatCompare float_compare = &Gecode::Gist::Comparator::compare;
73+
#endif
74+
75+
int main(void) {
76+
#ifdef GECODE_HAS_SET_VARS
77+
if (set_compare == nullptr)
78+
return 1;
79+
#endif
80+
#ifdef GECODE_HAS_FLOAT_VARS
81+
if (float_compare == nullptr)
82+
return 1;
83+
#endif
84+
return 0;
85+
}
2486
EOF
2587

2688
cmake -S "$work" -B "$work/build" -DCMAKE_PREFIX_PATH="$prefix"

0 commit comments

Comments
 (0)