forked from qt-creator/qt-creator
Handle Qt < 5.14.0 androiddeployqt settings file
This file is needed by cmake projects. Fixes: QTCREATORBUG-23306 Change-Id: Ie0ffd325ca01ac5638620c258d5e8ed5bbd3259e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
committed by
BogDan Vatra
parent
07544d4e07
commit
12c74e6664
@@ -221,11 +221,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;
|
||||
}
|
||||
@@ -237,7 +236,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()};
|
||||
@@ -353,6 +352,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);
|
||||
@@ -393,48 +394,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
|
||||
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
||||
if (!version)
|
||||
return false;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
Utils::FilePath androidLibsDir = bc->buildDirectory()
|
||||
.pathAppended("android-build/libs")
|
||||
.pathAppended(abi);
|
||||
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())
|
||||
@@ -453,7 +462,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());
|
||||
|
||||
Reference in New Issue
Block a user