summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2024-02-08 09:09:10 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-20 09:18:42 +0000
commit2b81e83e6a055d1bd01c1e0013a19036383f7ce7 (patch)
treeb27d267b1e081c59cfac9f0bcd34e41608b4274a
parent40ba380a188df50c2af438777d0d13e276c3cd82 (diff)
scanner: Make it work with mismatching protocol and file name
The names of the files that wayland-scanner generates are based on the protocol file name not the protocol name that is defined in the xml. When those two mismatch qtwaylandscanner would generate code that fails to build. Change-Id: Ieecd7a122177530ab1ff890367ce53809a8bb7b9 Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 90d91fe626a378fbeda43a9f97f1b1f0d8eb920a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 1b0a4a149..e70ad21db 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -3,6 +3,7 @@
#include <QCoreApplication>
#include <QFile>
+#include <QFileInfo>
#include <QXmlStreamReader>
#include <vector>
@@ -422,6 +423,8 @@ bool Scanner::process()
//QByteArray preProcessorProtocolName = QByteArray(m_protocolName).replace('-', '_').toUpper();
QByteArray preProcessorProtocolName = QByteArray(m_protocolName).toUpper();
+ const QByteArray fileBaseName = QFileInfo(file).completeBaseName().toLocal8Bit();
+
std::vector<WaylandInterface> interfaces;
while (m_xml->readNextStartElement()) {
@@ -467,9 +470,9 @@ bool Scanner::process()
printf("\n");
printf("#include \"wayland-server-core.h\"\n");
if (m_headerPath.isEmpty())
- printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"wayland-%s-server-protocol.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-server-protocol.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("#include <QByteArray>\n");
printf("#include <QMultiMap>\n");
printf("#include <QString>\n");
@@ -632,9 +635,9 @@ bool Scanner::process()
if (m_option == ServerCode) {
if (m_headerPath.isEmpty())
- printf("#include \"qwayland-server-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"qwayland-server-%s.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-server-%s.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");
@@ -962,9 +965,9 @@ bool Scanner::process()
printf("#define %s\n", inclusionGuard.constData());
printf("\n");
if (m_headerPath.isEmpty())
- printf("#include \"wayland-%s-client-protocol.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"wayland-%s-client-protocol.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/wayland-%s-client-protocol.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("#include <QByteArray>\n");
printf("#include <QString>\n");
printf("\n");
@@ -1074,9 +1077,9 @@ bool Scanner::process()
if (m_option == ClientCode) {
if (m_headerPath.isEmpty())
- printf("#include \"qwayland-%s.h\"\n", QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include \"qwayland-%s.h\"\n", fileBaseName.constData());
else
- printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), QByteArray(m_protocolName).replace('_', '-').constData());
+ printf("#include <%s/qwayland-%s.h>\n", m_headerPath.constData(), fileBaseName.constData());
printf("\n");
printf("QT_BEGIN_NAMESPACE\n");
printf("QT_WARNING_PUSH\n");