summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-07-27 10:11:42 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-27 13:31:27 +0200
commit75250731230f3b21eb49025fe9cb597839ffc775 (patch)
tree6d7a4388ff7fb6e178e8aea77cd2ec82745080f4
parentd4e0c8ce241a5b145c59f345f6a55c2616242fcb (diff)
Make mac(deploy|change)qt handle dylibs that use Qt inside an app bundle.
Needed e.g. for Qt Creator, which is a bundle of plugins. Ported from 4.8 4bda273330f6705b79cf18c3ea8ef294f58a5239 Change-Id: Icc966fb1f663c3156ac057acba3923a6db27ee09 Reviewed-on: http://codereview.qt.nokia.com/2257 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
-rw-r--r--src/macdeployqt/shared/shared.cpp67
-rw-r--r--src/macdeployqt/shared/shared.h5
2 files changed, 54 insertions, 18 deletions
diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp
index bb37f0b6e..30c493f42 100644
--- a/src/macdeployqt/shared/shared.cpp
+++ b/src/macdeployqt/shared/shared.cpp
@@ -84,6 +84,7 @@ inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
{
debug << "Application bundle path" << info.path << "\n";
debug << "Binary path" << info.binaryPath << "\n";
+ debug << "Additional libraries" << info.libraryPaths << "\n";
return debug;
}
@@ -208,6 +209,21 @@ QString findAppBinary(const QString &appBundlePath)
return QString();
}
+QStringList findAppLibraries(const QString &appBundlePath)
+{
+ QStringList result;
+ // dylibs
+ QDirIterator iter(appBundlePath, QStringList() << QString::fromLatin1("*.dylib"),
+ QDir::Files, QDirIterator::Subdirectories);
+
+ while (iter.hasNext()) {
+ iter.next();
+ result << iter.fileInfo().filePath();
+ }
+ return result;
+}
+
+
QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines, bool useDebugLibs)
{
QList<FrameworkInfo> libraries;
@@ -243,6 +259,21 @@ QList<FrameworkInfo> getQtFrameworks(const QString &path, bool useDebugLibs)
return getQtFrameworks(outputLines, useDebugLibs);
}
+QList<FrameworkInfo> getQtFrameworksForPaths(const QStringList &paths, bool useDebugLibs)
+{
+ QList<FrameworkInfo> result;
+ QSet<QString> existing;
+ foreach (const QString &path, paths) {
+ foreach (const FrameworkInfo &info, getQtFrameworks(path, useDebugLibs)) {
+ if (!existing.contains(info.frameworkPath)) { // avoid duplicates
+ existing.insert(info.frameworkPath);
+ result << info;
+ }
+ }
+ }
+ return result;
+}
+
// copies everything _inside_ sourcePath to destinationPath
void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
{
@@ -312,13 +343,14 @@ void changeIdentification(const QString &id, const QString &binaryPath)
runInstallNameTool(QStringList() << "-id" << id << binaryPath);
}
-void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath)
+void changeInstallName(const QString &oldName, const QString &newName, const QStringList &binaryPaths)
{
LogDebug() << "Using install_name_tool:";
- LogDebug() << " in" << binaryPath;
+ LogDebug() << " in" << binaryPaths;
LogDebug() << " change reference" << oldName;
LogDebug() << " to" << newName;
- runInstallNameTool(QStringList() << "-change" << oldName << newName << binaryPath);
+ foreach (const QString &path, binaryPaths)
+ runInstallNameTool(QStringList() << "-change" << oldName << newName << path);
}
void runStrip(const QString &binaryPath)
@@ -345,10 +377,10 @@ void runStrip(const QString &binaryPath)
a list of actually deployed frameworks.
*/
DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
- const QString &bundlePath, const QString &binaryPath, bool useDebugLibs)
+ const QString &bundlePath, const QStringList &binaryPaths, bool useDebugLibs)
{
LogNormal();
- LogNormal() << "Deploying Qt frameworks found inside:" << binaryPath;
+ LogNormal() << "Deploying Qt frameworks found inside:" << binaryPaths;
QStringList copiedFrameworks;
DeploymentInfo deploymentInfo;
@@ -370,7 +402,7 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
}
// Install_name_tool the new id into the binary
- changeInstallName(framework.installName, framework.deployedInstallName, binaryPath);
+ changeInstallName(framework.installName, framework.deployedInstallName, binaryPaths);
// Copy farmework to app bundle.
const QString deployedBinaryPath = copyFramework(framework, bundlePath);
@@ -386,7 +418,7 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
QList<FrameworkInfo> dependencies = getQtFrameworks(deployedBinaryPath, useDebugLibs);
foreach (FrameworkInfo dependency, dependencies) {
- changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath);
+ changeInstallName(dependency.installName, dependency.deployedInstallName, QStringList() << deployedBinaryPath);
// Deploy framework if necessary.
if (copiedFrameworks.contains(dependency.frameworkName) == false && frameworks.contains(dependency) == false) {
@@ -403,7 +435,9 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, bool useDebugLib
ApplicationBundleInfo applicationBundle;
applicationBundle.path = appBundlePath;
applicationBundle.binaryPath = findAppBinary(appBundlePath);
- QList<FrameworkInfo> frameworks = getQtFrameworks(applicationBundle.binaryPath, useDebugLibs);
+ applicationBundle.libraryPaths = findAppLibraries(appBundlePath);
+ QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths;
+ QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, useDebugLibs);
if (frameworks.isEmpty()) {
LogWarning();
LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath;
@@ -411,7 +445,7 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, bool useDebugLib
LogWarning() << "If so, you will need to rebuild" << appBundlePath << "before trying again.";
return DeploymentInfo();
} else {
- return deployQtFrameworks(frameworks, applicationBundle.path, applicationBundle.binaryPath, useDebugLibs);
+ return deployQtFrameworks(frameworks, applicationBundle.path, allBinaryPaths, useDebugLibs);
}
}
@@ -477,11 +511,11 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl
if (pluginName.contains("libphonon_qt7")) {
changeInstallName("/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo",
"/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore",
- destinationPath);
+ QStringList() << destinationPath);
}
QList<FrameworkInfo> frameworks = getQtFrameworks(destinationPath, useDebugLibs);
- deployQtFrameworks(frameworks, appBundleInfo.path, destinationPath, useDebugLibs);
+ deployQtFrameworks(frameworks, appBundleInfo.path, QStringList() << destinationPath, useDebugLibs);
}
} // foreach plugins
@@ -527,9 +561,9 @@ void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo,
}
-void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QString &appBinaryPath, const QString &absoluteQtPath)
+void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QStringList &binaryPaths, const QString &absoluteQtPath)
{
- LogNormal() << "Changing" << appBinaryPath << "to link against";
+ LogNormal() << "Changing" << binaryPaths << "to link against";
LogNormal() << "Qt in" << absoluteQtPath;
QString finalQtPath = absoluteQtPath;
@@ -539,21 +573,22 @@ void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QString &ap
foreach (FrameworkInfo framework, frameworks) {
const QString oldBinaryId = framework.installName;
const QString newBinaryId = finalQtPath + framework.frameworkName + framework.binaryPath;
- changeInstallName(oldBinaryId, newBinaryId, appBinaryPath);
+ changeInstallName(oldBinaryId, newBinaryId, binaryPaths);
}
}
void changeQtFrameworks(const QString appPath, const QString &qtPath, bool useDebugLibs)
{
const QString appBinaryPath = findAppBinary(appPath);
- const QList<FrameworkInfo> frameworks = getQtFrameworks(appBinaryPath, useDebugLibs);
+ const QStringList libraryPaths = findAppLibraries(appPath);
+ const QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(QStringList() << appBinaryPath << libraryPaths, useDebugLibs);
if (frameworks.isEmpty()) {
LogWarning();
LogWarning() << "Could not find any _external_ Qt frameworks to change in" << appPath;
return;
} else {
const QString absoluteQtPath = QDir(qtPath).absolutePath();
- changeQtFrameworks(frameworks, appBinaryPath, absoluteQtPath);
+ changeQtFrameworks(frameworks, QStringList() << appBinaryPath << libraryPaths, absoluteQtPath);
}
}
diff --git a/src/macdeployqt/shared/shared.h b/src/macdeployqt/shared/shared.h
index 5eec3cfbb..ab9ada2d1 100644
--- a/src/macdeployqt/shared/shared.h
+++ b/src/macdeployqt/shared/shared.h
@@ -77,6 +77,7 @@ class ApplicationBundleInfo
public:
QString path;
QString binaryPath;
+ QStringList libraryPaths;
};
class DeploymentInfo
@@ -91,7 +92,7 @@ public:
inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info);
void changeQtFrameworks(const QString appPath, const QString &qtPath, bool useDebugLibs);
-void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QString &appBinaryPath, const QString &qtPath);
+void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QStringList &binaryPaths, const QString &qtPath);
FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs);
QString findAppBinary(const QString &appBundlePath);
@@ -103,7 +104,7 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks, const QString
void createQtConf(const QString &appBundlePath);
void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo, bool useDebugLibs);
void changeIdentification(const QString &id, const QString &binaryPath);
-void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
+void changeInstallName(const QString &oldName, const QString &newName, const QStringList &binaryPaths);
QString findAppBinary(const QString &appBundlePath);
void createDiskImage(const QString &appBundlePath);