352bc9340f
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
261 lines
7.7 KiB
TOML
261 lines
7.7 KiB
TOML
#TODO: Qt6 SerialPort module — cross-compiled for Redox, but runtime validation against real serial devices is still pending.
|
|
# Provides: libQt6SerialPort and CMake/pkg-config metadata for downstream Qt serial consumers.
|
|
|
|
[source]
|
|
tar = "https://download.qt.io/official_releases/qt/6.11/6.11.0/submodules/qtserialport-everywhere-src-6.11.0.tar.xz"
|
|
|
|
[build]
|
|
template = "custom"
|
|
dependencies = [
|
|
"qtbase",
|
|
]
|
|
script = """
|
|
DYNAMIC_INIT
|
|
|
|
HOST_BUILD="${COOKBOOK_ROOT}/build/qt-host-build"
|
|
|
|
python - <<'PY'
|
|
import os
|
|
from pathlib import Path
|
|
path = Path(os.environ["COOKBOOK_SOURCE"]) / "src/serialport/qserialport_unix.cpp"
|
|
text = path.read_text()
|
|
text = text.replace(
|
|
'''static inline void qt_set_flowcontrol(termios *tio, QSerialPort::FlowControl flowcontrol)
|
|
{
|
|
switch (flowcontrol) {
|
|
case QSerialPort::NoFlowControl:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
case QSerialPort::HardwareControl:
|
|
tio->c_cflag |= CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
case QSerialPort::SoftwareControl:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag |= IXON | IXOFF | IXANY;
|
|
break;
|
|
default:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
}
|
|
}
|
|
''',
|
|
'''static inline void qt_set_flowcontrol(termios *tio, QSerialPort::FlowControl flowcontrol)
|
|
{
|
|
#ifdef CRTSCTS
|
|
switch (flowcontrol) {
|
|
case QSerialPort::NoFlowControl:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
case QSerialPort::HardwareControl:
|
|
tio->c_cflag |= CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
case QSerialPort::SoftwareControl:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag |= IXON | IXOFF | IXANY;
|
|
break;
|
|
default:
|
|
tio->c_cflag &= ~CRTSCTS;
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
break;
|
|
}
|
|
#else
|
|
Q_UNUSED(flowcontrol);
|
|
tio->c_iflag &= ~(IXON | IXOFF | IXANY);
|
|
#endif
|
|
}
|
|
''')
|
|
text = text.replace(
|
|
'''QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals()
|
|
{
|
|
int arg = 0;
|
|
|
|
if (::ioctl(descriptor, TIOCMGET, &arg) == -1) {
|
|
setError(getSystemError());
|
|
return QSerialPort::NoSignal;
|
|
}
|
|
''',
|
|
'''QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals()
|
|
{
|
|
#ifndef TIOCMGET
|
|
setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
|
|
QSerialPort::tr("Pinout signal query is not supported on this platform")));
|
|
return QSerialPort::NoSignal;
|
|
#else
|
|
int arg = 0;
|
|
|
|
if (::ioctl(descriptor, TIOCMGET, &arg) == -1) {
|
|
setError(getSystemError());
|
|
return QSerialPort::NoSignal;
|
|
}
|
|
#endif
|
|
''')
|
|
text = text.replace(
|
|
'''bool QSerialPortPrivate::setDataTerminalReady(bool set)
|
|
{
|
|
int status = TIOCM_DTR;
|
|
if (::ioctl(descriptor, set ? TIOCMBIS : TIOCMBIC, &status) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
''',
|
|
'''bool QSerialPortPrivate::setDataTerminalReady(bool set)
|
|
{
|
|
#if !defined(TIOCM_DTR) || !defined(TIOCMBIS) || !defined(TIOCMBIC)
|
|
Q_UNUSED(set);
|
|
setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
|
|
QSerialPort::tr("Data terminal ready is not supported on this platform")));
|
|
return false;
|
|
#else
|
|
int status = TIOCM_DTR;
|
|
if (::ioctl(descriptor, set ? TIOCMBIS : TIOCMBIC, &status) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
#endif
|
|
}
|
|
''')
|
|
text = text.replace(
|
|
'''bool QSerialPortPrivate::setRequestToSend(bool set)
|
|
{
|
|
int status = TIOCM_RTS;
|
|
if (::ioctl(descriptor, set ? TIOCMBIS : TIOCMBIC, &status) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
''',
|
|
'''bool QSerialPortPrivate::setRequestToSend(bool set)
|
|
{
|
|
#if !defined(TIOCM_RTS) || !defined(TIOCMBIS) || !defined(TIOCMBIC)
|
|
Q_UNUSED(set);
|
|
setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
|
|
QSerialPort::tr("Request-to-send is not supported on this platform")));
|
|
return false;
|
|
#else
|
|
int status = TIOCM_RTS;
|
|
if (::ioctl(descriptor, set ? TIOCMBIS : TIOCMBIC, &status) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
#endif
|
|
}
|
|
''')
|
|
text = text.replace(
|
|
'''bool QSerialPortPrivate::setBreakEnabled(bool set)
|
|
{
|
|
if (::ioctl(descriptor, set ? TIOCSBRK : TIOCCBRK) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
''',
|
|
'''bool QSerialPortPrivate::setBreakEnabled(bool set)
|
|
{
|
|
#if !defined(TIOCSBRK) || !defined(TIOCCBRK)
|
|
Q_UNUSED(set);
|
|
setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
|
|
QSerialPort::tr("Break signaling is not supported on this platform")));
|
|
return false;
|
|
#else
|
|
if (::ioctl(descriptor, set ? TIOCSBRK : TIOCCBRK) == -1) {
|
|
setError(getSystemError());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
#endif
|
|
}
|
|
''')
|
|
path.write_text(text)
|
|
PY
|
|
|
|
# Sysroot path fix: same as other Qt6 modules — cookbook only symlinks
|
|
# sysroot/{bin,include,lib,share} but Qt6 cmake targets reference
|
|
# ${_IMPORT_PREFIX}/{plugins,mkspecs,metatypes,modules}.
|
|
for qtdir in plugins mkspecs metatypes modules; do
|
|
if [ -d "${COOKBOOK_SYSROOT}/usr/${qtdir}" ] && [ ! -e "${COOKBOOK_SYSROOT}/${qtdir}" ]; then
|
|
ln -s "usr/${qtdir}" "${COOKBOOK_SYSROOT}/${qtdir}"
|
|
fi
|
|
done
|
|
|
|
rm -f CMakeCache.txt
|
|
rm -rf CMakeFiles
|
|
|
|
cmake "${COOKBOOK_SOURCE}" \
|
|
-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}" \
|
|
-DQT_BUILD_EXAMPLES=OFF \
|
|
-DQT_BUILD_TESTS=OFF \
|
|
-DQT_GENERATE_SBOM=OFF \
|
|
-Wno-dev
|
|
|
|
cmake --build . -j${COOKBOOK_MAKE_JOBS}
|
|
|
|
cmake --install . --prefix "${COOKBOOK_STAGE}/usr"
|
|
|
|
mkdir -p "${COOKBOOK_STAGE}/usr/lib"
|
|
for lib in lib/libQt6*.so*; do
|
|
[ -f "${lib}" ] && cp -an "${lib}" "${COOKBOOK_STAGE}/usr/lib/"
|
|
done
|
|
for lib in lib/libQt6*.a; do
|
|
[ -f "${lib}" ] && cp -an "${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
|
|
|
|
for lib in "${COOKBOOK_STAGE}/usr/lib/libQt6"*.so.*; do
|
|
[ -f "${lib}" ] || continue
|
|
patchelf --remove-rpath "${lib}" 2>/dev/null || true
|
|
done
|
|
|
|
BUILD_DIR="${COOKBOOK_BUILD}"
|
|
if [ -d "${COOKBOOK_STAGE}/usr/lib/cmake" ]; then
|
|
find "${COOKBOOK_STAGE}/usr/lib/cmake" -name '*.cmake' -exec sed -i \
|
|
"s|${BUILD_DIR}|/usr|g" {} + 2>/dev/null || true
|
|
fi
|
|
|
|
SYSROOT="${COOKBOOK_SYSROOT}"
|
|
if [ -d "${COOKBOOK_STAGE}/usr/include" ]; then
|
|
mkdir -p "${SYSROOT}/include"
|
|
cp -a "${COOKBOOK_STAGE}/usr/include/"* "${SYSROOT}/include/" 2>/dev/null || true
|
|
fi
|
|
if [ -d "${COOKBOOK_STAGE}/usr/lib/cmake/Qt6SerialPort" ]; then
|
|
find "${COOKBOOK_STAGE}/usr/lib/cmake/Qt6SerialPort" -name '*.cmake' -exec sed -i \
|
|
"s|/usr/include|${SYSROOT}/include|g" {} + 2>/dev/null || true
|
|
mkdir -p "${SYSROOT}/lib/cmake/Qt6SerialPort"
|
|
cp -a "${COOKBOOK_STAGE}/usr/lib/cmake/Qt6SerialPort/"* "${SYSROOT}/lib/cmake/Qt6SerialPort/" 2>/dev/null || true
|
|
fi
|
|
mkdir -p "${SYSROOT}/lib"
|
|
cp -a "${COOKBOOK_STAGE}/usr/lib/libQt6"* "${SYSROOT}/lib/" 2>/dev/null || true
|
|
"""
|