Android: fix for retrieving the path to deployment file and build dir

The Android deployment file for CMake project was constructed based
on the main project target and thus was always expecting the file
to be under the build folder root path. This makes sure the correct
path to the output path is retrieved.

This practically different problems with running examples when the
main project is a Qt module, for both qmake and cmake.

Fixes: QTCREATORBUG-25793
Change-Id: I5fdedd94c7c4c84c351c28476ca14b0f95f99f22
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2021-08-23 21:36:55 +03:00
parent dc71f32483
commit a2b6dba0bc
8 changed files with 77 additions and 32 deletions

View File

@@ -42,6 +42,8 @@
#include <projectexplorer/kit.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/buildsystem.h>
#include <cmakeprojectmanager/cmakeprojectconstants.h>
#include <proparser/profileevaluator.h>
@@ -172,19 +174,27 @@ int AndroidQtVersion::minimumNDK() const
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();
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"));
const bool isQt5 = qt && qt->qtVersion() < QtSupport::QtVersionNumber{6, 0, 0};
const Core::Context cmakeCtx = Core::Context(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
const bool isCmakeProject = (target->project()->projectContext() == cmakeCtx);
const BuildSystem *bs = target->buildSystem();
if (!bs)
return {};
const BuildTargetInfo buildTarget = bs->buildTarget(buildKey);
return buildTarget.workingDirectory.pathAppended((isQt5 && isCmakeProject)
? QLatin1String("android_deployment_settings.json")
: QString::fromLatin1("android-%1-deployment-settings.json")
.arg(buildTarget.displayName));
}
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const