Fix QML imports deployment when using path
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Mon, 10 Aug 2015 13:36:16 +0000 (15:36 +0200)
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Thu, 13 Aug 2015 09:03:39 +0000 (09:03 +0000)
During deployment the value of LC_RPATH on the main
executable gets updated with a new value pointing
inside the app bundle. This happens before QML
import deployment, which means reading LC_RPATH
at QML import deployment time will not give the
correct value.

Use the cached value stored in the DeploymentInfo
structure instead, which will point back to the Qt
installation.

Task-number: QTBUG-47390
Change-Id: Ide84240de408d2338c9f7a68a73849263ce69dff
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
src/macdeployqt/macdeployqt/main.cpp
src/macdeployqt/shared/shared.cpp
src/macdeployqt/shared/shared.h

index 40fc438..750316f 100644 (file)
@@ -158,7 +158,7 @@ int main(int argc, char **argv)
     }
 
     if (!qmlDirs.isEmpty())
-        deployQmlImports(appBundlePath, qmlDirs);
+        deployQmlImports(appBundlePath, deploymentInfo, qmlDirs);
 
     if (runCodesign)
         codesign(codesignIdentiy, appBundlePath);
index e2c4a19..5ed6c43 100644 (file)
@@ -553,13 +553,12 @@ bool recursiveCopy(const QString &sourcePath, const QString &destinationPath)
     return true;
 }
 
-void recursiveCopyAndDeploy(const QString &appBundlePath, const QString &sourcePath, const QString &destinationPath)
+void recursiveCopyAndDeploy(const QString &appBundlePath, const QSet<QString> &rpaths, const QString &sourcePath, const QString &destinationPath)
 {
     QDir().mkpath(destinationPath);
 
     LogNormal() << "copy:" << sourcePath << destinationPath;
 
-    QSet<QString> rpaths = getBinaryRPaths(findAppBinary(appBundlePath), true);
     QStringList files = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Files | QDir::NoDotAndDotDot);
     foreach (QString file, files) {
         const QString fileSourcePath = sourcePath + QLatin1Char('/') + file;
@@ -608,7 +607,7 @@ void recursiveCopyAndDeploy(const QString &appBundlePath, const QString &sourceP
 
     QStringList subdirs = QDir(sourcePath).entryList(QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot);
     foreach (QString dir, subdirs) {
-        recursiveCopyAndDeploy(appBundlePath, sourcePath + QLatin1Char('/') + dir, destinationPath + QLatin1Char('/') + dir);
+        recursiveCopyAndDeploy(appBundlePath, rpaths, sourcePath + QLatin1Char('/') + dir, destinationPath + QLatin1Char('/') + dir);
     }
 }
 
@@ -1028,7 +1027,7 @@ void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo,
     deployPlugins(applicationBundle, deploymentInfo.pluginPath, pluginDestinationPath, deploymentInfo, useDebugLibs);
 }
 
-void deployQmlImport(const QString &appBundlePath, const QString &importSourcePath, const QString &importName)
+void deployQmlImport(const QString &appBundlePath, const QSet<QString> &rpaths, const QString &importSourcePath, const QString &importName)
 {
     QString importDestinationPath = appBundlePath + "/Contents/Resources/qml/" + importName;
 
@@ -1037,11 +1036,11 @@ void deployQmlImport(const QString &appBundlePath, const QString &importSourcePa
     if (QDir().exists(importDestinationPath))
         return;
 
-    recursiveCopyAndDeploy(appBundlePath, importSourcePath, importDestinationPath);
+    recursiveCopyAndDeploy(appBundlePath, rpaths, importSourcePath, importDestinationPath);
 }
 
 // Scan qml files in qmldirs for import statements, deploy used imports from Qml2ImportsPath to Contents/Resources/qml.
-void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs)
+void deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs)
 {
     LogNormal() << "";
     LogNormal() << "Deploying QML imports ";
@@ -1129,7 +1128,7 @@ void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs)
         if (version.startsWith(QLatin1Char('.')))
             name.append(version);
 
-        deployQmlImport(appBundlePath, path, name);
+        deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name);
         LogNormal() << "";
     }
 }
index 43f1c24..27628b7 100644 (file)
@@ -100,7 +100,7 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringLis
 DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs, bool useLoaderPath);
 void createQtConf(const QString &appBundlePath);
 void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs);
-void deployQmlImports(const QString &appBundlePath, QStringList &qmlDirs);
+void deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInfo, QStringList &qmlDirs);
 void changeIdentification(const QString &id, const QString &binaryPath);
 void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
 void runStrip(const QString &binaryPath);