aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaphaël Cotty <raphael.cotty@gmail.com>2020-01-20 15:22:11 +0100
committerRaphaël Cotty <raphael.cotty@gmail.com>2020-02-04 12:40:58 +0000
commite130e492ebe6ad266a74df7b7d5efdef55dc0ff7 (patch)
treed46ae28bb6471b9dca6cccff316ac6842742ff6a /src
parent7811e70970294ff4c4c1fd76221727696e479cfb (diff)
Android: Update support to qt 5.14 and multi-arch apks for Qt apps
Before qt 5.14. The profile property "moduleProviders.Qt.qmakeFilePaths" is set with one or more paths to the different android architectures. Each qmake path belongs to a different android architecture installation. So each qmake is used to generated the Qt module corresponding to the architecture. Although qbs can generate multi-arch apks using multiplex mode, this is not possible when the project depends on qt libraries. This is because of the restriction of the qt tool androiddeployqt used by qbs. Now with qt 5.14. All android architectures are installed in the same directory. So the profile property "moduleProviders.Qt.qmakeFilePaths" is set with one qmake path. This directly impacts the qbs-setup-android tool and the generation of the Qt modules. Because qt libraries are installed in the the same directory, they have the abi in their name (libQt5Core_armeabi-v7a.so). So the rules that generate the apks are also impacted. The new androiddeployqt have a new interface (json config file format and requires to have the input libraries installed in the deployment directory) which allows the generation of multi-arch apks. So Qt.android_support modules needs to be updated as well. Fixes: QBS-1497 Change-Id: Ibd546f356c38a05f42dfcac0a4ec92bd82d6f700 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/app/qbs-setup-android/android-setup.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/app/qbs-setup-android/android-setup.cpp b/src/app/qbs-setup-android/android-setup.cpp
index 029628419..a0a9d2948 100644
--- a/src/app/qbs-setup-android/android-setup.cpp
+++ b/src/app/qbs-setup-android/android-setup.cpp
@@ -45,6 +45,7 @@
#include <tools/profile.h>
#include <tools/settings.h>
#include <tools/version.h>
+#include <tools/qttools.h>
#include <QtCore/qbytearraylist.h>
#include <QtCore/qcoreapplication.h>
@@ -94,10 +95,10 @@ static QString mapArch(const QString &androidName)
}
struct QtAndroidInfo {
- bool isValid() const { return !arch.isEmpty(); }
+ bool isValid() const { return !archs.isEmpty(); }
QString qmakePath;
- QString arch;
+ QStringList archs;
QString platform;
};
@@ -111,19 +112,30 @@ static QtAndroidInfo getInfoForQtDir(const QString &qtDir)
if (!qdevicepri.open(QIODevice::ReadOnly))
return info;
while (!qdevicepri.atEnd()) {
+ // For Qt < 5.14 use DEFAULT_ANDROID_TARGET_ARCH (which is the abi) to compute
+ // the architecture
+ // DEFAULT_ANDROID_ABIS doesn't exit
+ // For Qt >= 5.14:
+ // DEFAULT_ANDROID_TARGET_ARCH doesn't exist, use DEFAULT_ANDROID_ABIS to compute
+ // the architectures
const QByteArray line = qdevicepri.readLine().simplified();
const bool isArchLine = line.startsWith("DEFAULT_ANDROID_TARGET_ARCH");
+ const bool isAbisLine = line.startsWith("DEFAULT_ANDROID_ABIS");
const bool isPlatformLine = line.startsWith("DEFAULT_ANDROID_PLATFORM");
- if (!isArchLine && !isPlatformLine)
+ if (!isArchLine && !isPlatformLine && !isAbisLine)
continue;
const QList<QByteArray> elems = line.split('=');
if (elems.size() != 2)
continue;
const QString rhs = QString::fromLatin1(elems.at(1).trimmed());
- if (isArchLine)
- info.arch = mapArch(rhs);
- else
+ if (isArchLine) {
+ info.archs << mapArch(rhs);
+ } else if (isAbisLine) {
+ for (const QString &abi: rhs.split(QLatin1Char(' ')))
+ info.archs << mapArch(abi);
+ } else {
info.platform = rhs;
+ }
}
return info;
}
@@ -136,13 +148,16 @@ static QtInfoPerArch getQtAndroidInfo(const QString &qtSdkDir)
return archs;
QStringList qtDirs(qtSdkDir);
- QDirIterator dit(qtSdkDir, QStringList() << QStringLiteral("android_*"), QDir::Dirs);
+ const QStringList nameFilters{QStringLiteral("android_*"), QStringLiteral("android")};
+ QDirIterator dit(qtSdkDir, nameFilters, QDir::Dirs);
while (dit.hasNext())
qtDirs << dit.next();
for (const auto &qtDir : qtDirs) {
const QtAndroidInfo info = getInfoForQtDir(qtDir);
- if (info.isValid())
- archs.insert(info.arch, info);
+ if (info.isValid()) {
+ for (const QString &arch: info.archs)
+ archs.insert(arch, info);
+ }
}
return archs;
}
@@ -224,8 +239,10 @@ static void setupNdk(qbs::Settings *settings, const QString &profileName, const
qmakeFilePaths << qtAndroidInfo.qmakePath;
platform = maximumPlatform(platform, qtAndroidInfo.platform);
}
- if (!qmakeFilePaths.empty())
+ if (!qmakeFilePaths.empty()) {
+ qmakeFilePaths.removeDuplicates();
mainProfile.setValue(qls("moduleProviders.Qt.qmakeFilePaths"), qmakeFilePaths);
+ }
if (!platform.isEmpty())
mainProfile.setValue(qls("Android.ndk.platform"), platform);
}