1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 06:38:10 +00:00

Ports/qt6: Add a very basic Qt6 Base package

It's necessary to have a working serenity platform plugin for it to work
with GUI applications
This commit is contained in:
Martin Bříza 2021-08-12 19:40:25 +02:00 committed by Linus Groh
parent 41ea37f25a
commit ac762c5520
7 changed files with 425 additions and 0 deletions

View file

@ -149,6 +149,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
| [`pt2-clone`](pt2-clone/) | ProTracker 2 clone | 1.28 | https://github.com/8bitbubsy/pt2-clone |
| [`pv`](pv/) | Pipe Viewer | 1.6.20 | http://www.ivarch.com/programs/pv.shtml |
| [`python3`](python3/) | Python | 3.10.1 | https://www.python.org/ |
| [`qt6-qtbase`](qt6-qtbase/) | Qt6 QtBase | 6.2.2 | https://qt.io |
| [`quake`](quake/) | Quake | 0.65 | https://github.com/SerenityOS/SerenityQuake |
| [`quake2`](quake2/) | QuakeII | 0.1 | https://github.com/SerenityOS/SerenityQuakeII |
| [`r0`](r0/) | r0 (minimalistic commandline hexadecimal editor) | 0.8 | https://github.com/radareorg/r0 |

62
Ports/qt6-qtbase/package.sh Executable file
View file

@ -0,0 +1,62 @@
#!/usr/bin/env -S bash ../.port_include.sh
port=qt6-qtbase
version=6.2.2
workdir=qtbase-everywhere-src-${version}
useconfigure=true
files="https://download.qt.io/official_releases/qt/$(cut -d. -f1,2 <<< ${version})/${version}/submodules/qtbase-everywhere-src-${version}.tar.xz qt6-qtbase-${version}.tar.xz 85ab9180180c2eaf84cd11ae4c6d5a6a69f2f8fd7260aaccfd91a3e7e7232c1a"
auth_type="sha256"
configopts=(
"-GNinja"
"-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt"
"-DCMAKE_CROSSCOMPILING=ON"
"-DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON"
"-DQT_HOST_PATH=/usr"
"-DQT_FEATURE_cxx20=ON"
"-DINPUT_opengl=no"
)
QT_HOST_PATH=/usr
QT_HOST_CMAKE_PATH=${QT_HOST_PATH}/lib64/cmake
QT_HOST_TOOLS="HostInfo CoreTools GuiTools WidgetsTools"
QT_HOST_TOOLS_PATH="${QT_HOST_CMAKE_PATH}/Qt6%s/\n"
QT_DISABLED_FEATURES="sql opengl dbus systemsemaphore sharedmemory thread network"
configure() {
for host_tool in ${QT_HOST_TOOLS}; do
if [[ ! -d $(printf $QT_HOST_TOOLS_PATH $host_tool) ]]; then
echo "You need to have Qt $version installed on the host (path "$(printf $QT_HOST_TOOLS_PATH $host_tool)" is missing)"
exit 1
fi
done
MERGED_HOST_TOOLS=$(for host_tool in ${QT_HOST_TOOLS}; do echo "-DQt6${host_tool}_DIR=${QT_HOST_CMAKE_PATH}/Qt6${host_tool}/"; done)
MERGED_DISABLED_FEATURES=$(for feature in ${QT_DISABLED_FEATURES}; do echo "-DQT_FEATURE_${feature}=OFF"; done)
run cmake ${configopts[@]} ${MERGED_HOST_TOOLS} ${MERGED_DISABLED_FEATURES}
}
build() {
run ninja
}
install() {
run ninja install
echo "================================================================================"
echo "| NOTICE |"
echo "================================================================================"
echo -e "You have just installed a testing build of Qt $version.\n"
echo -e "GUI applications won't work without QSerenityPlatform!"
echo -e "\t" "It's packaged as qt6-serenity"
echo "The following Qt modules are disabled for now:"
echo -e "\t" "$QT_DISABLED_FEATURES"
echo "Work on enabling Qt modules will be happening here:"
echo -e "\t" "https://github.com/SerenityOS/serenity/tree/master/Ports/qt6-qtbase"
echo "The development of the Qt Serenity platform plugin is happening here. Fixes for things like input handling, window management and theme integration should go here:"
echo -e "\t" "https://github.com/SerenityPorts/QSerenityPlatform"
}
clean() {
run ninja clean
}

View file

@ -0,0 +1,202 @@
From 168040b44c185772fe6d24eb017e6fc6366fadb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20B=C5=99=C3=ADza?= <m@rtinbriza.cz>
Date: Wed, 15 Dec 2021 20:01:43 +0100
Subject: [PATCH 1/5] Add a SerenityOS platform definition
---
cmake/QtBuild.cmake | 2 +
mkspecs/serenity-g++/qmake.conf | 25 ++++++++
mkspecs/serenity-g++/qplatformdefs.h | 88 +++++++++++++++++++++++++++
src/corelib/global/qsystemdetection.h | 3 +
src/gui/CMakeLists.txt | 2 +
util/cmake/helper.py | 1 +
6 files changed, 121 insertions(+)
create mode 100644 mkspecs/serenity-g++/qmake.conf
create mode 100644 mkspecs/serenity-g++/qplatformdefs.h
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 7553b681..702ddf6f 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -321,6 +321,8 @@ elseif(APPLE)
set(QT_DEFAULT_MKSPEC macx-clang)
elseif(WASM)
set(QT_DEFAULT_MKSPEC wasm-emscripten)
+elseif(SERENITYOS)
+ set(QT_DEFAULT_MKSPEC serenity-g++)
elseif(QNX)
# Certain POSIX defines are not set if we don't compile with -std=gnuXX
set(QT_ENABLE_CXX_EXTENSIONS ON)
diff --git a/mkspecs/serenity-g++/qmake.conf b/mkspecs/serenity-g++/qmake.conf
new file mode 100644
index 00000000..00d5ae2c
--- /dev/null
+++ b/mkspecs/serenity-g++/qmake.conf
@@ -0,0 +1,25 @@
+#
+# qmake configuration for serenity-g++
+#
+
+MAKEFILE_GENERATOR = ninja
+QMAKE_PLATFORM = serenity
+
+include(../common/unix.conf)
+
+QMAKE_LIBS = -lpthread
+QMAKE_INCDIR =
+QMAKE_LIBDIR =
+
+QMAKE_LIBS_THREAD = -lpthread
+
+QMAKE_LIBS_NETWORK = -lnetwork
+QMAKE_LIBS_OPENGL = -lGL
+QMAKE_LIBS_OPENGL_QT = -lGL
+
+QMAKE_AR = ar cqs
+QMAKE_OBJCOPY = objcopy
+QMAKE_NM = nm -P
+QMAKE_RANLIB =
+
+load(qt_config)
diff --git a/mkspecs/serenity-g++/qplatformdefs.h b/mkspecs/serenity-g++/qplatformdefs.h
new file mode 100644
index 00000000..c054ddc5
--- /dev/null
+++ b/mkspecs/serenity-g++/qplatformdefs.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (c) 2021, the SerenityOS developers.
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMDEFS_H
+#define QPLATFORMDEFS_H
+
+// Get Qt defines/settings
+
+#define _GLIBCXX_HAVE_MBSTATE_T 1
+
+#include "qglobal.h"
+
+// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
+
+#include <unistd.h>
+
+#include <pthread.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <signal.h>
+#include <dlfcn.h>
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <netinet/in.h>
+
+#include "../common/posix/qplatformdefs.h"
+
+#ifdef QT_POSIX_IPC
+#define QT_POSIX_IPC 1
+//#undef QT_POSIX_IPC
+#endif
+
+#ifdef QT_OPEN_LARGEFILE
+#undef QT_OPEN_LARGEFILE
+#endif
+#define QT_OPEN_LARGEFILE 0
+
+#ifdef QT_LARGEFILE_SUPPORT
+#undef QT_LARGEFILE_SUPPORT
+#endif
+
+#include <langinfo.h>
+#include <sys/ioctl_numbers.h>
+
+#endif // QPLATFORMDEFS_H
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index c8f98042..5c534c4a 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -72,6 +72,7 @@
ANDROID - Android platform
HAIKU - Haiku
WEBOS - LG WebOS
+ SERENITY - SerenityOS
The following operating systems have variants:
LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android
@@ -165,6 +166,8 @@
# define Q_OS_VXWORKS
#elif defined(__HAIKU__)
# define Q_OS_HAIKU
+#elif defined(__serenity__)
+# define Q_OS_SERENITY
#elif defined(__MAKEDEPEND__)
#else
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 1e212b25..b12c8196 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -29,6 +29,8 @@ if (QT_FEATURE_gui)
set(_default_platform "haiku")
elseif(WASM)
set(_default_platform "wasm")
+ elseif(SERENITYOS)
+ set(_default_platform "serenity")
else()
set(_default_platform "xcb")
endif()
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index e55a9412..87260f36 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -767,6 +767,7 @@ platform_mapping = {
"macx": "MACOS",
"macos": "MACOS",
"macx-icc": "(MACOS AND ICC)",
+ "serenity": "SERENITY",
}
--
2.33.1

View file

@ -0,0 +1,62 @@
From f376d694af85f2f14de87f235d929895baa66fed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20B=C5=99=C3=ADza?= <m@rtinbriza.cz>
Date: Wed, 15 Dec 2021 19:38:27 +0100
Subject: [PATCH 3/5] Disable shared memory and semaphores
It's probably not done in the cleanest way but it works
---
mkspecs/serenity-g++/qplatformdefs.h | 3 +++
src/corelib/kernel/qsharedmemory_p.h | 3 ++-
src/corelib/kernel/qsystemsemaphore_p.h | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/mkspecs/serenity-g++/qplatformdefs.h b/mkspecs/serenity-g++/qplatformdefs.h
index c054ddc5..a5a759c0 100644
--- a/mkspecs/serenity-g++/qplatformdefs.h
+++ b/mkspecs/serenity-g++/qplatformdefs.h
@@ -44,6 +44,9 @@
#define _GLIBCXX_HAVE_MBSTATE_T 1
+#define QT_NO_SHAREDMEMORY 1
+#define QT_NO_SYSTEMSEMAPHORE 1
+
#include "qglobal.h"
// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index e06e7e86..7292782d 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include "qplatformdefs.h"
#include "qsharedmemory.h"
#include <QtCore/qstring.h>
@@ -78,7 +79,7 @@ QT_END_NAMESPACE
# include "private/qobject_p.h"
#endif
-#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_ANDROID) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_RTEMS) && !defined(Q_OS_SERENITY)
# include <sys/sem.h>
#endif
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index 56619d73..56cf8687 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include "qplatformdefs.h"
#include "qsystemsemaphore.h"
#ifndef QT_NO_SYSTEMSEMAPHORE
--
2.33.1

View file

@ -0,0 +1,25 @@
From a5935c4f1e954caa33a913cf999a468a02732d21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20B=C5=99=C3=ADza?= <m@rtinbriza.cz>
Date: Wed, 15 Dec 2021 19:49:43 +0100
Subject: [PATCH 4/5] Serenity doesn't support utimensat and UTIME_NOW
---
qmake/library/ioutils.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp
index 719d3b51..5490e823 100644
--- a/qmake/library/ioutils.cpp
+++ b/qmake/library/ioutils.cpp
@@ -262,7 +262,7 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF
*errorString = fL1S("Cannot stat() reference file %1: %2.").arg(referenceFileName, fL1S(strerror(errno)));
return false;
}
-# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
+# if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L && !defined(Q_OS_SERENITY)
const struct timespec times[2] = { { 0, UTIME_NOW }, st.st_mtim };
const bool utimeError = utimensat(AT_FDCWD, targetFileName.toLocal8Bit().constData(), times, 0) < 0;
# else
--
2.33.1

View file

@ -0,0 +1,32 @@
From c1809bf9fcbf7f4767f750057d08b723d1ad034b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20B=C5=99=C3=ADza?= <m@rtinbriza.cz>
Date: Wed, 15 Dec 2021 21:09:35 +0100
Subject: [PATCH 5/5] Hack: Force searching for plugins in /usr/local
I really don't know how else to do this but I'm sure there is a proper
way to handle this. But this works and doesn't break the system so
whatever for now.
---
src/corelib/kernel/qcoreapplication.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 3bce669b..ca9ca8b9 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2751,6 +2751,12 @@ QStringList QCoreApplication::libraryPathsLocked()
}
#endif // Q_OS_DARWIN
+#ifdef Q_OS_SERENITY
+ coreappdata()->app_libpaths->append("/usr/local");
+ coreappdata()->app_libpaths->append("/usr/local/lib");
+ coreappdata()->app_libpaths->append("/usr/local/plugins");
+#endif // Q_OS_SERENITY
+
QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
if (QFile::exists(installPathPlugins)) {
// Make sure we convert from backslashes to slashes.
--
2.33.1

View file

@ -0,0 +1,41 @@
From 830de469bab98268a328fc982c6d4f938e1547fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20B=C5=99=C3=ADza?= <m@rtinbriza.cz>
Date: Thu, 16 Dec 2021 12:47:31 +0100
Subject: [PATCH] Disable version tagging
This is necessary because as of now, Serenity doesn't support DT_VERSYM
and other related ELF objects
---
cmake/QtBuild.cmake | 2 ++
src/corelib/global/qversiontagging.cpp | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 702ddf6f..ff60a061 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -323,6 +323,8 @@ elseif(WASM)
set(QT_DEFAULT_MKSPEC wasm-emscripten)
elseif(SERENITYOS)
set(QT_DEFAULT_MKSPEC serenity-g++)
+ set(QT_DEFAULT_PLATFORM_DEFINITIONS QT_NO_VERSION_TAGGING=1)
+ set(HAVE_LD_VERSION_SCRIPT 0)
elseif(QNX)
# Certain POSIX defines are not set if we don't compile with -std=gnuXX
set(QT_ENABLE_CXX_EXTENSIONS ON)
diff --git a/src/corelib/global/qversiontagging.cpp b/src/corelib/global/qversiontagging.cpp
index b5e524bf..a7547a3b 100644
--- a/src/corelib/global/qversiontagging.cpp
+++ b/src/corelib/global/qversiontagging.cpp
@@ -42,7 +42,7 @@
#define SYM QT_MANGLE_NAMESPACE(qt_version_tag)
//#define SSYM QT_STRINGIFY(SYM)
-#if defined(Q_CC_GNU) && defined(Q_OF_ELF) && !defined(Q_OS_ANDROID)
+#if defined(Q_CC_GNU) && defined(Q_OF_ELF) && !defined(Q_OS_ANDROID) && !defined(QT_NO_VERSION_TAGGING)
# define make_versioned_symbol2(sym, m, n, separator) \
Q_CORE_EXPORT extern const char sym ## _ ## m ## _ ## n = 0; \
asm(".symver " QT_STRINGIFY(sym) "_" QT_STRINGIFY(m) "_" QT_STRINGIFY(n) ", " \
--
2.33.1