Source

Target

Commits (1)
Showing with 23 additions and 12 deletions
...@@ -58,6 +58,7 @@ int main(int argc, char **argv) ...@@ -58,6 +58,7 @@ int main(int argc, char **argv)
qDebug() << " -use-debug-libs : Deploy with debug versions of frameworks and plugins (implies -no-strip)"; qDebug() << " -use-debug-libs : Deploy with debug versions of frameworks and plugins (implies -no-strip)";
qDebug() << " -executable=<path> : Let the given executable use the deployed frameworks too"; qDebug() << " -executable=<path> : Let the given executable use the deployed frameworks too";
qDebug() << " -qmldir=<path> : Deploy imports used by .qml files in the given path"; qDebug() << " -qmldir=<path> : Deploy imports used by .qml files in the given path";
qDebug() << " -always-overwrite : Copy files enven if the target file exists";
qDebug() << ""; qDebug() << "";
qDebug() << "macdeployqt takes an application bundle as input and makes it"; qDebug() << "macdeployqt takes an application bundle as input and makes it";
qDebug() << "self-contained by copying in the Qt frameworks and plugins that"; qDebug() << "self-contained by copying in the Qt frameworks and plugins that";
...@@ -85,6 +86,7 @@ int main(int argc, char **argv) ...@@ -85,6 +86,7 @@ int main(int argc, char **argv)
bool dmg = false; bool dmg = false;
bool useDebugLibs = false; bool useDebugLibs = false;
extern bool runStripEnabled; extern bool runStripEnabled;
extern bool alwaysOwerwriteEnabled;
QStringList additionalExecutables; QStringList additionalExecutables;
QStringList qmlDirs; QStringList qmlDirs;
...@@ -126,6 +128,9 @@ int main(int argc, char **argv) ...@@ -126,6 +128,9 @@ int main(int argc, char **argv)
LogError() << "Missing qml directory path"; LogError() << "Missing qml directory path";
else else
qmlDirs << argument.mid(index+1); qmlDirs << argument.mid(index+1);
} else if (argument == QByteArray("-always-overwrite")) {
LogDebug() << "Argument found:" << argument;
alwaysOwerwriteEnabled = true;
} else if (argument.startsWith("-")) { } else if (argument.startsWith("-")) {
LogError() << "Unknown argument" << argument << "\n"; LogError() << "Unknown argument" << argument << "\n";
return 0; return 0;
...@@ -134,12 +139,8 @@ int main(int argc, char **argv) ...@@ -134,12 +139,8 @@ int main(int argc, char **argv)
DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath, additionalExecutables, useDebugLibs); DeploymentInfo deploymentInfo = deployQtFrameworks(appBundlePath, additionalExecutables, useDebugLibs);
if (plugins) { if (plugins && !deploymentInfo.qtPath.isEmpty()) {
if (deploymentInfo.qtPath.isEmpty()) deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins";
deploymentInfo.pluginPath = "/Developer/Applications/Qt/plugins"; // Assume binary package.
else
deploymentInfo.pluginPath = deploymentInfo.qtPath + "/plugins";
LogNormal(); LogNormal();
deployPlugins(appBundlePath, deploymentInfo, useDebugLibs); deployPlugins(appBundlePath, deploymentInfo, useDebugLibs);
createQtConf(appBundlePath); createQtConf(appBundlePath);
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "shared.h" #include "shared.h"
bool runStripEnabled = true; bool runStripEnabled = true;
bool alwaysOwerwriteEnabled = false;
int logLevel = 1; int logLevel = 1;
using std::cout; using std::cout;
...@@ -96,9 +97,15 @@ inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info) ...@@ -96,9 +97,15 @@ inline QDebug operator<<(QDebug debug, const ApplicationBundleInfo &info)
bool copyFilePrintStatus(const QString &from, const QString &to) bool copyFilePrintStatus(const QString &from, const QString &to)
{ {
if (QFile(to).exists()) { if (QFile(to).exists()) {
LogNormal() << "File exists, skip copy:" << to; if (alwaysOwerwriteEnabled) {
return false; QFile(to).remove();
} else if (QFile::copy(from, to)) { } else {
qDebug() << "File exists, skip copy:" << to;
return false;
}
}
if (QFile::copy(from, to)) {
QFile dest(to); QFile dest(to);
dest.setPermissions(dest.permissions() | QFile::WriteOwner | QFile::WriteUser); dest.setPermissions(dest.permissions() | QFile::WriteOwner | QFile::WriteUser);
LogNormal() << " copied:" << from; LogNormal() << " copied:" << from;
...@@ -384,7 +391,7 @@ QString copyFramework(const FrameworkInfo &framework, const QString path) ...@@ -384,7 +391,7 @@ QString copyFramework(const FrameworkInfo &framework, const QString path)
return QString(); return QString();
} }
if (!QFile::exists(to)) { // copy the binary and resources if that wasn't done before if (!QFile::exists(to) || alwaysOwerwriteEnabled) { // copy the binary and resources if that wasn't done before
copyFilePrintStatus(from, to); copyFilePrintStatus(from, to);
const QString resourcesSourcePath = framework.frameworkPath + "/Resources"; const QString resourcesSourcePath = framework.frameworkPath + "/Resources";
...@@ -532,7 +539,7 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringLis ...@@ -532,7 +539,7 @@ DeploymentInfo deployQtFrameworks(const QString &appBundlePath, const QStringLis
QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths QStringList allBinaryPaths = QStringList() << applicationBundle.binaryPath << applicationBundle.libraryPaths
<< additionalExecutables; << additionalExecutables;
QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, useDebugLibs); QList<FrameworkInfo> frameworks = getQtFrameworksForPaths(allBinaryPaths, useDebugLibs);
if (frameworks.isEmpty()) { if (frameworks.isEmpty() && !alwaysOwerwriteEnabled) {
LogWarning(); LogWarning();
LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath; LogWarning() << "Could not find any external Qt frameworks to deploy in" << appBundlePath;
LogWarning() << "Perhaps macdeployqt was already used on" << appBundlePath << "?"; LogWarning() << "Perhaps macdeployqt was already used on" << appBundlePath << "?";
...@@ -636,7 +643,7 @@ void createQtConf(const QString &appBundlePath) ...@@ -636,7 +643,7 @@ void createQtConf(const QString &appBundlePath)
QDir().mkpath(filePath); QDir().mkpath(filePath);
QFile qtconf(fileName); QFile qtconf(fileName);
if (qtconf.exists()) { if (qtconf.exists() && !alwaysOwerwriteEnabled) {
LogWarning(); LogWarning();
LogWarning() << fileName << "already exists, will not overwrite."; LogWarning() << fileName << "already exists, will not overwrite.";
LogWarning() << "To make sure the plugins are loaded from the correct location,"; LogWarning() << "To make sure the plugins are loaded from the correct location,";
...@@ -765,6 +772,9 @@ void createDiskImage(const QString &appBundlePath) ...@@ -765,6 +772,9 @@ void createDiskImage(const QString &appBundlePath)
QFile dmg(dmgName); QFile dmg(dmgName);
if (dmg.exists() && alwaysOwerwriteEnabled)
dmg.remove();
if (dmg.exists()) { if (dmg.exists()) {
LogNormal() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName(); LogNormal() << "Disk image already exists, skipping .dmg creation for" << dmg.fileName();
} else { } else {
......