diff options
author | Guilherme Steinmann <guidefloripa@gmail.com> | 2016-06-02 11:36:33 -0300 |
---|---|---|
committer | Guilherme Steinmann <guidefloripa@gmail.com> | 2016-07-27 12:04:34 +0000 |
commit | bda7ece99a8162118a91e9f475c149be39846ecd (patch) | |
tree | 48f8e16b00a333a7c1a71f2fdc17bf04e0527e62 | |
parent | fa17fe6d16891a786dfa457a3c13856ebe74925f (diff) | |
download | qttools-bda7ece99a8162118a91e9f475c149be39846ecd.tar.gz |
macdeployqt: add library search path
In earlier versions of OSX, the folder '/usr/lib/' is protected by
default and user libraries cannot be copied to that folder.
Alternatively, providing an option for alternative library search path
would avoid missing libraries during the deploy.
The addition of the option '-libpath=<path>' to macdeployqt adds a
search path for the dependencies. If a dependency was not found in the
provided path, the default folder for searching is used.
[ChangeLog][macdeployqt] Added option '-libpath' to search libraries in
a custom path.
Change-Id: I3afee6aaa3bc25521adecb91ec59d104e13834ed
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r-- | src/macdeployqt/macdeployqt/main.cpp | 9 | ||||
-rw-r--r-- | src/macdeployqt/shared/shared.cpp | 16 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/macdeployqt/macdeployqt/main.cpp b/src/macdeployqt/macdeployqt/main.cpp index 9a47e0f2c..8ccecfb9b 100644 --- a/src/macdeployqt/macdeployqt/main.cpp +++ b/src/macdeployqt/macdeployqt/main.cpp @@ -57,6 +57,7 @@ int main(int argc, char **argv) qDebug() << " -always-overwrite : Copy files even if the target file exists"; qDebug() << " -codesign=<ident> : Run codesign with the given identity on all executables"; qDebug() << " -appstore-compliant: Skip deployment of components that use private API"; + qDebug() << " -libpath=<path> : Add the given path to the library search path"; qDebug() << ""; qDebug() << "macdeployqt takes an application bundle as input and makes it"; qDebug() << "self-contained by copying in the Qt frameworks and plugins that"; @@ -90,6 +91,7 @@ int main(int argc, char **argv) bool useDebugLibs = false; extern bool runStripEnabled; extern bool alwaysOwerwriteEnabled; + extern QStringList librarySearchPath; QStringList additionalExecutables; bool qmldirArgumentUsed = false; QStringList qmlDirs; @@ -136,6 +138,13 @@ int main(int argc, char **argv) LogError() << "Missing qml directory path"; else qmlDirs << argument.mid(index+1); + } else if (argument.startsWith(QByteArray("-libpath"))) { + LogDebug() << "Argument found:" << argument; + int index = argument.indexOf('='); + if (index == -1) + LogError() << "Missing library search path"; + else + librarySearchPath << argument.mid(index+1); } else if (argument == QByteArray("-always-overwrite")) { LogDebug() << "Argument found:" << argument; alwaysOwerwriteEnabled = true; diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index 999342798..cb4599df3 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -56,6 +56,7 @@ bool runStripEnabled = true; bool alwaysOwerwriteEnabled = false; bool runCodesign = false; +QStringList librarySearchPath; QString codesignIdentiy; bool appstoreCompliant = false; int logLevel = 1; @@ -297,15 +298,26 @@ FrameworkInfo parseOtoolLibraryLine(const QString &line, const QString &appBundl } else if (trimmed.startsWith("/") == false) { // If the line does not contain a full path, the app is using a binary Qt package. QStringList partsCopy = parts; partsCopy.removeLast(); + foreach (QString path, librarySearchPath) { + if (!path.endsWith("/")) + path += '/'; + QString nameInPath = path + parts.join("/"); + if (QFile::exists(nameInPath)) { + info.frameworkDirectory = path + partsCopy.join("/"); + break; + } + } if (currentPart.contains(".framework")) { - info.frameworkDirectory = "/Library/Frameworks/" + partsCopy.join("/"); + if (info.frameworkDirectory.isEmpty()) + info.frameworkDirectory = "/Library/Frameworks/" + partsCopy.join("/"); if (!info.frameworkDirectory.endsWith("/")) info.frameworkDirectory += "/"; state = FrameworkName; --part; continue; } else if (currentPart.contains(".dylib")) { - info.frameworkDirectory = "/usr/lib/" + partsCopy.join("/"); + if (info.frameworkDirectory.isEmpty()) + info.frameworkDirectory = "/usr/lib/" + partsCopy.join("/"); if (!info.frameworkDirectory.endsWith("/")) info.frameworkDirectory += "/"; state = DylibName; |