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:
Tobias Hunger
2020-03-19 18:36:22 +01:00
parent 95947f280f
commit 10e79cebc9
6 changed files with 53 additions and 55 deletions

View File

@@ -36,9 +36,9 @@
#include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cppprojectupdater.h>
#include <cpptools/generatedcodemodelsupport.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -65,7 +65,6 @@ static Q_LOGGING_CATEGORY(cmakeBuildSystemLog, "qtc.cmake.buildsystem", QtWarnin
CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc)
: BuildSystem(bc)
, m_buildConfiguration(bc)
, m_buildDirManager(this)
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
{
@@ -545,14 +544,9 @@ void CMakeBuildSystem::handleParsingFailed(const QString &msg)
handleParsingError();
}
BuildConfiguration *CMakeBuildSystem::buildConfiguration() const
{
return m_buildConfiguration;
}
CMakeBuildConfiguration *CMakeBuildSystem::cmakeBuildConfiguration() const
{
return m_buildConfiguration;
return static_cast<CMakeBuildConfiguration *>(BuildSystem::buildConfiguration());
}
static Utils::FilePaths librarySearchPaths(const CMakeBuildSystem *bs, const QString &buildKey)

View File

@@ -36,10 +36,8 @@ class CppProjectUpdater;
} // namespace CppTools
namespace CMakeProjectManager {
class CMakeProject;
namespace Internal {
class CMakeBuildConfiguration;
// --------------------------------------------------------------------
@@ -80,7 +78,6 @@ public:
void handleParsingSuccess();
void handleParsingError();
ProjectExplorer::BuildConfiguration *buildConfiguration() const;
CMakeBuildConfiguration *cmakeBuildConfiguration() const;
const QList<ProjectExplorer::BuildTargetInfo> appTargets() const;
@@ -90,7 +87,7 @@ public:
private:
std::unique_ptr<CMakeProjectNode> generateProjectTree(
const QList<const ProjectExplorer::FileNode *> &allFiles);
const QList<const ProjectExplorer::FileNode *> &allFiles);
// Combining Treescanner and Parser states:
void combineScanAndParse();

View File

@@ -97,6 +97,11 @@ Kit *BuildSystem::kit() const
return d->m_target->kit();
}
BuildConfiguration *BuildSystem::buildConfiguration() const
{
return d->m_buildConfiguration;
}
void BuildSystem::emitParsingStarted()
{
QTC_ASSERT(!d->m_isParsing, return);

View File

@@ -54,6 +54,7 @@ public:
Project *project() const;
Target *target() const;
Kit *kit() const;
BuildConfiguration *buildConfiguration() const;
Utils::FilePath projectFilePath() const;
Utils::FilePath projectDirectory() const;

View File

@@ -25,13 +25,13 @@
#include "qmakeproject.h"
#include "qmakeprojectimporter.h"
#include "qmakebuildconfiguration.h"
#include "qmakebuildinfo.h"
#include "qmakestep.h"
#include "qmakenodes.h"
#include "qmakenodetreebuilder.h"
#include "qmakeprojectimporter.h"
#include "qmakeprojectmanagerconstants.h"
#include "qmakebuildconfiguration.h"
#include "qmakestep.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icontext.h>
@@ -180,10 +180,9 @@ DeploymentKnowledge QmakeProject::deploymentKnowledge() const
//
QmakeBuildSystem::QmakeBuildSystem(QmakeBuildConfiguration *bc)
: BuildSystem(bc),
m_qmakeVfs(new QMakeVfs),
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater),
m_buildConfiguration(bc)
: BuildSystem(bc)
, m_qmakeVfs(new QMakeVfs)
, m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
{
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
m_qmakeVfs->setTextCodec(codec);
@@ -195,16 +194,18 @@ QmakeBuildSystem::QmakeBuildSystem(QmakeBuildConfiguration *bc)
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
this, &QmakeBuildSystem::buildFinished);
connect(bc->target(), &Target::activeBuildConfigurationChanged,
this, [this](BuildConfiguration *bc) {
if (bc == m_buildConfiguration)
scheduleUpdateAllNowOrLater();
// FIXME: This is too eager in the presence of not handling updates
// when the build configuration is not active, see startAsyncTimer
// below.
// else
// m_cancelEvaluate = true;
});
connect(bc->target(),
&Target::activeBuildConfigurationChanged,
this,
[this](BuildConfiguration *bc) {
if (bc == buildConfiguration())
scheduleUpdateAllNowOrLater();
// FIXME: This is too eager in the presence of not handling updates
// when the build configuration is not active, see startAsyncTimer
// below.
// else
// m_cancelEvaluate = true;
});
connect(bc->project(), &Project::activeTargetChanged,
this, &QmakeBuildSystem::activeTargetWasChanged);
@@ -255,7 +256,7 @@ QmakeBuildSystem::~QmakeBuildSystem()
void QmakeBuildSystem::updateCodeModels()
{
if (!m_buildConfiguration->isActive())
if (!buildConfiguration()->isActive())
return;
updateCppCodeModel();
@@ -463,6 +464,11 @@ void QmakeBuildSystem::scheduleUpdateAllNowOrLater()
scheduleUpdateAll(QmakeProFile::ParseLater);
}
QmakeBuildConfiguration *QmakeBuildSystem::qmakeBuildConfiguration() const
{
return static_cast<QmakeBuildConfiguration *>(BuildSystem::buildConfiguration());
}
void QmakeBuildSystem::scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay)
{
if (m_asyncUpdateState == ShuttingDown)
@@ -491,10 +497,10 @@ void QmakeBuildSystem::scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay)
void QmakeBuildSystem::startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay)
{
if (!m_buildConfiguration->isActive()) {
if (!buildConfiguration()->isActive()) {
qCDebug(qmakeBuildSystemLog) << __FUNCTION__ << "skipped, not active";
return;
}
}
const int interval = qMin(parseDelay(),
delay == QmakeProFile::ParseLater ? UPDATE_INTERVAL : 0);
@@ -660,7 +666,7 @@ FilePath QmakeBuildSystem::buildDir(const FilePath &proFilePath) const
{
const QDir srcDirRoot = QDir(projectDirectory().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()
? projectDirectory().toString()
: buildConfigBuildDir;
@@ -681,7 +687,7 @@ QtSupport::ProFileReader *QmakeBuildSystem::createProFileReader(const QmakeProFi
QStringList qmakeArgs;
Kit *k = kit();
QmakeBuildConfiguration *bc = m_buildConfiguration;
QmakeBuildConfiguration *bc = qmakeBuildConfiguration();
Environment env = bc->environment();
if (QMakeStep *qs = bc->qmakeStep())
@@ -1248,12 +1254,7 @@ void QmakeBuildSystem::testToolChain(ToolChain *tc, const FilePath &path) const
return;
const Utils::FilePath expected = tc->compilerCommand();
Target *t = target();
QTC_ASSERT(t, return);
QTC_ASSERT(m_buildConfiguration, return);
Environment env = m_buildConfiguration->environment();
Environment env = buildConfiguration()->environment();
if (env.isSameExecutable(path.toString(), expected.toString()))
return;
@@ -1268,24 +1269,21 @@ void QmakeBuildSystem::testToolChain(ToolChain *tc, const FilePath &path) const
return;
}
TaskHub::addTask(
BuildSystemTask(Task::Warning,
QCoreApplication::translate(
"QmakeProjectManager",
"\"%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 "
"your target environment better.")
.arg(path.toUserOutput())
.arg(expected.toUserOutput())
.arg(t->kit()->displayName())));
BuildSystemTask(Task::Warning,
QCoreApplication::translate(
"QmakeProjectManager",
"\"%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 "
"your target environment better.")
.arg(path.toUserOutput())
.arg(expected.toUserOutput())
.arg(kit()->displayName())));
m_toolChainWarnings.insert(pair);
}
void QmakeBuildSystem::warnOnToolChainMismatch(const QmakeProFile *pro) const
{
const BuildConfiguration *bc = m_buildConfiguration;
if (!bc)
return;
const BuildConfiguration *bc = buildConfiguration();
testToolChain(ToolChainKitAspect::cToolChain(kit()), getFullPathOf(pro, Variable::QmakeCc, bc));
testToolChain(ToolChainKitAspect::cxxToolChain(kit()),
getFullPathOf(pro, Variable::QmakeCxx, bc));

View File

@@ -26,6 +26,7 @@
#pragma once
#include "qmakeprojectmanager_global.h"
#include "qmakenodes.h"
#include "qmakeparsernodes.h"
@@ -47,6 +48,7 @@ namespace ProjectExplorer { class DeploymentData; }
namespace QtSupport { class ProFileReader; }
namespace QmakeProjectManager {
class QmakeBuildConfiguration;
namespace Internal { class CentralizedFolderWatcher; }
@@ -172,6 +174,8 @@ public:
void scheduleUpdateAllNowOrLater();
Utils::FilePath buildDir(const Utils::FilePath &proFilePath) const;
QmakeBuildConfiguration *qmakeBuildConfiguration() const;
mutable QSet<const QPair<Utils::FilePath, Utils::FilePath>> m_toolChainWarnings;
// Current configuration
@@ -200,7 +204,6 @@ public:
Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher = nullptr;
ProjectExplorer::BuildSystem::ParseGuard m_guard;
QmakeBuildConfiguration *m_buildConfiguration = nullptr;
bool m_firstParseNeeded = true;
};