macdeployqt: Merge changes from upstream

This commit is contained in:
Jonas Kvinge 2022-08-30 17:48:16 +02:00
parent 32f9c4e670
commit 82d101ca27
1 changed files with 22 additions and 11 deletions

View File

@ -40,6 +40,8 @@
#include <QDir> #include <QDir>
#include <QSet> #include <QSet>
#include <QList> #include <QList>
#include <QVariant>
#include <QVariantMap>
#include <QStack> #include <QStack>
#include <QDirIterator> #include <QDirIterator>
#include <QLibraryInfo> #include <QLibraryInfo>
@ -220,6 +222,8 @@ OtoolInfo findDependencyInfo(const QString &binaryPath)
for (const QString &outputLine : outputLines) { for (const QString &outputLine : outputLines) {
const auto match = regexp.match(outputLine); const auto match = regexp.match(outputLine);
if (match.hasMatch()) { if (match.hasMatch()) {
if (match.captured(1) == info.installName)
continue; // Another arch reference to the same binary
DylibInfo dylib; DylibInfo dylib;
dylib.binaryPath = match.captured(1); dylib.binaryPath = match.captured(1);
dylib.compatibilityVersion = QVersionNumber::fromString(match.captured(2)); dylib.compatibilityVersion = QVersionNumber::fromString(match.captured(2));
@ -300,11 +304,11 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundl
if (state == QtPath) { if (state == QtPath) {
// Check for library name part // Check for library name part
if (part < parts.count() && parts.at(part).contains(".dylib")) { if (part < parts.count() && parts.at(part).contains(".dylib")) {
info.frameworkDirectory += "/" + (qtPath + currentPart + "/").simplified(); info.frameworkDirectory += "/" + QString(qtPath + currentPart + "/").simplified();
state = DylibName; state = DylibName;
continue; continue;
} else if (part < parts.count() && parts.at(part).endsWith(".framework")) { } else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
info.frameworkDirectory += "/" + (qtPath + "lib/").simplified(); info.frameworkDirectory += "/" + QString(qtPath + "lib/").simplified();
state = FrameworkName; state = FrameworkName;
continue; continue;
} else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package. } else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package.
@ -859,11 +863,18 @@ void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework
} else { } else {
deployedInstallName = framework.deployedInstallName; deployedInstallName = framework.deployedInstallName;
} }
if (!framework.sourceFilePath.isEmpty()) { changeInstallName(framework.installName, deployedInstallName, binary);
changeInstallName(framework.sourceFilePath, deployedInstallName, binary); // Workaround for the case when the library ID name is a symlink, while the dependencies
} // specified using the canonical path to the library (QTBUG-56814)
if (!framework.installName.isEmpty() && framework.installName != framework.sourceFilePath) { QFileInfo fileInfo= QFileInfo(framework.installName);
changeInstallName(framework.installName, deployedInstallName, binary); QString canonicalInstallName = fileInfo.canonicalFilePath();
if (!canonicalInstallName.isEmpty() && canonicalInstallName != framework.installName) {
changeInstallName(canonicalInstallName, deployedInstallName, binary);
// some libraries' inner dependencies (such as ffmpeg, nettle) use symbol link (QTBUG-100093)
QString innerDependency = fileInfo.canonicalPath() + "/" + fileInfo.fileName();
if (innerDependency != canonicalInstallName && innerDependency != framework.installName) {
changeInstallName(innerDependency, deployedInstallName, binary);
}
} }
} }
} }
@ -1078,7 +1089,7 @@ QString getLibInfix(const QStringList &deployedFrameworks)
{ {
QString libInfix; QString libInfix;
for (const QString &framework : deployedFrameworks) { for (const QString &framework : deployedFrameworks) {
if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework"))) { if (framework.startsWith(QStringLiteral("QtCore")) && framework.endsWith(QStringLiteral(".framework")) && !framework.contains(QStringLiteral("5Compat"))) {
Q_ASSERT(framework.length() >= 16); Q_ASSERT(framework.length() >= 16);
// 16 == "QtCore" + ".framework" // 16 == "QtCore" + ".framework"
const int lengthOfLibInfix = framework.length() - 16; const int lengthOfLibInfix = framework.length() - 16;
@ -1474,9 +1485,9 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
for (const QString &importPath : qmlImportPaths) for (const QString &importPath : qmlImportPaths)
argumentList << "-importPath" << importPath; argumentList << "-importPath" << importPath;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath); QString qmlImportsPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
#else #else
QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); QString qmlImportsPath = QLibraryInfo::location(QLibraryInfo::QmlImportsPath);
#endif #endif
argumentList.append( "-importPath"); argumentList.append( "-importPath");
argumentList.append(qmlImportsPath); argumentList.append(qmlImportsPath);
@ -1488,7 +1499,7 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString(); LogError() << "Could not start qmlimpoortscanner. Process error is" << qmlImportScanner.errorString();
return false; return false;
} }
qmlImportScanner.waitForFinished(); qmlImportScanner.waitForFinished(-1);
// log qmlimportscanner errors // log qmlimportscanner errors
qmlImportScanner.setReadChannel(QProcess::StandardError); qmlImportScanner.setReadChannel(QProcess::StandardError);