Android: Throw an error if project uses versioned shared library

Android internally cannot handle versioned shared libraries.
There is no explicit rule for that, but indirect signs point to this.
This adds an explicit error to androiddeployqt to give the clear
understanding of the error nature to user. Error is also thrown if
versioned library was used when linking Qt libraries.

E.g. when linking Qt with liba.so it might be symlink to liba.so.1.0
This means that liba.so.1.0 Qt will require liba.so.1.0 at runtime.
But since Android doesn't handle versioned shared libraries,
liba.so.1.0 will never be packaged correctly. Most build systems
support generating of versionless shared libraries, and this should
be used when building 3rdparty libraries for Android.

Task-number: QTBUG-101346
Change-Id: Ic49d1a0d7d3a4c5c0dc308a570e98e8a0a223053
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2022-03-03 15:46:34 +01:00
parent 657cc31b8a
commit 2eb7a92aa3

View File

@ -1470,7 +1470,14 @@ bool updateLibsXml(Options *options)
qtLibs += QLatin1String(" <item>%1;%2</item>\n").arg(it.key(), options->stdCppName);
for (const Options::BundledFile &bundledFile : options->bundledFiles[it.key()]) {
if (bundledFile.second.startsWith(QLatin1String("lib/"))) {
if (bundledFile.second.startsWith(QLatin1String("lib/lib"))) {
if (!bundledFile.second.endsWith(QLatin1String(".so"))) {
fprintf(stderr,
"The bundled library %s doesn't end with .so. Android only supports "
"versionless libraries ending with the .so suffix.\n",
qPrintable(bundledFile.second));
return false;
}
QString s = bundledFile.second.mid(sizeof("lib/lib") - 1);
s.chop(sizeof(".so") - 1);
qtLibs += QLatin1String(" <item>%1;%2</item>\n").arg(it.key(), s);
@ -1480,9 +1487,18 @@ bool updateLibsXml(Options *options)
if (!options->archExtraLibs[it.key()].isEmpty()) {
for (const QString &extraLib : options->archExtraLibs[it.key()]) {
QFileInfo extraLibInfo(extraLib);
QString name = extraLibInfo.fileName().mid(sizeof("lib") - 1);
name.chop(sizeof(".so") - 1);
extraLibs += QLatin1String(" <item>%1;%2</item>\n").arg(it.key(), name);
if (extraLibInfo.fileName().startsWith(QLatin1String("lib"))) {
if (!extraLibInfo.fileName().endsWith(QLatin1String(".so"))) {
fprintf(stderr,
"The library %s doesn't end with .so. Android only supports "
"versionless libraries ending with the .so suffix.\n",
qPrintable(extraLibInfo.fileName()));
return false;
}
QString name = extraLibInfo.fileName().mid(sizeof("lib") - 1);
name.chop(sizeof(".so") - 1);
extraLibs += QLatin1String(" <item>%1;%2</item>\n").arg(it.key(), name);
}
}
}