forked from qt-creator/qt-creator
Android: Handle Qt 5 CMake projects target build dir retrieval
This makes sure that Qt 5 CMake android projects return the build dir and not the android build libs folder. Change-Id: I675e2ea2946beb63bbe08b9bf4b7d9603c386f09 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -51,6 +51,9 @@
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -253,10 +256,29 @@ FilePath AndroidManager::androidBuildDirectory(const Target *target)
|
||||
return buildDirectory(target) / Constants::ANDROID_BUILD_DIRECTORY;
|
||||
}
|
||||
|
||||
bool AndroidManager::isQt5CmakeProject(const ProjectExplorer::Target *target)
|
||||
{
|
||||
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
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);
|
||||
return isQt5 && isCmakeProject;
|
||||
}
|
||||
|
||||
FilePath AndroidManager::buildDirectory(const Target *target)
|
||||
{
|
||||
if (const BuildSystem *bs = target->buildSystem())
|
||||
return bs->buildTarget(target->activeBuildKey()).workingDirectory;
|
||||
if (const BuildSystem *bs = target->buildSystem()) {
|
||||
const QString buildKey = target->activeBuildKey();
|
||||
const FilePath buildDir = bs->buildTarget(target->activeBuildKey()).workingDirectory;
|
||||
if (isQt5CmakeProject(target)) {
|
||||
// Return the main build dir and not the android libs dir
|
||||
const QString libsDir = QString(Constants::ANDROID_BUILD_DIRECTORY) + "/libs";
|
||||
Utils::FilePath parentDuildDir = buildDir.parentDir();
|
||||
if (parentDuildDir.endsWith(libsDir) || libsDir.endsWith(libsDir + "/"))
|
||||
return parentDuildDir.parentDir().parentDir();
|
||||
}
|
||||
return buildDir;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -93,6 +93,8 @@ public:
|
||||
static QStringList applicationAbis(const ProjectExplorer::Target *target);
|
||||
static QString archTriplet(const QString &abi);
|
||||
|
||||
static bool isQt5CmakeProject(const ProjectExplorer::Target *target);
|
||||
|
||||
// TODO: remove this on 6.0 branch, kept here for binary compatibility for 5.0 release.
|
||||
static Utils::FilePath dirPath(const ProjectExplorer::Target *target);
|
||||
static Utils::FilePath androidBuildDirectory(const ProjectExplorer::Target *target);
|
||||
|
@@ -43,7 +43,6 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/buildsystem.h>
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <proparser/profileevaluator.h>
|
||||
|
||||
@@ -183,18 +182,15 @@ Utils::FilePath AndroidQtVersion::androidDeploymentSettings(const Target *target
|
||||
}
|
||||
|
||||
// If unavailable, construct the name by ourselves (CMake)
|
||||
const BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
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));
|
||||
const QString displayName = bs->buildTarget(buildKey).displayName;
|
||||
return AndroidManager::buildDirectory(target).pathAppended(
|
||||
AndroidManager::isQt5CmakeProject(target)
|
||||
? QLatin1String("android_deployment_settings.json")
|
||||
: QString::fromLatin1("android-%1-deployment-settings.json")
|
||||
.arg(displayName));
|
||||
}
|
||||
|
||||
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
||||
|
Reference in New Issue
Block a user