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/qtkitinformation.h>
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
|
||||||
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -253,10 +256,29 @@ FilePath AndroidManager::androidBuildDirectory(const Target *target)
|
|||||||
return buildDirectory(target) / Constants::ANDROID_BUILD_DIRECTORY;
|
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)
|
FilePath AndroidManager::buildDirectory(const Target *target)
|
||||||
{
|
{
|
||||||
if (const BuildSystem *bs = target->buildSystem())
|
if (const BuildSystem *bs = target->buildSystem()) {
|
||||||
return bs->buildTarget(target->activeBuildKey()).workingDirectory;
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -93,6 +93,8 @@ public:
|
|||||||
static QStringList applicationAbis(const ProjectExplorer::Target *target);
|
static QStringList applicationAbis(const ProjectExplorer::Target *target);
|
||||||
static QString archTriplet(const QString &abi);
|
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.
|
// 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 dirPath(const ProjectExplorer::Target *target);
|
||||||
static Utils::FilePath androidBuildDirectory(const ProjectExplorer::Target *target);
|
static Utils::FilePath androidBuildDirectory(const ProjectExplorer::Target *target);
|
||||||
|
@@ -43,7 +43,6 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <projectexplorer/buildsystem.h>
|
#include <projectexplorer/buildsystem.h>
|
||||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
|
||||||
|
|
||||||
#include <proparser/profileevaluator.h>
|
#include <proparser/profileevaluator.h>
|
||||||
|
|
||||||
@@ -183,18 +182,15 @@ Utils::FilePath AndroidQtVersion::androidDeploymentSettings(const Target *target
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If unavailable, construct the name by ourselves (CMake)
|
// 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();
|
const BuildSystem *bs = target->buildSystem();
|
||||||
if (!bs)
|
if (!bs)
|
||||||
return {};
|
return {};
|
||||||
const BuildTargetInfo buildTarget = bs->buildTarget(buildKey);
|
const QString displayName = bs->buildTarget(buildKey).displayName;
|
||||||
return buildTarget.workingDirectory.pathAppended((isQt5 && isCmakeProject)
|
return AndroidManager::buildDirectory(target).pathAppended(
|
||||||
? QLatin1String("android_deployment_settings.json")
|
AndroidManager::isQt5CmakeProject(target)
|
||||||
: QString::fromLatin1("android-%1-deployment-settings.json")
|
? QLatin1String("android_deployment_settings.json")
|
||||||
.arg(buildTarget.displayName));
|
: QString::fromLatin1("android-%1-deployment-settings.json")
|
||||||
|
.arg(displayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
|
||||||
|
Reference in New Issue
Block a user