forked from qt-creator/qt-creator
Coco: Move some build step related code from plugin to cocobuildstep.cpp
Closer to the standard pattern. Change-Id: Ibbc34b66353e63009651e1593263c58d97ce917c Reviewed-by: Markus Redeker <markus.redeker@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -8,33 +8,23 @@
|
||||
#include "cocotr.h"
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
|
||||
#include <solutions/tasking/tasktree.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
namespace Coco::Internal {
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
QMakeStepFactory::QMakeStepFactory()
|
||||
{
|
||||
registerStep<CocoBuildStep>(Utils::Id{Constants::COCO_STEP_ID});
|
||||
setSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
setRepeatable(false);
|
||||
}
|
||||
|
||||
CMakeStepFactory::CMakeStepFactory()
|
||||
{
|
||||
registerStep<CocoBuildStep>(Utils::Id{Constants::COCO_STEP_ID});
|
||||
setSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
setRepeatable(false);
|
||||
}
|
||||
|
||||
CocoBuildStep *CocoBuildStep::create(BuildConfiguration *buildConfig)
|
||||
{
|
||||
// The "new" command creates a small memory leak which we can tolerate.
|
||||
@@ -122,4 +112,59 @@ Tasking::GroupItem CocoBuildStep::runRecipe()
|
||||
return Tasking::GroupItem({});
|
||||
}
|
||||
|
||||
// Factories
|
||||
|
||||
class QMakeStepFactory final : public BuildStepFactory
|
||||
{
|
||||
public:
|
||||
QMakeStepFactory()
|
||||
{
|
||||
registerStep<CocoBuildStep>(Utils::Id{Constants::COCO_STEP_ID});
|
||||
setSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
setRepeatable(false);
|
||||
}
|
||||
};
|
||||
|
||||
class CMakeStepFactory final : public BuildStepFactory
|
||||
{
|
||||
public:
|
||||
CMakeStepFactory()
|
||||
{
|
||||
registerStep<CocoBuildStep>(Utils::Id{Constants::COCO_STEP_ID});
|
||||
setSupportedProjectType(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
setRepeatable(false);
|
||||
}
|
||||
};
|
||||
|
||||
static void addBuildStep(Target *target)
|
||||
{
|
||||
for (BuildConfiguration *config : target->buildConfigurations()) {
|
||||
if (BuildSettings::supportsBuildConfig(*config)) {
|
||||
BuildStepList *steps = config->buildSteps();
|
||||
|
||||
if (!steps->contains(Constants::COCO_STEP_ID))
|
||||
steps->insertStep(0, CocoBuildStep::create(config));
|
||||
|
||||
steps->firstOfType<CocoBuildStep>()->display(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setupCocoBuildSteps()
|
||||
{
|
||||
static QMakeStepFactory theQmakeStepFactory;
|
||||
static CMakeStepFactory theCmakeStepFactory;
|
||||
|
||||
QObject::connect(ProjectManager::instance(), &ProjectManager::projectAdded, [&](Project *project) {
|
||||
if (Target *target = project->activeTarget())
|
||||
addBuildStep(target);
|
||||
|
||||
QObject::connect(project, &Project::addedTarget, [](Target *target) {
|
||||
addBuildStep(target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Coco::Internal
|
||||
|
@@ -15,18 +15,6 @@ class QPushButton;
|
||||
|
||||
namespace Coco::Internal {
|
||||
|
||||
class QMakeStepFactory: public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
QMakeStepFactory();
|
||||
};
|
||||
|
||||
class CMakeStepFactory: public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
CMakeStepFactory();
|
||||
};
|
||||
|
||||
class CocoBuildStep : public ProjectExplorer::BuildStep
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -56,4 +44,6 @@ private:
|
||||
QPushButton *m_reconfigureButton;
|
||||
};
|
||||
|
||||
void setupCocoBuildSteps();
|
||||
|
||||
} // namespace Coco::Internal
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -108,28 +107,13 @@ public:
|
||||
void addEntryToProjectSettings();
|
||||
|
||||
private:
|
||||
QMakeStepFactory m_qmakeStepFactory;
|
||||
CMakeStepFactory m_cmakeStepFactory;
|
||||
|
||||
CocoLanguageClient *m_client = nullptr;
|
||||
};
|
||||
|
||||
static void addBuildStep(Target *target)
|
||||
{
|
||||
for (BuildConfiguration *config : target->buildConfigurations()) {
|
||||
if (BuildSettings::supportsBuildConfig(*config)) {
|
||||
BuildStepList *steps = config->buildSteps();
|
||||
|
||||
if (!steps->contains(Constants::COCO_STEP_ID))
|
||||
steps->insertStep(0, CocoBuildStep::create(config));
|
||||
|
||||
steps->firstOfType<CocoBuildStep>()->display(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CocoPlugin::initialize()
|
||||
{
|
||||
setupCocoBuildSteps();
|
||||
|
||||
IOptionsPage::registerCategory(
|
||||
"I.Coco",
|
||||
QCoreApplication::translate("Coco", "Coco"),
|
||||
@@ -139,15 +123,6 @@ void CocoPlugin::initialize()
|
||||
GlobalSettingsPage::instance().widget();
|
||||
addEntryToProjectSettings();
|
||||
|
||||
connect(ProjectManager::instance(), &ProjectManager::projectAdded, this, [&](Project *project) {
|
||||
if (Target *target = project->activeTarget())
|
||||
addBuildStep(target);
|
||||
|
||||
connect(project, &Project::addedTarget, this, [](Target *target) {
|
||||
addBuildStep(target);
|
||||
});
|
||||
});
|
||||
|
||||
initLanguageServer();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user