diff --git a/app/build_log4qt.sh b/app/build_log4qt.sh index 72f694096..ef8e765c1 100755 --- a/app/build_log4qt.sh +++ b/app/build_log4qt.sh @@ -1,53 +1,21 @@ -#!/usr/bin/env bash -set -euo pipefail +#!/bin/bash +set -e -# build_log4qt.sh - build and install Log4Qt into /usr/local -# Designed to be run inside the Docker build or by a runner that has Qt installed at $QT_ROOT +cd /tmp +git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt +cd log4qt -QT_ROOT=${QT_ROOT:-/opt/Qt/6.8.3/gcc_64} -INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local} +mkdir build && cd build +cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 +make -j$(nproc) +make install -echo "Building Log4Qt (QT_ROOT=${QT_ROOT})..." +# Patch installed headers for C++17 compatibility +# Fix 1: Replace C++20 spaceship operator with traditional comparison operators in level.h +# Uses mValue (the actual member variable) instead of mLevel +sed -i 's/\[\[nodiscard\]\] constexpr auto operator<=>(const Level\& other) const noexcept = default;/bool operator<(const Level\& other) const noexcept { return mValue < other.mValue; }\n bool operator<=(const Level\& other) const noexcept { return mValue <= other.mValue; }\n bool operator>(const Level\& other) const noexcept { return mValue > other.mValue; }\n bool operator>=(const Level\& other) const noexcept { return mValue >= other.mValue; }\n bool operator==(const Level\& other) const noexcept { return mValue == other.mValue; }/' /usr/local/include/log4qt/level.h -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT +# Fix 2: Ensure mThreshold.load() is used in appenderskeleton.h +sed -i 's/return (mThreshold <= level)/return (mThreshold.load() <= level)/g' /usr/local/include/log4qt/appenderskeleton.h -cd "$TMPDIR" -if ! git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt; then - echo "Warning: failed to clone Log4Qt from github. Exiting build." >&2 - exit 0 -fi - -mkdir -p log4qt/build -cd log4qt/build -cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_CXX_STANDARD=20 \ - -DCMAKE_CXX_EXTENSIONS=OFF \ - -DCMAKE_PREFIX_PATH="${QT_ROOT}" \ - -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" .. - -cmake --build . -- -j$(nproc) || true -cmake --install . || true - -# Create minimal CMake config so find_package(Log4Qt) will work -mkdir -p "${INSTALL_PREFIX}/lib/cmake/Log4Qt" -libpath=$((ls "${INSTALL_PREFIX}/lib/libLog4Qt.so"* 2>/dev/null || ls "${INSTALL_PREFIX}/lib/liblog4qt.so"* 2>/dev/null) | head -n1 || true) -if [ -n "$libpath" ]; then - cat > "${INSTALL_PREFIX}/lib/cmake/Log4Qt/Log4QtConfig.cmake" <