macdeployqt: Also deploy framework's Libraries and Helpers
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>
Thu, 6 Nov 2014 10:42:00 +0000 (11:42 +0100)
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>
Thu, 13 Nov 2014 10:34:02 +0000 (11:34 +0100)
QtWebEngine can't put all its external data in qrc files and have a few
files lying around in the Qt installation. To allow it to be bundled
with applications, those files are now placed into the QtWebEngineCore
framework.

This patch allows Helpers/QtWebEngineProcess.app as well as
Libraries/ffmpegsumo.so to be deployed when macdeployqt is run on an
application linking to QtWebEngine.

This link mention that Libraries is a standard directory:
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

This link mention that Helpers is a standard directory for application
bundles, but I haven't seen any mention regarding frameworks:
https://developer.apple.com/library/mac/technotes/tn2206/_index.html

Task-number: QTBUG-41611
Change-Id: I27f662747bd3dff4b9fc8706ecbd2f16f057e857
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
src/macdeployqt/shared/shared.cpp

index a8716d7..a6f0d12 100644 (file)
@@ -381,8 +381,10 @@ QStringList getBinaryDependencies(const QString executablePath, const QString &p
 }
 
 // copies everything _inside_ sourcePath to destinationPath
-void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
+bool recursiveCopy(const QString &sourcePath, const QString &destinationPath)
 {
+    if (!QDir(sourcePath).exists())
+        return false;
     QDir().mkpath(destinationPath);
 
     LogNormal() << "copy:" << sourcePath << destinationPath;
@@ -398,6 +400,7 @@ void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
     foreach (QString dir, subdirs) {
         recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir);
     }
+    return true;
 }
 
 void recursiveCopyAndDeploy(const QString &appBundlePath, const QString &sourcePath, const QString &destinationPath)
@@ -516,10 +519,16 @@ QString copyFramework(const FrameworkInfo &framework, const QString path)
     // Copy framework binary
     copyFilePrintStatus(framework.sourceFilePath, frameworkDestinationBinaryPath);
 
-    // Copy Resouces/
+    // Copy Resouces/, Libraries/ and Helpers/
     const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
     const QString resourcesDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Resources";
     recursiveCopy(resourcesSourcePath, resourcesDestianationPath);
+    const QString librariesSourcePath = framework.frameworkPath + "/Libraries";
+    const QString librariesDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Libraries";
+    bool createdLibraries = recursiveCopy(librariesSourcePath, librariesDestianationPath);
+    const QString helpersSourcePath = framework.frameworkPath + "/Helpers";
+    const QString helpersDestianationPath = frameworkDestinationDirectory + "/Versions/" + framework.version + "/Helpers";
+    bool createdHelpers = recursiveCopy(helpersSourcePath, helpersDestianationPath);
 
     // Create symlink structure. Links at the framework root point to Versions/Current/
     // which again points to the actual version:
@@ -528,6 +537,10 @@ QString copyFramework(const FrameworkInfo &framework, const QString path)
     // QtFoo.framework/Versions/Current -> 5
     linkFilePrintStatus("Versions/Current/" + framework.binaryName, frameworkDestinationDirectory + "/" + framework.binaryName);
     linkFilePrintStatus("Versions/Current/Resources", frameworkDestinationDirectory + "/Resources");
+    if (createdLibraries)
+        linkFilePrintStatus("Versions/Current/Libraries", frameworkDestinationDirectory + "/Libraries");
+    if (createdHelpers)
+        linkFilePrintStatus("Versions/Current/Helpers", frameworkDestinationDirectory + "/Helpers");
     linkFilePrintStatus(framework.version, frameworkDestinationDirectory + "/Versions/Current");
 
     // Correct Info.plist location for frameworks produced by older versions of qmake