diff options
author | Filipe Azevedo <filipe.azevedo@kdab.com> | 2016-06-23 15:01:40 +0200 |
---|---|---|
committer | Filipe Azevedo <filipe.azevedo@kdab.com> | 2017-02-12 18:25:42 +0000 |
commit | 9db8c171e7bd775ed4cf5281fe17f8084c0ffbcd (patch) | |
tree | 518c2cc9ddb8c65276d6db3c1dcf8c247b2ad643 /src | |
parent | b2ffc4d0a0c7e498da68851b97963a8b7534847d (diff) |
Fix QLibrary::isLibrary on Apple platforms
Add proper support for 'so' and 'bundle' suffixes. Qt wrongly assumes
.so libraries are not versioned on Apple platforms, which is
wrong. Also, the shared library .bundle which is what Apple recommends
instead of .so, are also versioned (not to be confound with the
different Core Foundation bundles, which are directory hierarchy).
For more info, see http://docstore.mik.ua/orelly/unix3/mac/ch05_03.htm.
Especially the part that reads:
"Loadable modules, called bundles in Mac OS X, have the file type
MH_BUNDLE. Most Unix-based software ports usually produce bundles with a
.so extension, for the sake of consistency across platforms. Although
Apple recommends giving bundles a .bundle extension, it isn't
mandatory."
Task-number: QTBUG-50446
Change-Id: Iacd5136397a12d65d83821434f332eb602550b4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index aff2991ed1..96cf5371f9 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -617,40 +617,34 @@ bool QLibrary::isLibrary(const QString &fileName) { #if defined(Q_OS_WIN) return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive); -#else +#else // Generic Unix QString completeSuffix = QFileInfo(fileName).completeSuffix(); if (completeSuffix.isEmpty()) return false; const QVector<QStringRef> suffixes = completeSuffix.splitRef(QLatin1Char('.')); -# if defined(Q_OS_DARWIN) - - // On Mac, libs look like libmylib.1.0.0.dylib - const QStringRef &lastSuffix = suffixes.at(suffixes.count() - 1); - const QStringRef &firstSuffix = suffixes.at(0); - - bool valid = (lastSuffix == QLatin1String("dylib") - || firstSuffix == QLatin1String("so") - || firstSuffix == QLatin1String("bundle")); - - return valid; -# else // Generic Unix QStringList validSuffixList; -# if defined(Q_OS_HPUX) +# if defined(Q_OS_HPUX) /* See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF": "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit), the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix." */ validSuffixList << QLatin1String("sl"); -# if defined __ia64 +# if defined __ia64 validSuffixList << QLatin1String("so"); -# endif -# elif defined(Q_OS_AIX) +# endif +# elif defined(Q_OS_AIX) validSuffixList << QLatin1String("a") << QLatin1String("so"); -# elif defined(Q_OS_UNIX) +# elif defined(Q_OS_DARWIN) + // On Apple platforms, dylib look like libmylib.1.0.0.dylib + if (suffixes.last() == QLatin1String("dylib")) + return true; + + validSuffixList << QLatin1String("so") << QLatin1String("bundle"); +# elif defined(Q_OS_UNIX) validSuffixList << QLatin1String("so"); -# endif +# endif // Examples of valid library names: // libfoo.so @@ -669,9 +663,7 @@ bool QLibrary::isLibrary(const QString &fileName) if (i != suffixPos) suffixes.at(i).toInt(&valid); return valid; -# endif #endif - } typedef const char * (*QtPluginQueryVerificationDataFunction)(); |