diff options
author | David Redondo <qt@david-redondo.de> | 2024-02-08 09:09:10 +0100 |
---|---|---|
committer | David Redondo <qt@david-redondo.de> | 2024-03-20 08:53:07 +0100 |
commit | 90d91fe626a378fbeda43a9f97f1b1f0d8eb920a (patch) | |
tree | e577f5c537abb98dc0561a5332212222fd7ab18c | |
parent | c71df3e33f267a279c5ac1e6905b0d1e0e92fb23 (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.
Pick-to: 6.7
Change-Id: Ieecd7a122177530ab1ff890367ce53809a8bb7b9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
-rw-r--r-- | src/qtwaylandscanner/qtwaylandscanner.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 273a0012e..6bdcb8da5 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"); @@ -965,9 +968,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"); @@ -1077,9 +1080,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"); |