summaryrefslogtreecommitdiffstats
path: root/tools/macdeployqt
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tools/macdeployqt
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'tools/macdeployqt')
-rw-r--r--tools/macdeployqt/macchangeqt/macchangeqt.pro9
-rw-r--r--tools/macdeployqt/macchangeqt/main.cpp54
-rw-r--r--tools/macdeployqt/macdeployqt.pro7
-rw-r--r--tools/macdeployqt/macdeployqt/macdeployqt.pro13
-rw-r--r--tools/macdeployqt/macdeployqt/main.cpp116
-rw-r--r--tools/macdeployqt/shared/shared.cpp563
-rw-r--r--tools/macdeployqt/shared/shared.h104
-rw-r--r--tools/macdeployqt/tests/deployment_mac.pro10
-rw-r--r--tools/macdeployqt/tests/tst_deployment_mac.cpp233
9 files changed, 1109 insertions, 0 deletions
diff --git a/tools/macdeployqt/macchangeqt/macchangeqt.pro b/tools/macdeployqt/macchangeqt/macchangeqt.pro
new file mode 100644
index 0000000..c09fea3
--- /dev/null
+++ b/tools/macdeployqt/macchangeqt/macchangeqt.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+TARGET = macchangeqt
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp ../shared/shared.cpp
+CONFIG += qt warn_on
+CONFIG -= app_bundle
diff --git a/tools/macdeployqt/macchangeqt/main.cpp b/tools/macdeployqt/macchangeqt/main.cpp
new file mode 100644
index 0000000..e94e8a3
--- /dev/null
+++ b/tools/macdeployqt/macchangeqt/main.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../shared/shared.h"
+
+int main(int argc, char **argv)
+{
+ if (argc != 3) {
+ qDebug() << "Changeqt changes witch qt frameworks an application links against.";
+ qDebug() << "Usage: changeqt app-bundle qt-dir";
+ return 0;
+ }
+
+ const QString appPath = QString::fromLocal8Bit(argv[1]);
+ const QString qtPath = QString::fromLocal8Bit(argv[2]);
+ changeQtFrameworks(appPath, qtPath);
+}
diff --git a/tools/macdeployqt/macdeployqt.pro b/tools/macdeployqt/macdeployqt.pro
new file mode 100644
index 0000000..09ed698
--- /dev/null
+++ b/tools/macdeployqt/macdeployqt.pro
@@ -0,0 +1,7 @@
+
+mac {
+
+TEMPLATE = subdirs
+SUBDIRS = macdeployqt macchangeqt
+
+}
diff --git a/tools/macdeployqt/macdeployqt/macdeployqt.pro b/tools/macdeployqt/macdeployqt/macdeployqt.pro
new file mode 100644
index 0000000..3e56024
--- /dev/null
+++ b/tools/macdeployqt/macdeployqt/macdeployqt.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = macdeployqt
+DEPENDPATH += .
+INCLUDEPATH += .
+DESTDIR = ../../../bin
+
+# Input
+SOURCES += main.cpp ../shared/shared.cpp
+CONFIG += qt warn_on
+CONFIG -= app_bundle
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
diff --git a/tools/macdeployqt/macdeployqt/main.cpp b/tools/macdeployqt/macdeployqt/main.cpp
new file mode 100644
index 0000000..d6f7e5f
--- /dev/null
+++ b/tools/macdeployqt/macdeployqt/main.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../shared/shared.h"
+#include <qdir.h>
+
+int main(int argc, char **argv)
+{
+ QString appBundlePath;
+ if (argc > 1)
+ appBundlePath = QString::fromLocal8Bit(argv[1]);
+
+ if (argc < 2 || appBundlePath.startsWith("-")) {
+ qDebug() << "Usage: macdeployqt app-bundle [options]";
+ qDebug() << "";
+ qDebug() << "Options:";
+ qDebug() << " -no-plugins: Skip plugin deployment";
+ qDebug() << " -dmg : Create a .dmg disk image";
+ qDebug() << " -no-strip : Don't run 'strip' on the binaries";
+ qDebug() << "";
+ qDebug() << "macdeployqt takes an application bundle as input and makes it";
+ qDebug() << "self-contained by copying in the Qt frameworks and plugins that";
+ qDebug() << "the application uses.";
+ qDebug() << "";
+ qDebug() << "Plugins related to a framework are copied in with the";
+ qDebug() << "framework. The accessibilty, image formats, and text codec";
+ qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified.";
+ qDebug() << "";
+ qDebug() << "See the \"Deploying an Application on Qt/Mac\" typic in the";
+ qDebug() << "documentation for more information about deployment on Mac OS X.";
+
+ return 0;
+ }
+
+ if (appBundlePath.endsWith("/"))
+ appBundlePath.chop(1);
+
+ if (QDir().exists(appBundlePath) == false) {
+ qDebug() << "Error: Could not find app bundle" << appBundlePath;
+ return 0;
+ }
+
+ bool plugins = true;
+ bool dmg = false;
+ extern bool runStripEnabled;
+
+ for (int i = 2; i < argc; ++i) {
+ QByteArray argument = QByteArray(argv[i]);
+ if (argument == QByteArray("-no-plugins")) {
+ plugins = false;
+ } else if (argument == QByteArray("-dmg")) {
+ dmg = true;
+ } else if (argument == QByteArray("-no-strip")) {
+ runStripEnabled = false;
+ } else if (argument.startsWith("-")) {
+ qDebug() << "Error: Unknown option" << argument << "\n";
+ return 0;
+ }
+ }
+
+ DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath);
+
+ if (plugins) {
+ if (deploymentInfo.qtPath.isEmpty())
+ deploymentInfo.pluginPath = "/Developer/Applications/Qt/plugins"; // Assume binary package.
+ else
+ deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins";
+
+ qDebug() << "";
+ qDebug() << "Deploying plugins from" << deploymentInfo.pluginPath;
+ deployPlugins(appBundlePath, deploymentInfo);
+ createQtConf(appBundlePath);
+ }
+
+ if (dmg) {
+ createDiskImage(appBundlePath);
+ }
+}
+
diff --git a/tools/macdeployqt/shared/shared.cpp b/tools/macdeployqt/shared/shared.cpp
new file mode 100644
index 0000000..db76ef2
--- /dev/null
+++ b/tools/macdeployqt/shared/shared.cpp
@@ -0,0 +1,563 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QString>
+#include <QStringList>
+#include <QDebug>
+#include <iostream>
+#include <QProcess>
+#include <QDir>
+#include <QRegExp>
+#include <QSet>
+#include <QDirIterator>
+#include "shared.h"
+
+bool runStripEnabled = true;
+
+using std::cout;
+using std::endl;
+
+bool operator==(const FrameworkInfo &a, const FrameworkInfo &b)
+{
+ return ((a.frameworkPath == b.frameworkPath) && (a.binaryPath == b.binaryPath));
+}
+
+QDebug operator<<(QDebug debug, const FrameworkInfo &info)
+{
+ debug << "Framework directory" << info.frameworkDirectory << "\n";
+ debug << "Framework name" << info.frameworkName << "\n";
+ debug << "Framework path" << info.frameworkPath << "\n";
+ debug << "Binary directory" << info.binaryDirectory << "\n";
+ debug << "Binary name" << info.binaryName << "\n";
+ debug << "Binary path" << info.binaryPath << "\n";
+ debug << "Version" << info.version << "\n";
+ debug << "Install name" << info.installName << "\n";
+ debug << "Deployed install name" << info.deployedInstallName << "\n";
+ debug << "Source file Path" << info.sourceFilePath << "\n";
+ debug << "Deployed Directtory (relative to bundle)" << info.destinationDirectory << "\n";
+
+ return debug;
+}
+
+const QString bundleFrameworkDirectory = "Contents/Frameworks";
+const QString bundleBinaryDirectory = "Contents/MacOS";
+
+inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
+{
+ debug << "Application bundle path" << info.path << "\n";
+ debug << "Binary path" << info.binaryPath << "\n";
+ return debug;
+}
+
+bool copyFilePrintStatus(const QString &from, const QString &to)
+{
+ if (QFile::copy(from, to)) {
+ qDebug() << "copied" << from << "to" << to;
+ return true;
+ } else {
+ qDebug() << "ERROR: file copy failed from" << from << "to" << to;
+ return false;
+ }
+}
+
+
+FrameworkInfo parseOtoolLibraryLine(const QString &line)
+{
+ FrameworkInfo info;
+ QString trimmed = line.trimmed();
+
+ if (trimmed.isEmpty())
+ return info;
+
+ // Don't deploy system libraries.
+ if (trimmed.startsWith("/System/Library/") ||
+ (trimmed.startsWith("/usr/lib/") && trimmed.contains("libQt") == false) // exception for libQtuitools and libQtlucene
+ || trimmed.startsWith("@executable_path"))
+ return info;
+
+ enum State {QtPath, FrameworkName, DylibName, Version, End};
+ State state = QtPath;
+ int part = 0;
+ QString name;
+ QString qtPath;
+
+ // Split the line into [Qt-path]/lib/qt[Module].framework/Versions/[Version]/
+ QStringList parts = trimmed.split("/");
+ while (part < parts.count()) {
+ const QString currentPart = parts.at(part).simplified() ;
+// qDebug() << "currentPart" << currentPart;
+ ++part;
+ if (currentPart == "")
+ continue;
+
+ if (state == QtPath) {
+ // Check for library name part
+ if (part < parts.count() && parts.at(part).contains(".dylib ")) {
+ state = DylibName;
+ info.installName += "/" + (qtPath + "lib/").simplified();
+ info.frameworkDirectory = info.installName;
+ state = DylibName;
+ continue;
+ } else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
+ info.installName += "/" + (qtPath + "lib/").simplified();
+ info.frameworkDirectory = info.installName;
+ state = FrameworkName;
+ continue;
+ } else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package.
+ if (currentPart.contains(".framework")) {
+ info.frameworkDirectory = "/Library/Frameworks/";
+ state = FrameworkName;
+ } else {
+ info.frameworkDirectory = "/usr/lib/";
+ state = DylibName;
+ }
+
+ --part;
+ continue;
+ }
+ qtPath += (currentPart + "/");
+
+ } if (state == FrameworkName) {
+ // remove ".framework"
+ name = currentPart;
+ name.chop(QString(".framework").length());
+ info.frameworkName = currentPart;
+ state = Version;
+ ++part;
+ continue;
+ } if (state == DylibName) {
+ name = currentPart.split(" (compatibility").at(0);
+ info.frameworkName = name;
+ info.installName += info.frameworkName;
+ info.deployedInstallName = "@executable_path/../Frameworks/" + info.frameworkName;
+ info.binaryName = name;
+ info.frameworkPath = info.frameworkDirectory + info.frameworkName;
+ info.sourceFilePath = info.frameworkPath;
+ info.destinationDirectory = bundleFrameworkDirectory + "/";
+ state = End;
+ ++part;
+ continue;
+ } else if (state == Version) {
+ info.version = currentPart;
+ info.binaryDirectory = "Versions/" + info.version;
+ info.binaryName = name;
+ info.binaryPath = "/" + info.binaryDirectory + "/" + info.binaryName;
+ info.installName += info.frameworkName + info.binaryPath;
+ info.deployedInstallName = "@executable_path/../Frameworks/" + info.frameworkName + info.binaryPath;
+ info.frameworkPath = info.frameworkDirectory + info.frameworkName;
+ info.sourceFilePath = info.frameworkPath + info.binaryPath;
+ info.destinationDirectory = bundleFrameworkDirectory + "/" + info.frameworkName + "/" + info.binaryDirectory;
+
+ state = End;
+ } else if (state == End) {
+ break;
+ }
+ }
+
+ return info;
+}
+
+QString findAppBinary(const QString &appBundlePath)
+{
+ QString appName = QFileInfo(appBundlePath).completeBaseName();
+ QString binaryPath = appBundlePath + "/Contents/MacOS/" + appName;
+
+ if (QFile::exists(binaryPath))
+ return binaryPath;
+ qDebug() << "Error: Could not find bundle binary for" << appBundlePath;
+ return QString();
+}
+
+QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines)
+{
+ QList<FrameworkInfo> libraries;
+ foreach(const QString line, otoolLines) {
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+ if (info.frameworkName.isEmpty() == false) {
+ libraries.append(info);
+ }
+ }
+ return libraries;
+}
+
+QList<FrameworkInfo> getQtFrameworks(const QString &path)
+{
+ QProcess otool;
+ otool.start("otool", QStringList() << "-L" << path);
+ otool.waitForFinished();
+
+ if (otool.exitCode() != 0) {
+ qDebug() << otool.readAllStandardError();
+ }
+
+ QString output = otool.readAllStandardOutput();
+ QStringList outputLines = output.split("\n");
+ outputLines.removeFirst(); // remove line containing the binary path
+ if (path.contains(".framework") || path.contains(".dylib"))
+ outputLines.removeFirst(); // frameworks and dylibs lists themselves as a dependency.
+
+ return getQtFrameworks(outputLines);
+}
+
+// copies everything _inside_ sourcePath to destinationPath
+void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
+{
+ QDir().mkpath(destinationPath);
+
+ QStringList files = QDir(sourcePath).entryList(QStringList() << "*", QDir::Files | QDir::NoDotAndDotDot);
+ foreach (QString file, files) {
+ const QString fileSourcePath = sourcePath + "/" + file;
+ const QString fileDestinationPath = destinationPath + "/" + file;
+ copyFilePrintStatus(fileSourcePath, fileDestinationPath);
+ }
+
+ QStringList subdirs = QDir(sourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
+ foreach (QString dir, subdirs) {
+ recursiveCopy(sourcePath + "/" + dir, destinationPath + "/" + dir);
+ }
+}
+
+QString copyFramework(const FrameworkInfo &framework, const QString path)
+{
+ const QString from = framework.sourceFilePath;
+ const QString toDir = path + "/" + framework.destinationDirectory;
+ const QString to = toDir + "/" + framework.binaryName;
+
+ if (QFile::exists(from) == false) {
+ qDebug() << "ERROR: no file at" << from;
+ return QString();
+ }
+
+
+ QDir dir;
+ if (dir.mkpath(toDir) == false) {
+ qDebug() << "ERROR: could not create destination directory" << to;
+ return QString();
+ }
+
+
+ if (QFile::exists(to)) {
+// qDebug() << framework.frameworkName << "already deployed, skip";
+ return QString();
+ }
+
+ copyFilePrintStatus(from, to);
+
+ const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
+ const QString resourcesDestianationPath = path + "/Contents/Frameworks/" + framework.frameworkName + "/Resources";
+ recursiveCopy(resourcesSourcePath, resourcesDestianationPath);
+
+ return to;
+}
+
+void runInstallNameTool(QStringList options)
+{
+ QProcess installNametool;
+ installNametool.start("install_name_tool", options);
+ installNametool.waitForFinished();
+ if (installNametool.exitCode() != 0) {
+ qDebug() << installNametool.readAllStandardError();
+ qDebug() << installNametool.readAllStandardOutput();
+ }
+}
+
+void changeIdentification(const QString &id, const QString &binaryPath)
+{
+// qDebug() << "change identification on" << binaryPath << id;
+ runInstallNameTool(QStringList() << "-id" << id << binaryPath);
+}
+
+void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath)
+{
+// qDebug() << "change install name on" << binaryPath << oldName << newName;
+ runInstallNameTool(QStringList() << "-change" << oldName << newName << binaryPath);
+}
+
+void runStrip(const QString &binaryPath)
+{
+ if (runStripEnabled == false)
+ return;
+
+ QProcess strip;
+ strip.start("strip", QStringList() << "-x" << binaryPath);
+ strip.waitForFinished();
+ if (strip.exitCode() != 0) {
+ qDebug() << strip.readAllStandardError();
+ qDebug() << strip.readAllStandardOutput();
+ } else {
+ qDebug() << "stripped" << binaryPath;
+ }
+}
+
+/*
+ Deploys the the listed frameworks listed into an app bundle.
+ The frameworks are searched for dependencies, which are also deployed.
+ (deploying Qt3Support will also deploy QtNetwork and QtSql for example.)
+ Returns a DeploymentInfo structure containing the Qt path used and a
+ a list of actually deployed frameworks.
+*/
+DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks, const QString &bundlePath, const QString &binaryPath)
+{
+ QStringList copiedFrameworks;
+ DeploymentInfo deploymenInfo;
+
+ while (frameworks.isEmpty() == false) {
+ const FrameworkInfo framework = frameworks.takeFirst();
+ copiedFrameworks.append(framework.frameworkName);
+
+ // Get the qt path from one of the Qt frameworks;
+ if (deploymenInfo.qtPath == QString() && framework.frameworkName.contains("Qt")
+ && framework.frameworkDirectory.contains("/lib"))
+ {
+ deploymenInfo.qtPath = framework.frameworkDirectory;
+ deploymenInfo.qtPath.chop(5); // remove "/lib/"
+ }
+
+// qDebug() << "";
+// qDebug() << "deploy" << framework.frameworkName;
+
+ if (framework.installName.startsWith("/@executable_path/")) {
+ qDebug() << framework.frameworkName << "already deployed, skipping.";
+ continue;
+ }
+
+ // Install_name_tool the new id into the binary
+ changeInstallName(framework.installName, framework.deployedInstallName, binaryPath);
+
+ // Copy farmework to app bundle.
+ const QString deployedBinaryPath = copyFramework(framework, bundlePath);
+ // Skip the rest if already was deployed.
+ if (deployedBinaryPath == QString())
+ continue;
+
+ runStrip(deployedBinaryPath);
+
+ // Install_name_tool it a new id.
+ changeIdentification(framework.deployedInstallName, deployedBinaryPath);
+ // Check for framework dependencies
+ QList<FrameworkInfo> dependencies = getQtFrameworks(deployedBinaryPath);
+
+ foreach (FrameworkInfo dependency, dependencies) {
+// qDebug() << "dependent framework" << dependency.installName << deployedBinaryPath;
+ changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath);
+
+ // Deploy framework if neccesary.
+ if (copiedFrameworks.contains(dependency.frameworkName) == false && frameworks.contains(dependency) == false) {
+ frameworks.append(dependency);
+ }
+ }
+ }
+ deploymenInfo.deployedFrameworks = copiedFrameworks;
+ return deploymenInfo;
+}
+
+DeploymentInfo deployQtFrameworks(const QString &appBundlePath)
+{
+ ApplicationBundleInfo applicationBundle;
+ applicationBundle.path = appBundlePath;
+ applicationBundle.binaryPath = findAppBinary(appBundlePath);
+ return deployQtFrameworks(getQtFrameworks(applicationBundle.binaryPath), applicationBundle.path, applicationBundle.binaryPath);
+}
+
+void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pluginSourcePath, const QString pluginDestinationPath, DeploymentInfo deploymentInfo)
+{
+ QStringList plugins = QDir(pluginSourcePath).entryList(QStringList() << "*.dylib");
+
+ foreach (QString pluginName, plugins) {
+
+ // Skip some Qt plugins based on what frameworks were deployed:
+ //qDebug() << pluginSourcePath << deploymentInfo.pluginPath;
+
+ if (pluginSourcePath.contains(deploymentInfo.pluginPath)) {
+ QStringList deployedFrameworks = deploymentInfo.deployedFrameworks;
+
+ // Skip the debug versions of the plugins
+ if (pluginName.endsWith("_debug.dylib"))
+ continue;
+
+ // Skip the designer plugins
+ if (pluginSourcePath.contains("plugins/designer"))
+ continue;
+
+#ifndef QT_GRAPHICSSYSTEM_OPENGL
+ // SKip the opengl graphicssystem plugin when not in use.
+ if (pluginName.contains("libqglgraphicssystem"))
+ continue;
+#endif
+ // Deploy accessibility for Qt3Support only if the Qt3Support.framework is in use
+ if (deployedFrameworks.indexOf("Qt3Support.framework") == -1 && pluginName.contains("accessiblecompatwidgets"))
+ continue;
+
+ // Deploy the svg icon plugin if QtSvg.framework is in use.
+ if (deployedFrameworks.indexOf("QtSvg.framework") == -1 && pluginName.contains("svg"))
+ continue;
+
+ // Deploy the phonon plugins if phonon.framework is in use
+ if (deployedFrameworks.indexOf("phonon.framework") == -1 && pluginName.contains("phonon"))
+ continue;
+
+ // Deploy the sql plugins if QtSql.framework is in use
+ if (deployedFrameworks.indexOf("QtSql.framework") == -1 && pluginName.contains("sql"))
+ continue;
+
+ // Deploy the script plugins if QtScript.framework is in use
+ if (deployedFrameworks.indexOf("QtScript.framework") == -1 && pluginName.contains("script"))
+ continue;
+ }
+
+ QDir dir;
+ dir.mkpath(pluginDestinationPath);
+
+ const QString sourcePath = pluginSourcePath + "/" + pluginName;
+ const QString destinationPath = pluginDestinationPath + "/" + pluginName;
+ if (copyFilePrintStatus(sourcePath, destinationPath)) {
+
+ runStrip(destinationPath);
+
+ // Special case for the phonon plugin: CoreVideo is not available as a separate framework
+ // on panther, link against the QuartzCore framework instead. (QuartzCore contians CoreVideo.)
+ if (pluginName.contains("libphonon_qt7")) {
+ changeInstallName("/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo",
+ "/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore",
+ destinationPath);
+ }
+
+// qDebug() << "deploy plugin depedencies:";
+ QList<FrameworkInfo> frameworks = getQtFrameworks(destinationPath);
+// qDebug() << frameworks;
+ deployQtFrameworks(frameworks, appBundleInfo.path, destinationPath);
+// qDebug() << "deploy plugin depedencies done";
+ }
+ } // foreach plugins
+
+ QStringList subdirs = QDir(pluginSourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot);
+ foreach (const QString &subdir, subdirs)
+ deployPlugins(appBundleInfo, pluginSourcePath + "/" + subdir, pluginDestinationPath + "/" + subdir, deploymentInfo);
+}
+
+void createQtConf(const QString &appBundlePath)
+{
+ QByteArray contents = "[Paths]\nPlugins = PlugIns\n";
+ QString filePath = appBundlePath + "/Contents/Resources/";
+ QString fileName = filePath + "qt.conf";
+
+ QDir().mkpath(filePath);
+
+ QFile qtconf(fileName);
+ if (qtconf.exists()) {
+ qDebug() << "";
+ qDebug() << "Warning:" << fileName << "already exists, will not overwrite.";
+ qDebug() << "To make sure the plugins are loaded from the correct location,";
+ qDebug() << "please make sure qt.conf contains the following lines:";
+ qDebug() << contents;
+ qDebug() << "";
+ return;
+ }
+
+ qtconf.open(QIODevice::WriteOnly);
+ if (qtconf.write(contents) != -1) {
+ qDebug() << "";
+ qDebug() << "Created configuration file:" << fileName;
+ qDebug() << "This file sets the plugin search path to" << appBundlePath + "/Contents/PlugIns";
+ qDebug() << "";
+ }
+}
+
+void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo)
+{
+ ApplicationBundleInfo applicationBundle;
+ applicationBundle.path = appBundlePath;
+ applicationBundle.binaryPath = findAppBinary(appBundlePath);
+
+ const QString pluginDestinationPath = appBundlePath + "/" + "Contents/PlugIns";
+
+// qDebug() << "";
+// qDebug() << "recursively copying plugins from" << deploymentInfo.pluginPath << "to" << pluginDestinationPath;
+ deployPlugins(applicationBundle, deploymentInfo.pluginPath, pluginDestinationPath, deploymentInfo);
+}
+
+
+void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QString &appBinaryPath, const QString &absoluteQtPath)
+{
+ qDebug() << "Changing" << appBinaryPath << "to link against Qt in" << absoluteQtPath;
+ QString finalQtPath = absoluteQtPath;
+
+ if (absoluteQtPath.startsWith("/Library/Frameworks") == false)
+ finalQtPath += "/lib/";
+
+ foreach (FrameworkInfo framework, frameworks) {
+ const QString oldBinaryId = framework.installName;
+ const QString newBinaryId = finalQtPath + framework.frameworkName + framework.binaryPath;
+ qDebug() << "Changing" << oldBinaryId << "to" << newBinaryId;
+ changeInstallName(oldBinaryId, newBinaryId, appBinaryPath);
+ }
+}
+
+void changeQtFrameworks(const QString appPath, const QString &qtPath)
+{
+ const QString appBinaryPath = findAppBinary(appPath);
+ const QList<FrameworkInfo> qtFrameworks = getQtFrameworks(appBinaryPath);
+ const QString absoluteQtPath = QDir(qtPath).absolutePath();
+ changeQtFrameworks(qtFrameworks, appBinaryPath, absoluteQtPath);
+}
+
+
+void createDiskImage(const QString &appBundlePath)
+{
+ QString appBaseName = appBundlePath;
+ appBaseName.chop(4); // remove ".app" from end
+
+ QString dmgName = appBaseName + ".dmg";
+
+ QFile dmg(dmgName);
+
+ if (dmg.exists()) {
+ qDebug() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName();
+ } else {
+ qDebug() << "Creating disk image (.dmg) for" << appBundlePath;
+ }
+
+ // More dmg options can be found in the hdiutil man page.
+ QString options = QString("create %1.dmg -srcfolder %1.app -format UDZO -volname %1").arg(appBaseName);
+
+ QProcess hdutil;
+ hdutil.start("hdiutil", options.split(' '));
+ hdutil.waitForFinished(-1);
+}
diff --git a/tools/macdeployqt/shared/shared.h b/tools/macdeployqt/shared/shared.h
new file mode 100644
index 0000000..5f30dad
--- /dev/null
+++ b/tools/macdeployqt/shared/shared.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef MAC_DEPLOMYMENT_SHARED_H
+#define MAC_DEPLOMYMENT_SHARED_H
+
+#include <QString>
+#include <QStringList>
+#include <QDebug>
+
+extern bool runStripEnabled;
+
+class FrameworkInfo
+{
+public:
+ QString frameworkDirectory;
+ QString frameworkName;
+ QString frameworkPath;
+ QString binaryDirectory;
+ QString binaryName;
+ QString binaryPath;
+ QString version;
+ QString installName;
+ QString deployedInstallName;
+ QString sourceFilePath;
+ QString destinationDirectory;
+};
+
+bool operator==(const FrameworkInfo &a, const FrameworkInfo &b);
+QDebug operator<<(QDebug debug, const FrameworkInfo &info);
+
+class ApplicationBundleInfo
+{
+public:
+ QString path;
+ QString binaryPath;
+};
+
+class DeploymentInfo
+{
+public:
+ QString qtPath;
+ QString pluginPath;
+ QStringList deployedFrameworks;
+};
+
+
+inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info);
+
+void changeQtFrameworks(const QString appPath, const QString &qtPath);
+void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QString &appBinaryPath, const QString &qtPath);
+
+FrameworkInfo parseOtoolLibraryLine(const QString &line);
+QString findAppBinary(const QString &appBundlePath);
+QList<FrameworkInfo> getQtFrameworks(const QString &path);
+QList<FrameworkInfo> getQtFrameworks(const QStringList &otoolLines);
+QString copyFramework(const FrameworkInfo &framework, const QString path);
+DeploymentInfo deployQtFrameworks(const QString &appBundlePath);
+DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks, const QString &bundlePath, const QString &binaryPath);
+void createQtConf(const QString &appBundlePath);
+void deployPlugins(const QString &appBundlePath, DeploymentInfo deploymentInfo);
+void changeIdentification(const QString &id, const QString &binaryPath);
+void changeInstallName(const QString &oldName, const QString &newName, const QString &binaryPath);
+QString findAppBinary(const QString &appBundlePath);
+void createDiskImage(const QString &appBundlePath);
+
+#endif
diff --git a/tools/macdeployqt/tests/deployment_mac.pro b/tools/macdeployqt/tests/deployment_mac.pro
new file mode 100644
index 0000000..1bde1fd
--- /dev/null
+++ b/tools/macdeployqt/tests/deployment_mac.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+DEPENDPATH += . ../shared/
+INCLUDEPATH += . ../shared/
+TARGET=tst_deployment_mac
+CONFIG += qtestlib
+
+# Input
+SOURCES += tst_deployment_mac.cpp ../shared/shared.cpp
+HEADERS += ../shared/shared.h
+
diff --git a/tools/macdeployqt/tests/tst_deployment_mac.cpp b/tools/macdeployqt/tests/tst_deployment_mac.cpp
new file mode 100644
index 0000000..5f9c990
--- /dev/null
+++ b/tools/macdeployqt/tests/tst_deployment_mac.cpp
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtCore>
+#include <QtTest/QTest>
+#include <shared.h>
+
+class tst_deployment_mac : public QObject
+{
+Q_OBJECT
+private slots:
+ void testParseOtoolLibraryLine();
+ void testgetQtFrameworks();
+ void testFindAppBinarty();
+};
+
+void tst_deployment_mac::testParseOtoolLibraryLine()
+{
+{
+ QString line = " /Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/"));
+ QCOMPARE(info.frameworkName, QLatin1String("QtGui.framework"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework"));
+ QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4"));
+ QCOMPARE(info.binaryName, QLatin1String("QtGui"));
+ QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/QtGui"));
+ QCOMPARE(info.version, QLatin1String("4"));
+ QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/QtGui.framework/Versions/4"));
+}
+{
+ QString line = " /Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/"));
+ QCOMPARE(info.frameworkName, QLatin1String("phonon.framework"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework"));
+ QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4"));
+ QCOMPARE(info.binaryName, QLatin1String("phonon"));
+ QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon"));
+ QCOMPARE(info.version, QLatin1String("4"));
+ QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4"));
+}
+
+{
+ QString line = " /usr/local/Trolltech/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/usr/local/Trolltech/Qt-4.4.0/lib/"));
+ QCOMPARE(info.frameworkName, QLatin1String("phonon.framework"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/usr/local/Trolltech/Qt-4.4.0/lib/phonon.framework"));
+ QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4"));
+ QCOMPARE(info.binaryName, QLatin1String("phonon"));
+ QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon"));
+ QCOMPARE(info.version, QLatin1String("4"));
+ QCOMPARE(info.installName, QLatin1String("/usr/local/Trolltech/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/usr/local/Trolltech/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4"));
+}
+
+{
+ QString line = " QtGui.framework/Versions/4/QtGui (compatibility version 4.1.0, current version 4.1.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/Library/Frameworks/"));
+ QCOMPARE(info.frameworkName, QLatin1String("QtGui.framework"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/Library/Frameworks/QtGui.framework"));
+ QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4"));
+ QCOMPARE(info.binaryName, QLatin1String("QtGui"));
+ QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/QtGui"));
+ QCOMPARE(info.version, QLatin1String("4"));
+ QCOMPARE(info.installName, QLatin1String("QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/Library/Frameworks/QtGui.framework/Versions/4/QtGui"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/QtGui.framework/Versions/4"));
+}
+
+{
+ QString line = " phonon.framework/Versions/4/QtGui (compatibility version 4.1.0, current version 4.1.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/Library/Frameworks/"));
+ QCOMPARE(info.frameworkName, QLatin1String("phonon.framework"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/Library/Frameworks/phonon.framework"));
+ QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4"));
+ QCOMPARE(info.binaryName, QLatin1String("phonon"));
+ QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon"));
+ QCOMPARE(info.version, QLatin1String("4"));
+ QCOMPARE(info.installName, QLatin1String("phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/Library/Frameworks/phonon.framework/Versions/4/phonon"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4"));
+}
+
+{
+ QString line = " /Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/"));
+ QCOMPARE(info.binaryName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(info.frameworkName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib"));
+ QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/libQtCLucene.4.dylib"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/"));
+}
+{
+ QString line = "libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)";
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+// qDebug() << info;
+ QCOMPARE(info.frameworkDirectory, QLatin1String("/usr/lib/"));
+ QCOMPARE(info.binaryName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(info.frameworkName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(info.frameworkPath, QLatin1String("/usr/lib/libQtCLucene.4.dylib"));
+ QCOMPARE(info.installName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/libQtCLucene.4.dylib"));
+ QCOMPARE(info.sourceFilePath, QLatin1String("/usr/lib/libQtCLucene.4.dylib"));
+ QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/"));
+}
+{
+ QString line = "/foo"; //invalid
+ FrameworkInfo info = parseOtoolLibraryLine(line);
+ QCOMPARE(info.frameworkName, QString());
+}
+
+}
+
+void tst_deployment_mac::testgetQtFrameworks()
+{
+{
+ QStringList otool = QStringList()
+ << "/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)"
+ << "/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)"
+ << "/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)"
+ << "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.27.0)"
+ << "/Users/foo/build/qt-4.4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.4.0, current version 4.4.0)"
+ << "/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)"
+ << "/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)"
+ << "/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)"
+ << "/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)"
+ << " "
+ ;
+
+ QList<FrameworkInfo> frameworks = getQtFrameworks(otool);
+ QCOMPARE(frameworks.count(), 3);
+ QCOMPARE(frameworks.at(0).binaryName, QLatin1String("phonon"));
+ QCOMPARE(frameworks.at(1).binaryName, QLatin1String("QtGui"));
+ QCOMPARE(frameworks.at(2).binaryName, QLatin1String("QtCore"));
+}
+{
+ QStringList otool = QStringList()
+ << "QtHelp.framework/Versions/4/QtHelp (compatibility version 4.4.0, current version 4.4.0)"
+ << "libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)"
+ << "QtSql.framework/Versions/4/QtSql (compatibility version 4.4.0, current version 4.4.0)"
+ << "QtXml.framework/Versions/4/QtXml (compatibility version 4.4.0, current version 4.4.0)"
+ << "QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)"
+ << "/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)"
+ << "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 824.42.0)"
+ << "QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.4.0, current version 4.4.0)"
+ << "QtCore.framework/Versions/4/QtCore (compatibility version 4.4.0, current version 4.4.0)"
+ << "/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)"
+ << "/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.6)"
+ << "/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)"
+ << "/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)"
+ ;
+
+ QList<FrameworkInfo> frameworks = getQtFrameworks(otool);
+ QCOMPARE(frameworks.count(), 7);
+ QCOMPARE(frameworks.at(0).binaryName, QLatin1String("QtHelp"));
+ QCOMPARE(frameworks.at(1).binaryName, QLatin1String("libQtCLucene.4.dylib"));
+ QCOMPARE(frameworks.at(2).binaryName, QLatin1String("QtSql"));
+ QCOMPARE(frameworks.at(3).binaryName, QLatin1String("QtXml"));
+ QCOMPARE(frameworks.at(4).binaryName, QLatin1String("QtGui"));
+ QCOMPARE(frameworks.at(5).binaryName, QLatin1String("QtNetwork"));
+ QCOMPARE(frameworks.at(6).binaryName, QLatin1String("QtCore"));
+}
+
+}
+
+void tst_deployment_mac::testFindAppBinarty()
+{
+ QCOMPARE(findAppBinary("tst_deployment_mac.app"), QLatin1String("tst_deployment_mac.app/Contents/MacOS/tst_deployment_mac"));
+}
+
+QTEST_MAIN(tst_deployment_mac)
+
+#include "tst_deployment_mac.moc" \ No newline at end of file