forked from qt-creator/qt-creator
Detect qt sub projects and special case their build directory
Check every project's path against the source paths of all existing qts. If we find a match, make it build in the right place by default. Works for both in source and shadow builds. Note: There's a quadratic algorithm since foreach kit we check against all qt versions. That's unlikely to be a problem and non trivial to fix. Change-Id: I9f3456f3e835ee6adc35c26fe5c328c01387a8aa Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -648,8 +648,22 @@ QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
|
||||
// Leave info->buildDirectory unset;
|
||||
info->kitId = k->id();
|
||||
info->supportsShadowBuild = (version && version->supportsShadowBuilds());
|
||||
|
||||
// check if this project is in the source directory:
|
||||
Utils::FileName projectFilePath = Utils::FileName::fromString(projectPath);
|
||||
if (version->isInSourceDirectory(projectFilePath)) {
|
||||
// assemble build directory
|
||||
QString projectDirectory = projectFilePath.toFileInfo().absolutePath();
|
||||
QDir qtSourceDir = QDir(version->sourcePath().toString());
|
||||
QString relativeProjectPath = qtSourceDir.relativeFilePath(projectDirectory);
|
||||
QString qtBuildDir = version->versionInfo().value(QStringLiteral("QT_INSTALL_PREFIX"));
|
||||
QString absoluteBuildPath = QDir::cleanPath(qtBuildDir + QLatin1Char('/') + relativeProjectPath);
|
||||
|
||||
info->buildDirectory = Utils::FileName::fromString(absoluteBuildPath);
|
||||
} else {
|
||||
info->buildDirectory
|
||||
= defaultBuildDirectory(info->supportsShadowBuild, projectPath, k, suffix);
|
||||
}
|
||||
info->type = type;
|
||||
return info;
|
||||
}
|
||||
@@ -682,7 +696,6 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableSetups(const Kit *k,
|
||||
QList<ProjectExplorer::BuildInfo *> result;
|
||||
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Debug);
|
||||
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Release);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <proparser/qmakevfs.h>
|
||||
#include <qtsupport/profilereader.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <qtsupport/uicodemodelsupport.h>
|
||||
#include <resourceeditor/resourcenode.h>
|
||||
|
||||
@@ -362,6 +363,10 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) :
|
||||
|
||||
connect(BuildManager::instance(), SIGNAL(buildQueueFinished(bool)),
|
||||
SLOT(buildFinished(bool)));
|
||||
|
||||
setPreferredKitMatcher(KitMatcher([this](const Kit *kit) -> bool {
|
||||
return matchesKit(kit);
|
||||
}));
|
||||
}
|
||||
|
||||
QmakeProject::~QmakeProject()
|
||||
@@ -1605,6 +1610,21 @@ void QmakeProject::collectLibraryData(const QmakeProFileNode *node, DeploymentDa
|
||||
}
|
||||
}
|
||||
|
||||
bool QmakeProject::matchesKit(const Kit *kit)
|
||||
{
|
||||
QList<QtSupport::BaseQtVersion *> parentQts;
|
||||
Utils::FileName filePath = projectFilePath();
|
||||
foreach (QtSupport::BaseQtVersion *version, QtSupport::QtVersionManager::validVersions()) {
|
||||
if (version->isInSourceDirectory(filePath))
|
||||
parentQts.append(version);
|
||||
}
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
||||
if (!parentQts.isEmpty())
|
||||
return parentQts.contains(version);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString QmakeProject::executableFor(const QmakeProFileNode *node)
|
||||
{
|
||||
const ProjectExplorer::Kit * const kit = activeTarget()->kit();
|
||||
|
||||
@@ -177,6 +177,7 @@ private:
|
||||
ProjectExplorer::DeploymentData &deploymentData);
|
||||
void collectLibraryData(const QmakeProFileNode *node,
|
||||
ProjectExplorer::DeploymentData &deploymentData);
|
||||
bool matchesKit(const ProjectExplorer::Kit *kit);
|
||||
|
||||
QmakeManager *m_manager;
|
||||
QmakeProFileNode *m_rootProjectNode;
|
||||
|
||||
@@ -1450,6 +1450,10 @@ FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &ver
|
||||
|
||||
FileName BaseQtVersion::sourcePath(const QHash<QString, QString> &versionInfo)
|
||||
{
|
||||
const QString qt5Source = qmakeProperty(versionInfo, "QT_INSTALL_PREFIX/src");
|
||||
if (!qt5Source.isEmpty())
|
||||
return Utils::FileName::fromString(qt5Source);
|
||||
|
||||
const QString installData = qmakeProperty(versionInfo, "QT_INSTALL_PREFIX");
|
||||
QString sourcePath = installData;
|
||||
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
|
||||
@@ -1471,6 +1475,18 @@ FileName BaseQtVersion::sourcePath(const QHash<QString, QString> &versionInfo)
|
||||
return FileName::fromUserInput(sourcePath);
|
||||
}
|
||||
|
||||
bool BaseQtVersion::isInSourceDirectory(const Utils::FileName &filePath)
|
||||
{
|
||||
const Utils::FileName &source = sourcePath();
|
||||
if (source.isEmpty())
|
||||
return false;
|
||||
QDir dir = QDir(source.toString());
|
||||
if (dir.dirName() == QLatin1String("qtbase"))
|
||||
dir.cdUp();
|
||||
|
||||
return filePath.isChildOf(dir);
|
||||
}
|
||||
|
||||
bool BaseQtVersion::isQmlDebuggingSupported(Kit *k, QString *reason)
|
||||
{
|
||||
QTC_ASSERT(k, return false);
|
||||
|
||||
@@ -124,6 +124,8 @@ public:
|
||||
virtual Utils::Environment qmakeRunEnvironment() const;
|
||||
|
||||
virtual Utils::FileName sourcePath() const;
|
||||
bool isInSourceDirectory(const Utils::FileName &filePath);
|
||||
|
||||
// used by UiCodeModelSupport
|
||||
virtual QString uicCommand() const;
|
||||
virtual QString designerCommand() const;
|
||||
|
||||
Reference in New Issue
Block a user