summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHonglei Zhang <honglei.zhang@nokia.com>2011-08-04 07:47:56 (GMT)
committerHonglei Zhang <honglei.zhang@nokia.com>2011-08-04 07:47:56 (GMT)
commit41c038dadb505d82447e1d9a8a743e0614c60098 (patch)
treec05e11632c8898db7d2e443f6cb09fda75592c14 /tools
parent8e2dc4ac2ec35e9b2f57ade5af390c2d44765382 (diff)
parent920ce5ed71bc456e429b887801a8d8bea7a3db0d (diff)
downloadQt-41c038dadb505d82447e1d9a8a743e0614c60098.zip
Qt-41c038dadb505d82447e1d9a8a743e0614c60098.tar.gz
Qt-41c038dadb505d82447e1d9a8a743e0614c60098.tar.bz2
Merge remote-tracking branch 'qt/4.8'
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/linguist/Info_mac.plist60
-rw-r--r--tools/linguist/linguist/main.cpp58
-rw-r--r--tools/macdeployqt/shared/shared.cpp128
-rw-r--r--tools/macdeployqt/shared/shared.h5
4 files changed, 212 insertions, 39 deletions
diff --git a/tools/linguist/linguist/Info_mac.plist b/tools/linguist/linguist/Info_mac.plist
index b11f493..b37a43b 100644
--- a/tools/linguist/linguist/Info_mac.plist
+++ b/tools/linguist/linguist/Info_mac.plist
@@ -14,5 +14,65 @@
<string>????</string>
<key>CFBundleExecutable</key>
<string>Linguist</string>
+
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleTypeIconFile</key>
+ <string>linguist.icns</string>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>qph</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>Qt Linguist 'Phrase Book'</string>
+ <key>LSHandlerRank</key>
+ <string>Default</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleTypeIconFile</key>
+ <string>linguist.icns</string>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>ts</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>Qt Translation Source</string>
+ <key>LSHandlerRank</key>
+ <string>Default</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleTypeIconFile</key>
+ <string>linguist.icns</string>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>po</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>GNU Gettext Localization File</string>
+ <key>LSHandlerRank</key>
+ <string>Default</string>
+ </dict>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleTypeIconFile</key>
+ <string>linguist.icns</string>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>xlf</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>XLIFF Localization File</string>
+ <key>LSHandlerRank</key>
+ <string>Default</string>
+ </dict>
+ </array>
</dict>
</plist>
diff --git a/tools/linguist/linguist/main.cpp b/tools/linguist/linguist/main.cpp
index a137f36..ba45613 100644
--- a/tools/linguist/linguist/main.cpp
+++ b/tools/linguist/linguist/main.cpp
@@ -54,8 +54,54 @@
#include <QtGui/QPixmap>
#include <QtGui/QSplashScreen>
+#ifdef Q_WS_MAC
+#include <QtCore/QUrl>
+#include <QtGui/QFileOpenEvent>
+#endif // Q_WS_MAC
+
QT_USE_NAMESPACE
+#ifdef Q_WS_MAC
+class ApplicationEventFilter : public QObject
+{
+ Q_OBJECT
+
+public:
+ ApplicationEventFilter()
+ : m_mainWindow(0)
+ {
+ }
+
+ void setMainWindow(MainWindow *mw)
+ {
+ m_mainWindow = mw;
+ if (!m_filesToOpen.isEmpty() && m_mainWindow) {
+ m_mainWindow->openFiles(m_filesToOpen);
+ m_filesToOpen.clear();
+ }
+ }
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event)
+ {
+ if (object == qApp && event->type() == QEvent::FileOpen) {
+ QFileOpenEvent *e = static_cast<QFileOpenEvent*>(event);
+ QString file = e->url().toLocalFile();
+ if (!m_mainWindow)
+ m_filesToOpen << file;
+ else
+ m_mainWindow->openFiles(QStringList() << file);
+ return true;
+ }
+ return QObject::eventFilter(object, event);
+ }
+
+private:
+ MainWindow *m_mainWindow;
+ QStringList m_filesToOpen;
+};
+#endif // Q_WS_MAC
+
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(linguist);
@@ -63,6 +109,11 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
QApplication::setOverrideCursor(Qt::WaitCursor);
+#ifdef Q_WS_MAC
+ ApplicationEventFilter eventFilter;
+ app.installEventFilter(&eventFilter);
+#endif // Q_WS_MAC
+
QStringList files;
QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
QStringList args = app.arguments();
@@ -111,6 +162,9 @@ int main(int argc, char **argv)
splash->show();
MainWindow mw;
+#ifdef Q_WS_MAC
+ eventFilter.setMainWindow(&mw);
+#endif // Q_WS_MAC
mw.show();
splash->finish(&mw);
QApplication::restoreOverrideCursor();
@@ -119,3 +173,7 @@ int main(int argc, char **argv)
return app.exec();
}
+
+#ifdef Q_WS_MAC
+#include "main.moc"
+#endif // Q_WS_MAC
diff --git a/tools/macdeployqt/shared/shared.cpp b/tools/macdeployqt/shared/shared.cpp
index c411683..1a9a6ab 100644
--- a/tools/macdeployqt/shared/shared.cpp
+++ b/tools/macdeployqt/shared/shared.cpp
@@ -72,7 +72,7 @@ QDebug operator<<(QDebug debug, const FrameworkInfo &info)
debug << "Install name" << info.installName << "\n";
debug << "Deployed install name" << info.deployedInstallName << "\n";
debug << "Source file Path" << info.sourceFilePath << "\n";
- debug << "Deployed Directory (relative to bundle)" << info.destinationDirectory << "\n";
+ debug << "Destination Directory (relative to bundle)" << info.destinationDirectory << "\n";
return debug;
}
@@ -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;
}
@@ -111,7 +112,7 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, bool useDebugLibs)
// 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"))
+ || trimmed.startsWith("@executable_path") || trimmed.startsWith("@loader_path") || trimmed.startsWith("@rpath"))
return info;
enum State {QtPath, FrameworkName, DylibName, Version, End};
@@ -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;
@@ -238,11 +254,26 @@ QList<FrameworkInfo> getQtFrameworks(const QString &path, bool useDebugLibs)
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.
+ outputLines.removeFirst(); // frameworks and dylibs print install name of themselves first.
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)
{
@@ -264,32 +295,51 @@ void recursiveCopy(const QString &sourcePath, const QString &destinationPath)
QString copyFramework(const FrameworkInfo &framework, const QString path)
{
QString from = framework.sourceFilePath;
- QString toDir = path + "/" + framework.destinationDirectory;
- QString to = toDir + "/" + framework.binaryName;
- if (QFile::exists(from) == false) {
+ if (!QFile::exists(from)) {
LogError() << "no file at" << from;
return QString();
}
+ QFileInfo fromDirInfo(framework.frameworkPath + QLatin1Char('/')
+ + framework.binaryDirectory);
+ bool fromDirIsSymLink = fromDirInfo.isSymLink();
+ QString unresolvedToDir = path + "/" + framework.destinationDirectory;
+ QString resolvedToDir;
+ QString relativeLinkTarget; // will contain the link from Current to e.g. 4 in the Versions directory
+ if (fromDirIsSymLink) {
+ // handle the case where framework is referenced with Versions/Current
+ // which is a symbolic link, so copy to target and recreate as symbolic link
+ relativeLinkTarget = QDir(fromDirInfo.canonicalPath())
+ .relativeFilePath(QFileInfo(fromDirInfo.symLinkTarget()).canonicalFilePath());
+ resolvedToDir = QFileInfo(unresolvedToDir).path() + QLatin1Char('/') + relativeLinkTarget;
+ } else {
+ resolvedToDir = unresolvedToDir;
+ }
+
+ QString to = resolvedToDir + "/" + framework.binaryName;
+ // create the (non-symlink) dir
QDir dir;
- if (dir.mkpath(toDir) == false) {
+ if (!dir.mkpath(resolvedToDir)) {
LogError() << "could not create destination directory" << to;
return QString();
}
+ if (!QFile::exists(to)) { // copy the binary and resources if that wasn't done before
+ copyFilePrintStatus(from, to);
- if (QFile::exists(to)) {
- return QString();
+ const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
+ const QString resourcesDestianationPath = path + "/Contents/Frameworks/" + framework.frameworkName + "/Resources";
+ recursiveCopy(resourcesSourcePath, resourcesDestianationPath);
}
- copyFilePrintStatus(from, to);
-
- const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
- const QString resourcesDestianationPath = path + "/Contents/Frameworks/" + framework.frameworkName + "/Resources";
- recursiveCopy(resourcesSourcePath, resourcesDestianationPath);
-
+ // create the Versions/Current symlink dir if necessary
+ if (fromDirIsSymLink) {
+ QFile::link(relativeLinkTarget, unresolvedToDir);
+ LogNormal() << " linked:" << unresolvedToDir;
+ LogNormal() << " to" << resolvedToDir << "(" << relativeLinkTarget << ")";
+ }
return to;
}
@@ -312,13 +362,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,23 +396,23 @@ 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 deploymenInfo;
+ DeploymentInfo deploymentInfo;
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.isNull() && framework.frameworkName.contains("Qt")
+ if (deploymentInfo.qtPath.isNull() && framework.frameworkName.contains("Qt")
&& framework.frameworkDirectory.contains("/lib"))
{
- deploymenInfo.qtPath = framework.frameworkDirectory;
- deploymenInfo.qtPath.chop(5); // remove "/lib/"
+ deploymentInfo.qtPath = framework.frameworkDirectory;
+ deploymentInfo.qtPath.chop(5); // remove "/lib/"
}
if (framework.installName.startsWith("/@executable_path/")) {
@@ -370,7 +421,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 +437,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) {
@@ -394,8 +445,8 @@ DeploymentInfo deployQtFrameworks(QList<FrameworkInfo> frameworks,
}
}
}
- deploymenInfo.deployedFrameworks = copiedFrameworks;
- return deploymenInfo;
+ deploymentInfo.deployedFrameworks = copiedFrameworks;
+ return deploymentInfo;
}
DeploymentInfo deployQtFrameworks(const QString &appBundlePath, bool useDebugLibs)
@@ -403,7 +454,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 +464,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 +530,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 +580,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 +592,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);