284 lines
13 KiB
TOML
284 lines
13 KiB
TOML
#TODO: Qt6 QML/QtQuick — cross-compiled for Redox. Needs qtbase with Wayland.
|
|
# Provides: libQt6Qml, libQt6Quick, libQt6QuickWidgets, libQt6QmlModels, etc.
|
|
# Also builds QML host tools (qmlcachegen, qmllint) for cross-compilation.
|
|
[source]
|
|
tar = "https://download.qt.io/official_releases/qt/6.11/6.11.0/submodules/qtdeclarative-everywhere-src-6.11.0.tar.xz"
|
|
|
|
[build]
|
|
template = "custom"
|
|
dependencies = [
|
|
"qtbase",
|
|
"qtshadertools",
|
|
"qtsvg",
|
|
]
|
|
script = """
|
|
DYNAMIC_INIT
|
|
|
|
HOST_BUILD="${COOKBOOK_ROOT}/build/qt-host-build"
|
|
DECL_HOST="${COOKBOOK_ROOT}/build/qt-declarative-host"
|
|
HOST_QTSVG_BUILD="${COOKBOOK_ROOT}/build/qtsvg-host-build"
|
|
source "${COOKBOOK_ROOT}/local/scripts/lib/qt-sysroot.sh"
|
|
source "${COOKBOOK_ROOT}/local/scripts/lib/qt-sysroot.sh"
|
|
|
|
# ============================================================
|
|
# Step 0: Build host qtsvg into the shared host prefix.
|
|
# quick-vectorimage in qtdeclarative requires host Qt::Svg support before
|
|
# svgtoqml / Qt6QuickTools can be generated and exported.
|
|
# ============================================================
|
|
if [ ! -d "${HOST_BUILD}/lib/cmake/Qt6Svg" ]; then
|
|
echo "=== Building qtsvg host module ==="
|
|
rm -rf "${HOST_QTSVG_BUILD}"
|
|
env \
|
|
-u CPPFLAGS \
|
|
-u LDFLAGS \
|
|
-u PKG_CONFIG_ALLOW_CROSS \
|
|
-u PKG_CONFIG_PATH \
|
|
-u PKG_CONFIG_LIBDIR \
|
|
-u PKG_CONFIG_SYSROOT_DIR \
|
|
-u CFLAGS_x86_64_unknown_redox \
|
|
-u CXXFLAGS_x86_64_unknown_redox \
|
|
-u LDFLAGS_x86_64_unknown_redox \
|
|
cmake -S "${COOKBOOK_ROOT}/recipes/wip/qt/qtsvg/source" -B "${HOST_QTSVG_BUILD}" \
|
|
-DCMAKE_C_COMPILER=/usr/bin/cc \
|
|
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="${HOST_BUILD}" \
|
|
-DCMAKE_PREFIX_PATH="${HOST_BUILD}" \
|
|
-DQT_BUILD_EXAMPLES=OFF \
|
|
-DQT_BUILD_TESTS=OFF \
|
|
-DQT_GENERATE_SBOM=OFF \
|
|
-Wno-dev
|
|
cmake --build "${HOST_QTSVG_BUILD}" -j"${COOKBOOK_MAKE_JOBS}"
|
|
cmake --install "${HOST_QTSVG_BUILD}" --prefix "${HOST_BUILD}"
|
|
fi
|
|
|
|
# ============================================================
|
|
# Step 1: Build only the qtdeclarative host tools actually needed for cross-builds.
|
|
# We intentionally avoid building the full host tool surface (`qml`, quicktooling, etc.)
|
|
# because the shared host prefix is not a full host QtGui install.
|
|
# Install/copy the minimal host tools into the same prefix as qtbase host tools so
|
|
# QT_HOST_PATH finds both qtbase and qtdeclarative tools.
|
|
# ============================================================
|
|
if [ ! -f "${HOST_BUILD}/bin/qmlcachegen" ] || [ ! -f "${HOST_BUILD}/bin/qmlaotstats" ] || [ ! -d "${HOST_BUILD}/lib/cmake/Qt6QmlTools" ] || [ ! -d "${HOST_BUILD}/lib/cmake/Qt6QuickTools" ] || { [ ! -f "${HOST_BUILD}/bin/svgtoqml" ] && [ ! -f "${HOST_BUILD}/libexec/svgtoqml" ]; }; then
|
|
echo "=== Building qtdeclarative host tools ==="
|
|
mkdir -p "${DECL_HOST}"
|
|
env \
|
|
-u CPPFLAGS \
|
|
-u LDFLAGS \
|
|
-u PKG_CONFIG_ALLOW_CROSS \
|
|
-u PKG_CONFIG_PATH \
|
|
-u PKG_CONFIG_LIBDIR \
|
|
-u PKG_CONFIG_SYSROOT_DIR \
|
|
-u CFLAGS_x86_64_unknown_redox \
|
|
-u CXXFLAGS_x86_64_unknown_redox \
|
|
-u LDFLAGS_x86_64_unknown_redox \
|
|
cmake -S "${COOKBOOK_SOURCE}" -B "${DECL_HOST}" \
|
|
-DCMAKE_C_COMPILER=/usr/bin/cc \
|
|
-DCMAKE_CXX_COMPILER=/usr/bin/c++ \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="${HOST_BUILD}" \
|
|
-DCMAKE_PREFIX_PATH="${HOST_BUILD}" \
|
|
-DQt6ShaderToolsTools_DIR="${HOST_BUILD}/lib/cmake/Qt6ShaderToolsTools" \
|
|
-DQT_BUILD_EXAMPLES=OFF \
|
|
-DQT_BUILD_TESTS=OFF \
|
|
-DQT_GENERATE_SBOM=OFF \
|
|
-Wno-dev
|
|
cmake --build "${DECL_HOST}" --target qmllint qmlimportscanner qmltyperegistrar qmlaotstats svgtoqml -j"${COOKBOOK_MAKE_JOBS}" || true
|
|
# Generate jsroot.qmltypes needed by qmlcachegen using the host-built qmltyperegistrar.
|
|
# Qt6 CMake rule: qmltyperegistrar --jsroot --generate-qmltypes <output>
|
|
QMLREG="${DECL_HOST}/libexec/qmltyperegistrar"
|
|
QML_BUILD_DIR="${DECL_HOST}/qml/QML"
|
|
if [ -x "${QMLREG}" ]; then
|
|
mkdir -p "${QML_BUILD_DIR}"
|
|
"${QMLREG}" --jsroot --generate-qmltypes "${QML_BUILD_DIR}/jsroot.qmltypes" || \
|
|
touch "${QML_BUILD_DIR}/jsroot.qmltypes"
|
|
# Also generate plugins.qmltypes (needed by builtins.qmltypes)
|
|
touch "${QML_BUILD_DIR}/plugins.qmltypes"
|
|
mkdir -p "${DECL_HOST}/qml"
|
|
cp "${QML_BUILD_DIR}/jsroot.qmltypes" "${DECL_HOST}/qml/jsroot.qmltypes" 2>/dev/null || true
|
|
else
|
|
mkdir -p "${QML_BUILD_DIR}"
|
|
touch "${QML_BUILD_DIR}/jsroot.qmltypes"
|
|
fi
|
|
cmake --build "${DECL_HOST}" --target qmlcachegen -j"${COOKBOOK_MAKE_JOBS}" 2>/dev/null || echo "qmlcachegen skipped"
|
|
# Fix qmlcachegen RPATH so it loads host Qt6 libs, not cross-compiled sysroot ones
|
|
if [ -f "${DECL_HOST}/libexec/qmlcachegen" ]; then
|
|
patchelf --set-rpath '$ORIGIN/../lib:$ORIGIN/../../qt-host-build/lib' \
|
|
"${DECL_HOST}/libexec/qmlcachegen" 2>/dev/null || true
|
|
fi
|
|
|
|
mkdir -p "${HOST_BUILD}/bin" "${HOST_BUILD}/libexec" "${HOST_BUILD}/lib/cmake"
|
|
for tool in qmlcachegen qmllint qmlimportscanner qmltyperegistrar qmlaotstats svgtoqml; do
|
|
if [ -f "${DECL_HOST}/bin/${tool}" ]; then
|
|
cp -a "${DECL_HOST}/bin/${tool}" "${HOST_BUILD}/bin/"
|
|
elif [ -f "${DECL_HOST}/libexec/${tool}" ]; then
|
|
cp -a "${DECL_HOST}/libexec/${tool}" "${HOST_BUILD}/libexec/"
|
|
cp -a "${DECL_HOST}/libexec/${tool}" "${HOST_BUILD}/bin/${tool}"
|
|
fi
|
|
done
|
|
cp -a "${DECL_HOST}/lib/cmake/Qt6QmlTools" "${HOST_BUILD}/lib/cmake/" 2>/dev/null || true
|
|
cp -a "${DECL_HOST}/lib/cmake/Qt6QmlCompiler" "${HOST_BUILD}/lib/cmake/" 2>/dev/null || true
|
|
cp -a "${DECL_HOST}/lib/cmake/Qt6QuickTools" "${HOST_BUILD}/lib/cmake/" 2>/dev/null || true
|
|
fi
|
|
|
|
# ============================================================
|
|
# Step 2: Cross-compile qtdeclarative for Redox
|
|
# ============================================================
|
|
rm -f CMakeCache.txt
|
|
rm -rf CMakeFiles
|
|
|
|
redbear_qt_link_sysroot_dirs "${COOKBOOK_SYSROOT}" plugins mkspecs metatypes modules
|
|
|
|
# Patch masm/CheckedArithmetic.h: add missing ArithmeticOperations<unsigned, long>
|
|
# specialization for LP64 (sizeof(long) != sizeof(int)). The existing code only
|
|
# handles <unsigned, int> but GCC instantiates <unsigned, long> on x86_64.
|
|
CHECKED="${COOKBOOK_SOURCE}/src/3rdparty/masm/wtf/CheckedArithmetic.h"
|
|
if ! grep -q 'ArithmeticOperations<unsigned, long, ResultType, false, true>' "${CHECKED}" 2>/dev/null; then
|
|
PATCHF="${COOKBOOK_BUILD}/arithm_patch.h"
|
|
mkdir -p "${COOKBOOK_BUILD}"
|
|
printf '%s\n' \
|
|
"template <typename ResultType> struct ArithmeticOperations<unsigned, long, ResultType, false, true> {" \
|
|
" static inline bool add(unsigned lhs, long rhs, ResultType& result) WARN_UNUSED_RETURN" \
|
|
" {" \
|
|
" int64_t temp = static_cast<int64_t>(lhs) + static_cast<int64_t>(rhs);" \
|
|
" if (temp < std::numeric_limits<ResultType>::min()) return false;" \
|
|
" if (temp > std::numeric_limits<ResultType>::max()) return false;" \
|
|
" result = static_cast<ResultType>(temp);" \
|
|
" return true;" \
|
|
" }" \
|
|
" static inline bool sub(unsigned lhs, long rhs, ResultType& result) WARN_UNUSED_RETURN" \
|
|
" {" \
|
|
" int64_t temp = static_cast<int64_t>(lhs) - static_cast<int64_t>(rhs);" \
|
|
" if (temp < std::numeric_limits<ResultType>::min()) return false;" \
|
|
" if (temp > std::numeric_limits<ResultType>::max()) return false;" \
|
|
" result = static_cast<ResultType>(temp);" \
|
|
" return true;" \
|
|
" }" \
|
|
" static inline bool multiply(unsigned lhs, long rhs, ResultType& result) WARN_UNUSED_RETURN" \
|
|
" {" \
|
|
" int64_t temp = static_cast<int64_t>(lhs) * static_cast<int64_t>(rhs);" \
|
|
" if (temp < std::numeric_limits<ResultType>::min()) return false;" \
|
|
" if (temp > std::numeric_limits<ResultType>::max()) return false;" \
|
|
" result = static_cast<ResultType>(temp);" \
|
|
" return true;" \
|
|
" }" \
|
|
" static inline bool equals(unsigned lhs, long rhs)" \
|
|
" {" \
|
|
" return static_cast<int64_t>(lhs) == static_cast<int64_t>(rhs);" \
|
|
" }" \
|
|
"};" > "${PATCHF}"
|
|
LINE=$(grep -n "ArithmeticOperations<int, unsigned, ResultType>::equals" "${CHECKED}" | head -1 | cut -d: -f1)
|
|
INSERT=$((LINE + 3))
|
|
sed -i "${INSERT}r ${PATCHF}" "${CHECKED}"
|
|
fi
|
|
|
|
python - <<'PY'
|
|
import os
|
|
from pathlib import Path
|
|
path = Path(os.environ["COOKBOOK_SOURCE"]) / "src/CMakeLists.txt"
|
|
text = path.read_text()
|
|
text = text.replace('if(TARGET Qt::Gui AND TARGET Qt::qsb AND QT_FEATURE_qml_animation)', 'if(TARGET Qt::Gui AND QT_FEATURE_qml_animation)')
|
|
path.write_text(text)
|
|
PY
|
|
|
|
cat > "${COOKBOOK_BUILD}/shader_stub.cmake" << 'EOFCMAKE'
|
|
function(qt_internal_add_shaders target name)
|
|
endfunction()
|
|
function(qt_internal_add_shader_helpers target name)
|
|
endfunction()
|
|
EOFCMAKE
|
|
|
|
cmake "${COOKBOOK_SOURCE}" \
|
|
-C "${COOKBOOK_BUILD}/shader_stub.cmake" \
|
|
-DCMAKE_TOOLCHAIN_FILE="${COOKBOOK_ROOT}/local/recipes/qt/redox-toolchain.cmake" \
|
|
-DQT_HOST_PATH="${HOST_BUILD}" \
|
|
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_PREFIX_PATH="${COOKBOOK_SYSROOT}" \
|
|
-DQt6ShaderToolsTools_DIR="${HOST_BUILD}/lib/cmake/Qt6ShaderToolsTools" \
|
|
-DQT_BUILD_EXAMPLES=OFF \
|
|
-DQT_BUILD_TESTS=OFF \
|
|
-DQT_GENERATE_SBOM=OFF \
|
|
-DQT_FEATURE_qml_jit=OFF \
|
|
-DQT_FEATURE_ssl=OFF \
|
|
-DQT_FEATURE_network=OFF \
|
|
-DQT_FEATURE_localserver=OFF \
|
|
-DQT_FEATURE_http=OFF \
|
|
-DQT_FEATURE_udpsocket=OFF \
|
|
-DQT_FEATURE_dnslookup=OFF \
|
|
-DQT_FEATURE_networkinterface=OFF \
|
|
-DQT_FEATURE_networkproxy=OFF \
|
|
-DQT_FEATURE_socks5=OFF \
|
|
-DQT_FEATURE_networkdiskcache=OFF \
|
|
-Wno-dev
|
|
|
|
HOST_QT6_LIBS="${DECL_HOST}/lib:${HOST_BUILD}/lib"
|
|
export LD_LIBRARY_PATH="${HOST_QT6_LIBS}:${LD_LIBRARY_PATH:-}"
|
|
cmake --build . --target Qml Quick QuickWidgets QmlModels QmlWorkerScript QmlIntegration LabsSettings QuickControls2 QuickTemplates2 QuickVectorImageGeneratorPrivate QuickVectorImage QuickVectorImageHelpers -j${COOKBOOK_MAKE_JOBS}
|
|
cmake --build . -j${COOKBOOK_MAKE_JOBS} 2>/dev/null || echo "Some targets failed (tools/qml expected)"
|
|
|
|
# ============================================================
|
|
# Step 3: Stage everything
|
|
# ============================================================
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/lib"
|
|
for lib in lib/libQt6*.so*; do
|
|
[ -f "${lib}" ] && cp -a "${lib}" "${COOKBOOK_STAGE}/usr/lib/"
|
|
done
|
|
for lib in lib/libQt6*.a; do
|
|
[ -f "${lib}" ] && cp -a "${lib}" "${COOKBOOK_STAGE}/usr/lib/"
|
|
done
|
|
|
|
if [ -d "lib/cmake" ]; then
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/lib/cmake"
|
|
cp -a lib/cmake/Qt6* "${COOKBOOK_STAGE}/usr/lib/cmake/" 2>/dev/null || true
|
|
fi
|
|
if [ -d "lib/pkgconfig" ]; then
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/lib/pkgconfig"
|
|
cp -a lib/pkgconfig/*.pc "${COOKBOOK_STAGE}/usr/lib/pkgconfig/" 2>/dev/null || true
|
|
fi
|
|
if [ -d "include" ]; then
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/include"
|
|
cp -a include/* "${COOKBOOK_STAGE}/usr/include/" 2>/dev/null || true
|
|
fi
|
|
if [ -d "plugins" ]; then
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/plugins"
|
|
cp -a plugins/* "${COOKBOOK_STAGE}/usr/plugins/" 2>/dev/null || true
|
|
fi
|
|
if [ -d "qml" ]; then
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/qml"
|
|
cp -a qml/* "${COOKBOOK_STAGE}/usr/qml/" 2>/dev/null || true
|
|
fi
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/metatypes"
|
|
find . -path '*/meta_types/*.json' -type f -exec cp -an {} "${COOKBOOK_STAGE}/usr/metatypes/" \\; 2>/dev/null || true
|
|
|
|
# RPATH cleanup
|
|
for lib in "${COOKBOOK_STAGE}/usr/lib/libQt6"*.so.*; do
|
|
[ -f "${lib}" ] || continue
|
|
patchelf --remove-rpath "${lib}" 2>/dev/null || true
|
|
done
|
|
find "${COOKBOOK_STAGE}/usr/plugins" -name '*.so' -exec patchelf --remove-rpath {} + 2>/dev/null || true
|
|
|
|
# CMake export fixup and sysroot propagation
|
|
BUILD_DIR="${COOKBOOK_BUILD}"
|
|
STAGE_USR="${COOKBOOK_STAGE}/usr"
|
|
STAGE_CMAKE_DIR="${STAGE_USR}/lib/cmake"
|
|
SYSROOT="${COOKBOOK_SYSROOT}"
|
|
redbear_qt_rewrite_stage_build_paths "${STAGE_USR}" "${BUILD_DIR}"
|
|
redbear_qt_rewrite_stage_include_paths "${STAGE_CMAKE_DIR}" "${SYSROOT}"
|
|
redbear_qt_rewrite_stage_lib_paths "${STAGE_CMAKE_DIR}" "${SYSROOT}"
|
|
redbear_qt_rewrite_stage_source_metatype_paths "${STAGE_CMAKE_DIR}" "${SYSROOT}" "${COOKBOOK_SOURCE}"
|
|
redbear_qt_copy_common_stage_to_sysroot "${STAGE_USR}" "${SYSROOT}"
|
|
redbear_qt_copy_stage_qt6_cmake_to_sysroot "${STAGE_USR}" "${SYSROOT}"
|
|
redbear_qt_copy_optional_stage_dir_to_sysroot "${STAGE_USR}" "${SYSROOT}" metatypes
|
|
redbear_qt_copy_optional_stage_dir_to_sysroot "${STAGE_USR}" "${SYSROOT}" plugins
|
|
redbear_qt_copy_optional_stage_dir_to_sysroot "${STAGE_USR}" "${SYSROOT}" qml
|
|
|
|
for stdlib in \
|
|
"${COOKBOOK_STAGE}/usr/include/stdlib.h" \
|
|
"${SYSROOT}/include/stdlib.h" \
|
|
"${SYSROOT}/usr/include/stdlib.h"; do
|
|
[ -f "$stdlib" ] || continue
|
|
sed -i '/strtold[[:space:]]*(/d' "$stdlib" 2>/dev/null || true
|
|
done
|
|
"""
|