diff options
Diffstat (limited to 'src/plugins/android/androidbuildapkstep.cpp')
-rw-r--r-- | src/plugins/android/androidbuildapkstep.cpp | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 0b8281fcb4..027de1edc9 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -226,11 +226,10 @@ bool AndroidBuildApkStep::init() QString outputDir = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString(); - QString inputFile; if (node) - inputFile = node->data(Constants::AndroidDeploySettingsFile).toString(); + m_inputFile = node->data(Constants::AndroidDeploySettingsFile).toString(); - if (inputFile.isEmpty()) { + if (m_inputFile.isEmpty()) { m_skipBuilding = true; return true; } @@ -242,7 +241,7 @@ bool AndroidBuildApkStep::init() return false; } - QStringList arguments = {"--input", inputFile, + QStringList arguments = {"--input", m_inputFile, "--output", outputDir, "--android-platform", AndroidManager::buildTargetSDK(target()), "--jdk", AndroidConfigurations::currentConfig().openJDKLocation().toString()}; @@ -358,6 +357,8 @@ bool AndroidBuildApkStep::verifyCertificatePassword() static bool copyFileIfNewer(const QString &sourceFileName, const QString &destinationFileName) { + if (sourceFileName == destinationFileName) + return true; if (QFile::exists(destinationFileName)) { QFileInfo destinationFileInfo(destinationFileName); QFileInfo sourceFileInfo(sourceFileName); @@ -398,48 +399,56 @@ void AndroidBuildApkStep::doRun() if (!node) return false; - FilePath deploymentSettingsFile = FilePath::fromString(node->data(Android::Constants::AndroidDeploySettingsFile).toString()); - if (deploymentSettingsFile.exists()) - return true; // cmake creates this file for us + 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 auto targets = node->data(Android::Constants::AndroidTargets).toStringList(); if (targets.isEmpty()) - return true; // qmake does this job for us + return inputExists; // qmake does this job for us - QJsonObject deploySettings = Android::AndroidManager::deploymentSettings(target()); - QJsonObject architectures; - // Copy targets to android build folder - QString applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toFileInfo().fileName(); - for (const auto &abi : androidAbis) { - QString targetSuffix = QString{"_%1.so"}.arg(abi); - if (applicationBinary.endsWith(targetSuffix)) { - // Keep only TargetName from "lib[TargetName]_abi.so" - applicationBinary.remove(0, 3).chop(targetSuffix.size()); - } + QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit()); + if (!version) + return false; - Utils::FilePath androidLibsDir = bc->buildDirectory() - .pathAppended("android-build/libs") - .pathAppended(abi); + QJsonObject deploySettings = Android::AndroidManager::deploymentSettings(target()); + QString applicationBinary; + if (version->qtVersion() < QtSupport::QtVersionNumber(5, 14, 0)) { + QTC_ASSERT(androidAbis.size() == 1, return false); + applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toString(); + Utils::FilePath androidLibsDir = bc->buildDirectory().pathAppended("android-build/libs").pathAppended(androidAbis.first()); for (const auto &target : targets) { - if (target.endsWith(targetSuffix)) { - if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString())) - return false; - if (abi == "x86") { - architectures[abi] = "i686-linux-android"; - } else if (abi == "x86_64") { - architectures[abi] = "x86_64-linux-android"; - } else if (abi == "arm64-v8a") { - architectures[abi] = "aarch64-linux-android"; - } else { - architectures[abi] = "arm-linux-androideabi"; + if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString())) + return false; + } + deploySettings["target-architecture"] = androidAbis.first(); + } else { + applicationBinary = target()->activeRunConfiguration()->buildTargetInfo().targetFilePath.toFileInfo().fileName(); + QJsonObject architectures; + + // Copy targets to android build folder + for (const auto &abi : androidAbis) { + QString targetSuffix = QString{"_%1.so"}.arg(abi); + if (applicationBinary.endsWith(targetSuffix)) { + // Keep only TargetName from "lib[TargetName]_abi.so" + applicationBinary.remove(0, 3).chop(targetSuffix.size()); + } + + Utils::FilePath androidLibsDir = bc->buildDirectory() + .pathAppended("android-build/libs") + .pathAppended(abi); + for (const auto &target : targets) { + if (target.endsWith(targetSuffix)) { + if (!copyFileIfNewer(target, androidLibsDir.pathAppended(QFileInfo{target}.fileName()).toString())) + return false; + architectures[abi] = AndroidManager::archTriplet(abi); } } } + deploySettings["architectures"] = architectures; } - deploySettings["application-binary"] = applicationBinary; - deploySettings["architectures"] = architectures; QString extraLibs = node->data(Android::Constants::AndroidExtraLibs).toString(); if (!extraLibs.isEmpty()) @@ -458,7 +467,7 @@ void AndroidBuildApkStep::doRun() qmlRootPath = target()->project()->rootProjectDirectory().toString(); deploySettings["qml-root-path"] = qmlRootPath; - QFile f{deploymentSettingsFile.toString()}; + QFile f{m_inputFile}; if (!f.open(QIODevice::WriteOnly)) return false; f.write(QJsonDocument{deploySettings}.toJson()); |