ProjectExplorer: Use a functor for BuildSystem creation

... instead of creating the BuildSystem direct. This will help the
shift of BuildSystem owner ship as a Project will have potentially
multiple BuildSystem instances (one per BuildConfiguration), but
still be responsible for creating them with the Targets.

Change-Id: I2dd71c7687ed41af9e42c874b3f932ce704e7ee3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-10-23 08:47:05 +02:00
parent 5b815d22a3
commit 6a878c7293
16 changed files with 34 additions and 33 deletions

View File

@@ -365,8 +365,8 @@ QbsRootProjectNode::QbsRootProjectNode(QbsProject *project) :
// QbsBuildSystem:
// --------------------------------------------------------------------
QbsBuildSystem::QbsBuildSystem(QbsProject *project)
: BuildSystem(project), m_project(project)
QbsBuildSystem::QbsBuildSystem(Project *project)
: BuildSystem(project)
{
}
@@ -449,7 +449,7 @@ RemovedFilesFromProject QbsBuildSystem::removeFiles(Node *context, const QString
return RemovedFilesFromProject::Error;
}
return m_project->removeFilesFromProduct(filePaths, prdNode->qbsProductData(),
return project()->removeFilesFromProduct(filePaths, prdNode->qbsProductData(),
n->m_qbsGroupData, notRemoved);
}
@@ -486,7 +486,7 @@ bool QbsBuildSystem::renameFile(Node *context, const QString &filePath, const QS
if (!prdNode || !prdNode->qbsProductData().isValid())
return false;
return m_project->renameFileInProduct(filePath, newFilePath,
return project()->renameFileInProduct(filePath, newFilePath,
prdNode->qbsProductData(), n->m_qbsGroupData);
}
@@ -502,5 +502,10 @@ bool QbsBuildSystem::renameFile(Node *context, const QString &filePath, const QS
return BuildSystem::renameFile(context, filePath, newFilePath);
}
QbsProject *QbsBuildSystem::project() const
{
return static_cast<QbsProject *>(BuildSystem::project());
}
} // namespace Internal
} // namespace QbsProjectManager

View File

@@ -39,7 +39,7 @@ class QbsProject;
class QbsBuildSystem : public ProjectExplorer::BuildSystem
{
public:
explicit QbsBuildSystem(QbsProject *project);
explicit QbsBuildSystem(ProjectExplorer::Project *project);
bool supportsAction(ProjectExplorer::Node *context,
ProjectExplorer::ProjectAction action,
@@ -53,8 +53,7 @@ public:
bool renameFile(ProjectExplorer::Node *context,
const QString &filePath, const QString &newFilePath) override;
private:
QbsProject *m_project = nullptr;
QbsProject *project() const;
};
// --------------------------------------------------------------------

View File

@@ -135,7 +135,7 @@ QbsProject::QbsProject(const FilePath &fileName)
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
setCanBuildProducts();
setBuildSystem(std::make_unique<QbsBuildSystem>(this));
setBuildSystemCreator([](Project *p) { return new QbsBuildSystem(p); });
rebuildProjectTree();