forked from qt-creator/qt-creator
Android: Fix android-*-deployment-settings.json detection
Qt 6.0 + CMake: The name for the Android deployment settings file needs to be determined by using the build key of the current run configuration rather than by using the display name of the project root node. Since in contrast to qmake/Qbs, CMake does not supply us with the file name and we have to contruct it ourselves. Therefore, it makes sense to move the value into the Android plugin. This change adds AndroidQtVersion::androidDeploymentSettings which lets qmake and Qbs still provide the value as before while handling the CMake fallback. Fixes: QTCREATORBUG-25209 Change-Id: I12314d06a45d6e045cb654d9140f9d2ed4602f67 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
#include "androidcreatekeystorecertificate.h"
|
#include "androidcreatekeystorecertificate.h"
|
||||||
#include "androidextralibrarylistmodel.h"
|
#include "androidextralibrarylistmodel.h"
|
||||||
#include "androidmanager.h"
|
#include "androidmanager.h"
|
||||||
|
#include "androidqtversion.h"
|
||||||
#include "androidsdkmanager.h"
|
#include "androidsdkmanager.h"
|
||||||
#include "certificatesmodel.h"
|
#include "certificatesmodel.h"
|
||||||
#include "createandroidmanifestwizard.h"
|
#include "createandroidmanifestwizard.h"
|
||||||
@@ -572,13 +573,9 @@ bool AndroidBuildApkStep::init()
|
|||||||
|
|
||||||
QString outputDir = buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
QString outputDir = buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
||||||
|
|
||||||
const QString buildKey = target()->activeBuildKey();
|
m_inputFile = AndroidQtVersion::androidDeploymentSettings(target()).toString();
|
||||||
const ProjectNode *node = project()->findNodeForBuildKey(buildKey);
|
|
||||||
if (node)
|
|
||||||
m_inputFile = node->data(Constants::AndroidDeploySettingsFile).toString();
|
|
||||||
|
|
||||||
if (m_inputFile.isEmpty()) {
|
if (m_inputFile.isEmpty()) {
|
||||||
qCDebug(buildapkstepLog) << "no input file" << node << buildKey;
|
qCDebug(buildapkstepLog) << "no input file" << target()->activeBuildKey();
|
||||||
m_skipBuilding = true;
|
m_skipBuilding = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ static QStringList getSoLibSearchPath(const ProjectNode *node)
|
|||||||
res.append(node->data(Constants::AndroidSoLibPath).toStringList());
|
res.append(node->data(Constants::AndroidSoLibPath).toStringList());
|
||||||
});
|
});
|
||||||
|
|
||||||
const QString jsonFile = node->data(Android::Constants::AndroidDeploySettingsFile).toString();
|
const QString jsonFile = AndroidQtVersion::androidDeploymentSettings(
|
||||||
|
node->getProject()->activeTarget()).toString();
|
||||||
QFile deploymentSettings(jsonFile);
|
QFile deploymentSettings(jsonFile);
|
||||||
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
if (deploymentSettings.open(QIODevice::ReadOnly)) {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "androidconstants.h"
|
#include "androidconstants.h"
|
||||||
#include "androidglobal.h"
|
#include "androidglobal.h"
|
||||||
#include "androidavdmanager.h"
|
#include "androidavdmanager.h"
|
||||||
|
#include "androidqtversion.h"
|
||||||
|
|
||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -200,7 +201,7 @@ bool AndroidDeployQtStep::init()
|
|||||||
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
m_command = AndroidConfigurations::currentConfig().adbToolPath();
|
||||||
AndroidManager::setManifestPath(target(), m_manifestName);
|
AndroidManager::setManifestPath(target(), m_manifestName);
|
||||||
} else {
|
} else {
|
||||||
QString jsonFile = node->data(Constants::AndroidDeploySettingsFile).toString();
|
QString jsonFile = AndroidQtVersion::androidDeploymentSettings(target()).toString();
|
||||||
if (jsonFile.isEmpty()) {
|
if (jsonFile.isEmpty()) {
|
||||||
const QString error = tr("Cannot find the androiddeploy Json file.");
|
const QString error = tr("Cannot find the androiddeploy Json file.");
|
||||||
emit addOutput(error, OutputFormat::Stderr);
|
emit addOutput(error, OutputFormat::Stderr);
|
||||||
|
|||||||
@@ -35,7 +35,9 @@
|
|||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
#include <qtsupport/qtversionmanager.h>
|
#include <qtsupport/qtversionmanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -169,6 +171,24 @@ int AndroidQtVersion::minimumNDK() const
|
|||||||
return m_minNdk;
|
return m_minNdk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::FilePath AndroidQtVersion::androidDeploymentSettings(const Target *target)
|
||||||
|
{
|
||||||
|
// Try to fetch the file name from node data as provided by qmake and Qbs
|
||||||
|
const QString buildKey = target->activeBuildKey();
|
||||||
|
const ProjectNode *node = target->project()->findNodeForBuildKey(buildKey);
|
||||||
|
if (node) {
|
||||||
|
const QString nameFromData = node->data(Constants::AndroidDeploySettingsFile).toString();
|
||||||
|
if (!nameFromData.isEmpty())
|
||||||
|
return Utils::FilePath::fromUserInput(nameFromData);
|
||||||
|
}
|
||||||
|
// If unavailable, construct the name by ourselves (CMake)
|
||||||
|
const BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||||
|
const bool isQt6 = qt && qt->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0};
|
||||||
|
return target->activeBuildConfiguration()->buildDirectory().pathAppended(
|
||||||
|
isQt6 ? QString::fromLatin1("android-%1-deployment-settings.json").arg(buildKey)
|
||||||
|
: QLatin1String("android_deployment_settings.json"));
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
||||||
{
|
{
|
||||||
m_androidAbis = evaluator->values("ALL_ANDROID_ABIS");
|
m_androidAbis = evaluator->values("ALL_ANDROID_ABIS");
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public:
|
|||||||
const QStringList &androidAbis() const;
|
const QStringList &androidAbis() const;
|
||||||
int minimumNDK() const;
|
int minimumNDK() const;
|
||||||
|
|
||||||
|
static Utils::FilePath androidDeploymentSettings(const ProjectExplorer::Target *target);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void parseMkSpec(ProFileEvaluator *) const override;
|
void parseMkSpec(ProFileEvaluator *) const override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -606,32 +606,12 @@ void CMakeBuildSystem::updateProjectData()
|
|||||||
auto newRoot = generateProjectTree(m_allFiles, true);
|
auto newRoot = generateProjectTree(m_allFiles, true);
|
||||||
if (newRoot) {
|
if (newRoot) {
|
||||||
setRootProjectNode(std::move(newRoot));
|
setRootProjectNode(std::move(newRoot));
|
||||||
CMakeConfigItem settingFileItem;
|
|
||||||
settingFileItem.key = Android::Constants::ANDROID_DEPLOYMENT_SETTINGS_FILE;
|
|
||||||
|
|
||||||
const FilePath buildDir = cmakeBuildConfiguration()->buildDirectory();
|
const FilePath buildDir = cmakeBuildConfiguration()->buildDirectory();
|
||||||
if (p->rootProjectNode()) {
|
if (p->rootProjectNode()) {
|
||||||
const QString nodeName = p->rootProjectNode()->displayName();
|
const QString nodeName = p->rootProjectNode()->displayName();
|
||||||
p->setDisplayName(nodeName);
|
p->setDisplayName(nodeName);
|
||||||
|
|
||||||
const Kit *k = kit();
|
|
||||||
if (DeviceTypeKitAspect::deviceTypeId(k) == Android::Constants::ANDROID_DEVICE_TYPE) {
|
|
||||||
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
|
||||||
if (qt && qt->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0}) {
|
|
||||||
const QLatin1String jsonFile("android-%1-deployment-settings.json");
|
|
||||||
settingFileItem.value = buildDir.pathAppended(jsonFile.arg(nodeName))
|
|
||||||
.toString()
|
|
||||||
.toUtf8();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settingFileItem.value.isEmpty()) {
|
|
||||||
settingFileItem.value = buildDir.pathAppended("android_deployment_settings.json")
|
|
||||||
.toString()
|
|
||||||
.toUtf8();
|
|
||||||
}
|
|
||||||
patchedConfig.append(settingFileItem);
|
|
||||||
|
|
||||||
for (const CMakeBuildTarget &bt : qAsConst(m_buildTargets)) {
|
for (const CMakeBuildTarget &bt : qAsConst(m_buildTargets)) {
|
||||||
const QString buildKey = bt.title;
|
const QString buildKey = bt.title;
|
||||||
|
|||||||
Reference in New Issue
Block a user