From 66d6eeea28efb1a6a03e8c69670b634b27025260 Mon Sep 17 00:00:00 2001 From: tobtoht <41021257+tobtoht@users.noreply.github.com> Date: Tue, 24 May 2022 17:03:04 +0000 Subject: [PATCH] Allow linuxdeployqt to be built with Qt 6 Allow linuxdeployqt to be built with Qt 6; this does not mean that we build linuxdeployqt with Qt 6 or that linuxdeployqt can deploy Qt 6 applications yet Thanks @tobtoht --- tools/linuxdeployqt/main.cpp | 2 +- tools/linuxdeployqt/shared.cpp | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/linuxdeployqt/main.cpp b/tools/linuxdeployqt/main.cpp index 338a0e2..6683bc1 100644 --- a/tools/linuxdeployqt/main.cpp +++ b/tools/linuxdeployqt/main.cpp @@ -541,7 +541,7 @@ int main(int argc, char **argv) // Update deploymentInfo.deployedLibraries - the QML imports // may have brought in extra libraries as dependencies. deploymentInfo.deployedLibraries += findAppLibraries(appDirPath); - deploymentInfo.deployedLibraries = deploymentInfo.deployedLibraries.toSet().toList(); + deploymentInfo.deployedLibraries.removeDuplicates(); } deploymentInfo.usedModulesMask = 0; diff --git a/tools/linuxdeployqt/shared.cpp b/tools/linuxdeployqt/shared.cpp index 03f299e..4d03b52 100644 --- a/tools/linuxdeployqt/shared.cpp +++ b/tools/linuxdeployqt/shared.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +45,12 @@ #include "shared.h" #include "excludelist.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + #define QSTRING_SPLIT_BEHAVIOR_NAMESPACE QString +#else + #define QSTRING_SPLIT_BEHAVIOR_NAMESPACE Qt +#endif + QString appBinaryPath; bool runStripEnabled = true; bool bundleAllButCoreLibs = false; @@ -307,7 +312,7 @@ bool copyCopyrightFile(QString libPath){ myProcess->waitForFinished(); strOut = myProcess->readAllStandardOutput(); - QStringList outputLines = strOut.split("\n", QString::SkipEmptyParts); + QStringList outputLines = strOut.split("\n", QSTRING_SPLIT_BEHAVIOR_NAMESPACE::SkipEmptyParts); foreach (QString outputLine, outputLines) { if((outputLine.contains("usr/share/doc")) && (outputLine.contains("/copyright")) && (outputLine.contains(" "))){ @@ -356,7 +361,7 @@ LddInfo findDependencyInfo(const QString &binaryPath) static const QRegularExpression regexp(QStringLiteral("^.+ => (.+) \\(")); QString output = ldd.readAllStandardOutput(); - QStringList outputLines = output.split("\n", QString::SkipEmptyParts); + QStringList outputLines = output.split("\n", QSTRING_SPLIT_BEHAVIOR_NAMESPACE::SkipEmptyParts); if (outputLines.size() < 2) { if ((output.contains("statically linked") == false)){ LogError() << "Could not parse ldd output under 2 lines:" << output; @@ -851,7 +856,7 @@ void changeIdentification(const QString &id, const QString &binaryPath) } } - QStringList rpath = oldRpath.split(":", QString::SkipEmptyParts); + QStringList rpath = oldRpath.split(":", QSTRING_SPLIT_BEHAVIOR_NAMESPACE::SkipEmptyParts); rpath.prepend(id); rpath.removeDuplicates(); foreach(QString path, QStringList(rpath)) { @@ -1064,7 +1069,11 @@ DeploymentInfo deployQtLibraries(QList libraries, static QString captureOutput(const QString &command) { QProcess process; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) process.start(command, QIODevice::ReadOnly); +#else + process.startCommand(command, QIODevice::ReadOnly); +#endif process.waitForFinished(); if (process.exitStatus() != QProcess::NormalExit) { @@ -1129,7 +1138,7 @@ DeploymentInfo deployQtLibraries(const QString &appDirPath, const QStringList &a QString output = captureOutput(qmakePath + " -query"); LogDebug() << "-query output from qmake:" << output; - QStringList outputLines = output.split("\n", QString::SkipEmptyParts); + QStringList outputLines = output.split("\n", QSTRING_SPLIT_BEHAVIOR_NAMESPACE::SkipEmptyParts); foreach (const QString &outputLine, outputLines) { int colonIndex = outputLine.indexOf(QLatin1Char(':')); if (colonIndex != -1) {