build(grantlee): add Qt6 migration helper script build_grantlee_qt6.sh to attempt pragmatic CMake patches and build against Qt6
This commit is contained in:
1 parent
866081ee98
commit
f8d57dce5d
1 file changed
+57
@@ -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
|
||||
Reference in new issue
Block a user