From f8d57dce5d761078f3ace15cd4619a7ef97f595a Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 20 Jul 2026 18:56:10 +0200 Subject: [PATCH] build(grantlee): add Qt6 migration helper script build_grantlee_qt6.sh to attempt pragmatic CMake patches and build against Qt6 --- app/build_grantlee_qt6.sh | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/build_grantlee_qt6.sh diff --git a/app/build_grantlee_qt6.sh b/app/build_grantlee_qt6.sh new file mode 100644 index 000000000..7f80c0c33 --- /dev/null +++ b/app/build_grantlee_qt6.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -euo pipefail + +# build_grantlee_qt6.sh - build grantlee with pragmatic Qt6 patches and install to INSTALL_PREFIX +QT_ROOT=${QT_ROOT:-/opt/Qt/6.8.3/gcc_64} +INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local} + +echo "Building Grantlee (attempt Qt6 port) into ${INSTALL_PREFIX} using QT_ROOT=${QT_ROOT}" +TMPDIR=$(mktemp -d) +trap 'rm -rf "$TMPDIR"' EXIT +cd "$TMPDIR" + +if ! git clone --depth 1 https://github.com/steveire/grantlee.git grantlee; then + echo "Failed to clone grantlee" >&2 + exit 1 +fi + +pushd grantlee >/dev/null +# Backup relevant files +git ls-files | grep -E "CMakeLists.txt|\\.cmake$" | xargs -r -n1 -I{} cp {} {}.bak || true + +# Python-based safe patches +python3 - <<'PY' +import re +from pathlib import Path +patterns = [ + (re.compile(r'find_package\s*\(\s*Qt5[^)]*\)', re.M), 'find_package(Qt6 REQUIRED COMPONENTS Core Widgets)'), + (re.compile(r'Qt5::'), 'Qt6::'), + (re.compile(r'QT5_WRAP_CPP'), 'QT_WRAP_CPP'), +] +for p in Path('.').rglob('*'): + if p.is_file() and (p.name=='CMakeLists.txt' or p.suffix=='.cmake'): + try: + s = p.read_text() + orig = s + for pat, repl in patterns: + s = pat.sub(repl, s) + if s != orig: + p.write_text(s) + print('Patched', p) + except Exception as e: + print('Skipping', p, 'error', e) +PY + +popd >/dev/null + +mkdir -p grantlee/build +cd grantlee/build +cmake -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ + -DCMAKE_PREFIX_PATH="${QT_ROOT}:${INSTALL_PREFIX}" .. + +cmake --build . -- -j$(nproc) || true +cmake --install . || true + +echo "Grantlee attempted build finished" +exit 0