31 lines
1.3 KiB
Bash
Executable File
31 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Apply lightweight fix to Grantlee sources in externals to avoid duplicate
|
|
# QT_TESTCASE_BUILDDIR definition which causes compiler errors on Qt6.
|
|
|
|
GRANTLEE_SRC_DIR="${1:-./external/grantlee-src}"
|
|
|
|
if [ ! -d "$GRANTLEE_SRC_DIR" ]; then
|
|
echo "Grantlee source dir not found: $GRANTLEE_SRC_DIR" >&2
|
|
exit 2
|
|
fi
|
|
|
|
TARGET_FILE="$GRANTLEE_SRC_DIR/textdocument/tests/CMakeLists.txt"
|
|
|
|
if [ ! -f "$TARGET_FILE" ]; then
|
|
echo "Target CMake file not found: $TARGET_FILE" >&2
|
|
exit 3
|
|
fi
|
|
|
|
# Replace the unconditional target_compile_definitions block with a commented
|
|
# explanation to avoid duplicate -D flags.
|
|
|
|
awk '
|
|
BEGIN{inblock=0}
|
|
/target_compile_definitions\(plainmarkupbuildertest_exec PRIVATE QT_TESTCASE_BUILDDIR/ {inblock=1; print "# QT_TESTCASE_BUILDDIR was previously defined here which could conflict with the"; print "# the definition injected by Qt\'s test configuration. Defining the macro in"; print "# multiple places leads to compiler redefinition errors. The test framework"; print "# already provides this define when needed, so omit the explicit definition"; print "# to avoid duplicate -D flags."; next}
|
|
{ if (inblock) { if (/^endif\(\)/) { inblock=0; next } else next } print }
|
|
' "$TARGET_FILE" > "$TARGET_FILE.tmp" && mv "$TARGET_FILE.tmp" "$TARGET_FILE"
|
|
|
|
echo "Applied grantlee fix to $TARGET_FILE"
|