ProjectExplorer: Move BuildSystem owership to BuildConfiguration

... or Target.

This patch moves build system from conceptually "one per project"
to "one per target (i.e. per project-and-kit)" or "per
BuildConfigurations" for targets where the builds differ
significantly.

Building requires usually items from the kit (Qt version, compiler,
...) so a target-agnostic build is practically almost always wrong.

Moving the build system to the target also has the potential
to solve issues caused by switching targets while parsing, that
used Project::activeTarget() regularly, with potentially different
results before and after the switch.

This patch might create performance/size regressions when several
targets are set up per project as the build system implementation's
internal data are duplicated in this case.

The idea is to fix that by sharing per-project pieces again in
the project implementation once these problems occur.

Change-Id: I87f640ce418b93175b5029124eaa55f3b8721dca
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-10-25 09:55:32 +02:00
parent 9073c46c9c
commit 2758682723
127 changed files with 2541 additions and 2532 deletions

View File

@@ -108,6 +108,8 @@ enum { debug = 0 };
QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, Core::Id id)
: BuildConfiguration(target, id)
{
m_buildSystem = new QmakeBuildSystem(this);
connect(this, &BuildConfiguration::buildDirectoryChanged,
this, &QmakeBuildConfiguration::emitProFileEvaluateNeeded);
connect(this, &BuildConfiguration::environmentChanged,
@@ -175,7 +177,10 @@ void QmakeBuildConfiguration::initialize()
updateCacheAndEmitEnvironmentChanged();
}
QmakeBuildConfiguration::~QmakeBuildConfiguration() = default;
QmakeBuildConfiguration::~QmakeBuildConfiguration()
{
delete m_buildSystem;
}
QVariantMap QmakeBuildConfiguration::toMap() const
{
@@ -219,6 +224,11 @@ void QmakeBuildConfiguration::qtVersionsChanged(const QList<int> &,const QList<i
emitProFileEvaluateNeeded();
}
BuildSystem *QmakeBuildConfiguration::buildSystem() const
{
return m_buildSystem;
}
NamedWidget *QmakeBuildConfiguration::createConfigWidget()
{
return new QmakeProjectConfigWidget(this);
@@ -255,8 +265,7 @@ void QmakeBuildConfiguration::setFileNodeBuild(FileNode *node)
QString QmakeBuildConfiguration::makefile() const
{
auto rootNode = dynamic_cast<QmakeProFileNode *>(target()->project()->rootProjectNode());
return rootNode ? rootNode->makefile() : QString();
return m_buildSystem->rootProFile()->singleVariableValue(Variable::Makefile);
}
BaseQtVersion::QmakeBuildConfigs QmakeBuildConfiguration::qmakeBuildConfiguration() const
@@ -277,10 +286,7 @@ void QmakeBuildConfiguration::setQMakeBuildConfiguration(BaseQtVersion::QmakeBui
void QmakeBuildConfiguration::emitProFileEvaluateNeeded()
{
Target *t = target();
Project *p = t->project();
if (t->activeBuildConfiguration() == this && p->activeTarget() == t)
static_cast<QmakeProject *>(p)->scheduleAsyncUpdate();
m_buildSystem->scheduleUpdateAllNowOrLater();
}
QString QmakeBuildConfiguration::unalignedBuildDirWarning()
@@ -341,6 +347,11 @@ QmakeMakeStep *QmakeBuildConfiguration::makeStep() const
return nullptr;
}
QmakeBuildSystem *QmakeBuildConfiguration::qmakeBuildSystem() const
{
return m_buildSystem;
}
// Returns true if both are equal.
QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportFrom(const QString &makefile, QString *errorString)
{