summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@nokia.com>2011-07-26 15:03:03 (GMT)
committerEike Ziller <eike.ziller@nokia.com>2011-07-26 15:31:07 (GMT)
commit4bda273330f6705b79cf18c3ea8ef294f58a5239 (patch)
treef18bab3f968ad268e8a644be172a8b0544c74873
parent2ccef4f57f036a486cb96904298a8b4673ff0aec (diff)
downloadQt-4bda273330f6705b79cf18c3ea8ef294f58a5239.zip
Qt-4bda273330f6705b79cf18c3ea8ef294f58a5239.tar.gz
Qt-4bda273330f6705b79cf18c3ea8ef294f58a5239.tar.bz2
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. Reviewed-by: TrustMe
-rw-r--r--tools/macdeployqt/shared/shared.cpp67
-rw-r--r--tools/macdeployqt/shared/shared.h5
2 files changed, 54 insertions, 18 deletions
diff --git a/tools/macdeployqt/shared/shared.cpp b/tools/macdeployqt/shared/shared.cpp
index bb37f0b..30c493f 100644
--- a/tools/macdeployqt/shared/shared.cpp
+++ b/tools/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/tools/macdeployqt/shared/shared.h b/tools/macdeployqt/shared/shared.h
index 5eec3cf..ab9ada2 100644
--- a/tools/macdeployqt/shared/shared.h
+++ b/tools/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);