forked from qt-creator/qt-creator
BuildSystem: Add buildConfiguration() method
Add a buildConfiguration method that returns the saved BuildConfiguration or the active BuildConfiguration if none is set. Change-Id: I8af25aa1037f59a0091900bac7eb84fed9e5fbb0 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -36,9 +36,9 @@
|
|||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <cpptools/cppprojectupdater.h>
|
#include <cpptools/cppprojectupdater.h>
|
||||||
#include <cpptools/generatedcodemodelsupport.h>
|
#include <cpptools/generatedcodemodelsupport.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
|
||||||
#include <projectexplorer/kitmanager.h>
|
#include <projectexplorer/kitmanager.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
|
||||||
@@ -65,7 +65,6 @@ static Q_LOGGING_CATEGORY(cmakeBuildSystemLog, "qtc.cmake.buildsystem", QtWarnin
|
|||||||
|
|
||||||
CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc)
|
CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc)
|
||||||
: BuildSystem(bc)
|
: BuildSystem(bc)
|
||||||
, m_buildConfiguration(bc)
|
|
||||||
, m_buildDirManager(this)
|
, m_buildDirManager(this)
|
||||||
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
|
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
|
||||||
{
|
{
|
||||||
@@ -545,14 +544,9 @@ void CMakeBuildSystem::handleParsingFailed(const QString &msg)
|
|||||||
handleParsingError();
|
handleParsingError();
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildConfiguration *CMakeBuildSystem::buildConfiguration() const
|
|
||||||
{
|
|
||||||
return m_buildConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMakeBuildConfiguration *CMakeBuildSystem::cmakeBuildConfiguration() const
|
CMakeBuildConfiguration *CMakeBuildSystem::cmakeBuildConfiguration() const
|
||||||
{
|
{
|
||||||
return m_buildConfiguration;
|
return static_cast<CMakeBuildConfiguration *>(BuildSystem::buildConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
static Utils::FilePaths librarySearchPaths(const CMakeBuildSystem *bs, const QString &buildKey)
|
static Utils::FilePaths librarySearchPaths(const CMakeBuildSystem *bs, const QString &buildKey)
|
||||||
|
|||||||
@@ -36,10 +36,8 @@ class CppProjectUpdater;
|
|||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
class CMakeProject;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CMakeBuildConfiguration;
|
class CMakeBuildConfiguration;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -80,7 +78,6 @@ public:
|
|||||||
void handleParsingSuccess();
|
void handleParsingSuccess();
|
||||||
void handleParsingError();
|
void handleParsingError();
|
||||||
|
|
||||||
ProjectExplorer::BuildConfiguration *buildConfiguration() const;
|
|
||||||
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
|
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
|
||||||
|
|
||||||
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
|
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
|
||||||
@@ -90,7 +87,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
||||||
const QList<const ProjectExplorer::FileNode *> &allFiles);
|
const QList<const ProjectExplorer::FileNode *> &allFiles);
|
||||||
|
|
||||||
// Combining Treescanner and Parser states:
|
// Combining Treescanner and Parser states:
|
||||||
void combineScanAndParse();
|
void combineScanAndParse();
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ Kit *BuildSystem::kit() const
|
|||||||
return d->m_target->kit();
|
return d->m_target->kit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BuildConfiguration *BuildSystem::buildConfiguration() const
|
||||||
|
{
|
||||||
|
return d->m_buildConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
void BuildSystem::emitParsingStarted()
|
void BuildSystem::emitParsingStarted()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_isParsing, return);
|
QTC_ASSERT(!d->m_isParsing, return);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public:
|
|||||||
Project *project() const;
|
Project *project() const;
|
||||||
Target *target() const;
|
Target *target() const;
|
||||||
Kit *kit() const;
|
Kit *kit() const;
|
||||||
|
BuildConfiguration *buildConfiguration() const;
|
||||||
|
|
||||||
Utils::FilePath projectFilePath() const;
|
Utils::FilePath projectFilePath() const;
|
||||||
Utils::FilePath projectDirectory() const;
|
Utils::FilePath projectDirectory() const;
|
||||||
|
|||||||
@@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
#include "qmakeproject.h"
|
#include "qmakeproject.h"
|
||||||
|
|
||||||
#include "qmakeprojectimporter.h"
|
#include "qmakebuildconfiguration.h"
|
||||||
#include "qmakebuildinfo.h"
|
#include "qmakebuildinfo.h"
|
||||||
#include "qmakestep.h"
|
|
||||||
#include "qmakenodes.h"
|
#include "qmakenodes.h"
|
||||||
#include "qmakenodetreebuilder.h"
|
#include "qmakenodetreebuilder.h"
|
||||||
|
#include "qmakeprojectimporter.h"
|
||||||
#include "qmakeprojectmanagerconstants.h"
|
#include "qmakeprojectmanagerconstants.h"
|
||||||
#include "qmakebuildconfiguration.h"
|
#include "qmakestep.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
@@ -180,10 +180,9 @@ DeploymentKnowledge QmakeProject::deploymentKnowledge() const
|
|||||||
//
|
//
|
||||||
|
|
||||||
QmakeBuildSystem::QmakeBuildSystem(QmakeBuildConfiguration *bc)
|
QmakeBuildSystem::QmakeBuildSystem(QmakeBuildConfiguration *bc)
|
||||||
: BuildSystem(bc),
|
: BuildSystem(bc)
|
||||||
m_qmakeVfs(new QMakeVfs),
|
, m_qmakeVfs(new QMakeVfs)
|
||||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater),
|
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
|
||||||
m_buildConfiguration(bc)
|
|
||||||
{
|
{
|
||||||
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
||||||
m_qmakeVfs->setTextCodec(codec);
|
m_qmakeVfs->setTextCodec(codec);
|
||||||
@@ -195,16 +194,18 @@ QmakeBuildSystem::QmakeBuildSystem(QmakeBuildConfiguration *bc)
|
|||||||
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
||||||
this, &QmakeBuildSystem::buildFinished);
|
this, &QmakeBuildSystem::buildFinished);
|
||||||
|
|
||||||
connect(bc->target(), &Target::activeBuildConfigurationChanged,
|
connect(bc->target(),
|
||||||
this, [this](BuildConfiguration *bc) {
|
&Target::activeBuildConfigurationChanged,
|
||||||
if (bc == m_buildConfiguration)
|
this,
|
||||||
scheduleUpdateAllNowOrLater();
|
[this](BuildConfiguration *bc) {
|
||||||
// FIXME: This is too eager in the presence of not handling updates
|
if (bc == buildConfiguration())
|
||||||
// when the build configuration is not active, see startAsyncTimer
|
scheduleUpdateAllNowOrLater();
|
||||||
// below.
|
// FIXME: This is too eager in the presence of not handling updates
|
||||||
// else
|
// when the build configuration is not active, see startAsyncTimer
|
||||||
// m_cancelEvaluate = true;
|
// below.
|
||||||
});
|
// else
|
||||||
|
// m_cancelEvaluate = true;
|
||||||
|
});
|
||||||
|
|
||||||
connect(bc->project(), &Project::activeTargetChanged,
|
connect(bc->project(), &Project::activeTargetChanged,
|
||||||
this, &QmakeBuildSystem::activeTargetWasChanged);
|
this, &QmakeBuildSystem::activeTargetWasChanged);
|
||||||
@@ -255,7 +256,7 @@ QmakeBuildSystem::~QmakeBuildSystem()
|
|||||||
|
|
||||||
void QmakeBuildSystem::updateCodeModels()
|
void QmakeBuildSystem::updateCodeModels()
|
||||||
{
|
{
|
||||||
if (!m_buildConfiguration->isActive())
|
if (!buildConfiguration()->isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCppCodeModel();
|
updateCppCodeModel();
|
||||||
@@ -463,6 +464,11 @@ void QmakeBuildSystem::scheduleUpdateAllNowOrLater()
|
|||||||
scheduleUpdateAll(QmakeProFile::ParseLater);
|
scheduleUpdateAll(QmakeProFile::ParseLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QmakeBuildConfiguration *QmakeBuildSystem::qmakeBuildConfiguration() const
|
||||||
|
{
|
||||||
|
return static_cast<QmakeBuildConfiguration *>(BuildSystem::buildConfiguration());
|
||||||
|
}
|
||||||
|
|
||||||
void QmakeBuildSystem::scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay)
|
void QmakeBuildSystem::scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay)
|
||||||
{
|
{
|
||||||
if (m_asyncUpdateState == ShuttingDown)
|
if (m_asyncUpdateState == ShuttingDown)
|
||||||
@@ -491,10 +497,10 @@ void QmakeBuildSystem::scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay)
|
|||||||
|
|
||||||
void QmakeBuildSystem::startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay)
|
void QmakeBuildSystem::startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay)
|
||||||
{
|
{
|
||||||
if (!m_buildConfiguration->isActive()) {
|
if (!buildConfiguration()->isActive()) {
|
||||||
qCDebug(qmakeBuildSystemLog) << __FUNCTION__ << "skipped, not active";
|
qCDebug(qmakeBuildSystemLog) << __FUNCTION__ << "skipped, not active";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int interval = qMin(parseDelay(),
|
const int interval = qMin(parseDelay(),
|
||||||
delay == QmakeProFile::ParseLater ? UPDATE_INTERVAL : 0);
|
delay == QmakeProFile::ParseLater ? UPDATE_INTERVAL : 0);
|
||||||
@@ -660,7 +666,7 @@ FilePath QmakeBuildSystem::buildDir(const FilePath &proFilePath) const
|
|||||||
{
|
{
|
||||||
const QDir srcDirRoot = QDir(projectDirectory().toString());
|
const QDir srcDirRoot = QDir(projectDirectory().toString());
|
||||||
const QString relativeDir = srcDirRoot.relativeFilePath(proFilePath.parentDir().toString());
|
const QString relativeDir = srcDirRoot.relativeFilePath(proFilePath.parentDir().toString());
|
||||||
const QString buildConfigBuildDir = m_buildConfiguration->buildDirectory().toString();
|
const QString buildConfigBuildDir = buildConfiguration()->buildDirectory().toString();
|
||||||
const QString buildDir = buildConfigBuildDir.isEmpty()
|
const QString buildDir = buildConfigBuildDir.isEmpty()
|
||||||
? projectDirectory().toString()
|
? projectDirectory().toString()
|
||||||
: buildConfigBuildDir;
|
: buildConfigBuildDir;
|
||||||
@@ -681,7 +687,7 @@ QtSupport::ProFileReader *QmakeBuildSystem::createProFileReader(const QmakeProFi
|
|||||||
QStringList qmakeArgs;
|
QStringList qmakeArgs;
|
||||||
|
|
||||||
Kit *k = kit();
|
Kit *k = kit();
|
||||||
QmakeBuildConfiguration *bc = m_buildConfiguration;
|
QmakeBuildConfiguration *bc = qmakeBuildConfiguration();
|
||||||
|
|
||||||
Environment env = bc->environment();
|
Environment env = bc->environment();
|
||||||
if (QMakeStep *qs = bc->qmakeStep())
|
if (QMakeStep *qs = bc->qmakeStep())
|
||||||
@@ -1248,12 +1254,7 @@ void QmakeBuildSystem::testToolChain(ToolChain *tc, const FilePath &path) const
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const Utils::FilePath expected = tc->compilerCommand();
|
const Utils::FilePath expected = tc->compilerCommand();
|
||||||
|
Environment env = buildConfiguration()->environment();
|
||||||
Target *t = target();
|
|
||||||
QTC_ASSERT(t, return);
|
|
||||||
|
|
||||||
QTC_ASSERT(m_buildConfiguration, return);
|
|
||||||
Environment env = m_buildConfiguration->environment();
|
|
||||||
|
|
||||||
if (env.isSameExecutable(path.toString(), expected.toString()))
|
if (env.isSameExecutable(path.toString(), expected.toString()))
|
||||||
return;
|
return;
|
||||||
@@ -1268,24 +1269,21 @@ void QmakeBuildSystem::testToolChain(ToolChain *tc, const FilePath &path) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TaskHub::addTask(
|
TaskHub::addTask(
|
||||||
BuildSystemTask(Task::Warning,
|
BuildSystemTask(Task::Warning,
|
||||||
QCoreApplication::translate(
|
QCoreApplication::translate(
|
||||||
"QmakeProjectManager",
|
"QmakeProjectManager",
|
||||||
"\"%1\" is used by qmake, but \"%2\" is configured in the kit.\n"
|
"\"%1\" is used by qmake, but \"%2\" is configured in the kit.\n"
|
||||||
"Please update your kit (%3) or choose a mkspec for qmake that matches "
|
"Please update your kit (%3) or choose a mkspec for qmake that matches "
|
||||||
"your target environment better.")
|
"your target environment better.")
|
||||||
.arg(path.toUserOutput())
|
.arg(path.toUserOutput())
|
||||||
.arg(expected.toUserOutput())
|
.arg(expected.toUserOutput())
|
||||||
.arg(t->kit()->displayName())));
|
.arg(kit()->displayName())));
|
||||||
m_toolChainWarnings.insert(pair);
|
m_toolChainWarnings.insert(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeBuildSystem::warnOnToolChainMismatch(const QmakeProFile *pro) const
|
void QmakeBuildSystem::warnOnToolChainMismatch(const QmakeProFile *pro) const
|
||||||
{
|
{
|
||||||
const BuildConfiguration *bc = m_buildConfiguration;
|
const BuildConfiguration *bc = buildConfiguration();
|
||||||
if (!bc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
testToolChain(ToolChainKitAspect::cToolChain(kit()), getFullPathOf(pro, Variable::QmakeCc, bc));
|
testToolChain(ToolChainKitAspect::cToolChain(kit()), getFullPathOf(pro, Variable::QmakeCc, bc));
|
||||||
testToolChain(ToolChainKitAspect::cxxToolChain(kit()),
|
testToolChain(ToolChainKitAspect::cxxToolChain(kit()),
|
||||||
getFullPathOf(pro, Variable::QmakeCxx, bc));
|
getFullPathOf(pro, Variable::QmakeCxx, bc));
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qmakeprojectmanager_global.h"
|
#include "qmakeprojectmanager_global.h"
|
||||||
|
|
||||||
#include "qmakenodes.h"
|
#include "qmakenodes.h"
|
||||||
#include "qmakeparsernodes.h"
|
#include "qmakeparsernodes.h"
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ namespace ProjectExplorer { class DeploymentData; }
|
|||||||
namespace QtSupport { class ProFileReader; }
|
namespace QtSupport { class ProFileReader; }
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
|
|
||||||
class QmakeBuildConfiguration;
|
class QmakeBuildConfiguration;
|
||||||
|
|
||||||
namespace Internal { class CentralizedFolderWatcher; }
|
namespace Internal { class CentralizedFolderWatcher; }
|
||||||
@@ -172,6 +174,8 @@ public:
|
|||||||
void scheduleUpdateAllNowOrLater();
|
void scheduleUpdateAllNowOrLater();
|
||||||
Utils::FilePath buildDir(const Utils::FilePath &proFilePath) const;
|
Utils::FilePath buildDir(const Utils::FilePath &proFilePath) const;
|
||||||
|
|
||||||
|
QmakeBuildConfiguration *qmakeBuildConfiguration() const;
|
||||||
|
|
||||||
mutable QSet<const QPair<Utils::FilePath, Utils::FilePath>> m_toolChainWarnings;
|
mutable QSet<const QPair<Utils::FilePath, Utils::FilePath>> m_toolChainWarnings;
|
||||||
|
|
||||||
// Current configuration
|
// Current configuration
|
||||||
@@ -200,7 +204,6 @@ public:
|
|||||||
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
|
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
|
||||||
|
|
||||||
ProjectExplorer::BuildSystem::ParseGuard m_guard;
|
ProjectExplorer::BuildSystem::ParseGuard m_guard;
|
||||||
QmakeBuildConfiguration *m_buildConfiguration = nullptr;
|
|
||||||
bool m_firstParseNeeded = true;
|
bool m_firstParseNeeded = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user