summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2021-05-25 19:34:25 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2021-06-28 10:29:01 +0000
commitf9a8e47d13b7fec4f26c9f641271843f9ca65394 (patch)
treeebd85c4b49c9f587157f34b1e1edced795faf1ec
parent03712d6a92fd8e590c989bfc59d8c6035704fc1a (diff)
downloadqt-creator-f9a8e47d13b7fec4f26c9f641271843f9ca65394.tar.gz
Android: Copy the target lib to android-build as part of the apk step
Make sure to copy the target's main lib file before building the APK. If the lib file is already there, i.e. copied by the underlying build system, this does nothing, but if the file is not copied by default like in cmake with Qt 6, this would copy it and would save us having to add *_prepare_apk_dir in cmake command. Also, this could allow us to remove the step "make install" from qmake step settings. After this we could revert 9dcbb8ca01e0981b6a3c7ea8dd278014343f48e3. Fixes: QTCREATORBUG-25367 Fixes: QTCREATORBUG-25216 Change-Id: I243a16a32e2ea97e175c893470480c9d2c9b1e27 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
-rw-r--r--src/plugins/android/androidbuildapkstep.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp
index d149b2033c..1e89531172 100644
--- a/src/plugins/android/androidbuildapkstep.cpp
+++ b/src/plugins/android/androidbuildapkstep.cpp
@@ -748,28 +748,54 @@ void AndroidBuildApkStep::doRun()
auto setup = [this] {
const auto androidAbis = AndroidManager::applicationAbis(target());
+ const QString buildKey = target()->activeBuildKey();
+
+ QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
+ if (!version)
+ return false;
+
for (const auto &abi : androidAbis) {
FilePath androidLibsDir = buildDirectory() / "android-build/libs" / abi;
- if (!androidLibsDir.exists() && !QDir{buildDirectory().toString()}.mkpath(androidLibsDir.toString()))
- return false;
- }
+ if (!androidLibsDir.exists()) {
+ if (!QDir{buildDirectory().toString()}.mkpath(androidLibsDir.toString())) {
+ const QString error = tr("The Android build folder %1 wasn't found and "
+ "couldn't be created.").arg(androidLibsDir.toString());
+ emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
+ TaskHub::addTask(BuildSystemTask(Task::Error, error));
+ return false;
+ } else if (version->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0}
+ && version->qtVersion() <= QtSupport::QtVersionNumber{6, 1, 1}) {
+ // 6.0.x <= Qt <= 6.1.1 used to need a manaul call to _prepare_apk_dir target,
+ // and now it's made directly with ALL target, so this code below ensures
+ // these versions are not broken.
+ const QString fileName = QString("lib%1_%2.so").arg(buildKey, abi);
+ const FilePath from = buildDirectory() / fileName;
+ const FilePath to = androidLibsDir / fileName;
+ if (!from.exists() || to.exists())
+ continue;
+
+ if (!QFile::copy(from.toString(), to.toString())) {
+ const QString error = tr("Couldn't copy the target's lib file %1 to the "
+ "Android build folder %2.")
+ .arg(fileName, androidLibsDir.toString());
+ emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
+ TaskHub::addTask(BuildSystemTask(Task::Error, error));
+ return false;
+ }
+ }
+ }
- const QString buildKey = target()->activeBuildKey();
- BuildSystem *bs = buildSystem();
+ }
bool inputExists = QFile::exists(m_inputFile);
if (inputExists && !AndroidManager::isQtCreatorGenerated(FilePath::fromString(m_inputFile)))
return true; // use the generated file if it was not generated by qtcreator
+ BuildSystem *bs = buildSystem();
auto targets = bs->extraData(buildKey, Android::Constants::AndroidTargets).toStringList();
if (targets.isEmpty())
return inputExists; // qmake does this job for us
-
- QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
- if (!version)
- return false;
-
QJsonObject deploySettings = Android::AndroidManager::deploymentSettings(target());
QString applicationBinary;
if (!version->supportsMultipleQtAbis()) {