forked from qt-creator/qt-creator
CMake: Use setup functions for more plugin items
Change-Id: I48ff764248f29ef2a8f46757cba84705983c7740 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -271,11 +271,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const CMakeFormatterSettingsPage settingsPage;
|
void setupCMakeFormatter()
|
||||||
|
|
||||||
CMakeFormatter::CMakeFormatter()
|
|
||||||
{
|
{
|
||||||
|
static const CMakeFormatterSettingsPage theCMakeFormatterSettingsPage;
|
||||||
|
|
||||||
formatterSettings();
|
formatterSettings();
|
||||||
}
|
};
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -4,14 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Core { class IDocument; }
|
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeFormatter
|
void setupCMakeFormatter();
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMakeFormatter();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
#include "cmaketool.h"
|
#include "cmaketool.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/buildstep.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/processparameters.h>
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -27,7 +28,7 @@ namespace CMakeProjectManager::Internal {
|
|||||||
|
|
||||||
// CMakeInstallStep
|
// CMakeInstallStep
|
||||||
|
|
||||||
class CMakeInstallStep : public CMakeAbstractProcessStep
|
class CMakeInstallStep final : public CMakeAbstractProcessStep
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMakeInstallStep(BuildStepList *bsl, Id id)
|
CMakeInstallStep(BuildStepList *bsl, Id id)
|
||||||
@@ -112,7 +113,10 @@ QWidget *CMakeInstallStep::createConfigWidget()
|
|||||||
|
|
||||||
// CMakeInstallStepFactory
|
// CMakeInstallStepFactory
|
||||||
|
|
||||||
CMakeInstallStepFactory::CMakeInstallStepFactory()
|
class CMakeInstallStepFactory : public ProjectExplorer::BuildStepFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMakeInstallStepFactory()
|
||||||
{
|
{
|
||||||
registerStep<CMakeInstallStep>(Constants::CMAKE_INSTALL_STEP_ID);
|
registerStep<CMakeInstallStep>(Constants::CMAKE_INSTALL_STEP_ID);
|
||||||
setDisplayName(
|
setDisplayName(
|
||||||
@@ -120,6 +124,11 @@ CMakeInstallStepFactory::CMakeInstallStepFactory()
|
|||||||
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
|
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
|
||||||
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_DEPLOY});
|
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_DEPLOY});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupCMakeInstallStep()
|
||||||
|
{
|
||||||
|
static CMakeInstallStepFactory theCMakeInstallStepFactory;
|
||||||
|
}
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeInstallStepFactory : public ProjectExplorer::BuildStepFactory
|
void setupCMakeInstallStep();
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMakeInstallStepFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
|
||||||
|
#include <coreplugin/locator/ilocatorfilter.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
@@ -23,6 +25,8 @@ namespace CMakeProjectManager::Internal {
|
|||||||
|
|
||||||
using BuildAcceptor = std::function<void(const FilePath &, const QString &)>;
|
using BuildAcceptor = std::function<void(const FilePath &, const QString &)>;
|
||||||
|
|
||||||
|
// CMakeBuildTargetFilter
|
||||||
|
|
||||||
static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
@@ -80,7 +84,7 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
|||||||
return {{Sync(onSetup), storage}};
|
return {{Sync(onSetup), storage}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupFilter(ILocatorFilter *filter)
|
static void setupFilter(ILocatorFilter *filter)
|
||||||
{
|
{
|
||||||
const auto projectListUpdated = [filter] {
|
const auto projectListUpdated = [filter] {
|
||||||
filter->setEnabled(Utils::contains(ProjectManager::projects(),
|
filter->setEnabled(Utils::contains(ProjectManager::projects(),
|
||||||
@@ -92,10 +96,6 @@ void setupFilter(ILocatorFilter *filter)
|
|||||||
filter, projectListUpdated);
|
filter, projectListUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// BuildCMakeTargetLocatorFilter:
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void buildAcceptor(const FilePath &projectPath, const QString &displayName)
|
static void buildAcceptor(const FilePath &projectPath, const QString &displayName)
|
||||||
{
|
{
|
||||||
// Get the project containing the target selected
|
// Get the project containing the target selected
|
||||||
@@ -126,7 +126,10 @@ static void buildAcceptor(const FilePath &projectPath, const QString &displayNam
|
|||||||
buildStep->setBuildTargets(oldTargets);
|
buildStep->setBuildTargets(oldTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeBuildTargetFilter::CMakeBuildTargetFilter()
|
class CMakeBuildTargetFilter final : ILocatorFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMakeBuildTargetFilter()
|
||||||
{
|
{
|
||||||
setId("Build CMake target");
|
setId("Build CMake target");
|
||||||
setDisplayName(Tr::tr("Build CMake Target"));
|
setDisplayName(Tr::tr("Build CMake Target"));
|
||||||
@@ -136,16 +139,16 @@ CMakeBuildTargetFilter::CMakeBuildTargetFilter()
|
|||||||
setupFilter(this);
|
setupFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::LocatorMatcherTasks CMakeBuildTargetFilter::matchers()
|
private:
|
||||||
|
LocatorMatcherTasks matchers() final { return cmakeMatchers(&buildAcceptor); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// OpenCMakeTargetLocatorFilter
|
||||||
|
|
||||||
|
class CMakeOpenTargetFilter final : ILocatorFilter
|
||||||
{
|
{
|
||||||
return cmakeMatchers(&buildAcceptor);
|
public:
|
||||||
}
|
CMakeOpenTargetFilter()
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// OpenCMakeTargetLocatorFilter:
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
CMakeOpenTargetFilter::CMakeOpenTargetFilter()
|
|
||||||
{
|
{
|
||||||
setId("Open CMake target definition");
|
setId("Open CMake target definition");
|
||||||
setDisplayName(Tr::tr("Open CMake Target"));
|
setDisplayName(Tr::tr("Open CMake Target"));
|
||||||
@@ -155,9 +158,16 @@ CMakeOpenTargetFilter::CMakeOpenTargetFilter()
|
|||||||
setupFilter(this);
|
setupFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::LocatorMatcherTasks CMakeOpenTargetFilter::matchers()
|
private:
|
||||||
|
LocatorMatcherTasks matchers() final { return cmakeMatchers({}); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// Setup
|
||||||
|
|
||||||
|
void setupCMakeLocatorFilters()
|
||||||
{
|
{
|
||||||
return cmakeMatchers({});
|
static CMakeBuildTargetFilter theCMakeBuildTargetFilter;
|
||||||
|
static CMakeOpenTargetFilter theCMakeOpenTargetFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -3,26 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/locator/ilocatorfilter.h>
|
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeBuildTargetFilter : Core::ILocatorFilter
|
void setupCMakeLocatorFilters();
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMakeBuildTargetFilter();
|
|
||||||
|
|
||||||
private:
|
} // CMakeProjectManager::Internal
|
||||||
Core::LocatorMatcherTasks matchers() final;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMakeOpenTargetFilter : Core::ILocatorFilter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMakeOpenTargetFilter();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Core::LocatorMatcherTasks matchers() final;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace CMakeProjectManager::Internal
|
|
||||||
|
|||||||
@@ -51,12 +51,6 @@ public:
|
|||||||
Tr::tr("Build \"%1\""),
|
Tr::tr("Build \"%1\""),
|
||||||
Action::AlwaysEnabled/*handled manually*/
|
Action::AlwaysEnabled/*handled manually*/
|
||||||
};
|
};
|
||||||
|
|
||||||
CMakeInstallStepFactory installStepFactory;
|
|
||||||
CMakeBuildTargetFilter cMakeBuildTargetFilter;
|
|
||||||
CMakeOpenTargetFilter cMakeOpenTargetFilter;
|
|
||||||
|
|
||||||
CMakeFormatter cmakeFormatter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
||||||
@@ -77,9 +71,13 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
|||||||
|
|
||||||
setupCMakeBuildConfiguration();
|
setupCMakeBuildConfiguration();
|
||||||
setupCMakeBuildStep();
|
setupCMakeBuildStep();
|
||||||
|
setupCMakeInstallStep();
|
||||||
|
|
||||||
setupCMakeEditor();
|
setupCMakeEditor();
|
||||||
|
|
||||||
|
setupCMakeLocatorFilters();
|
||||||
|
setupCMakeFormatter();
|
||||||
|
|
||||||
d = new CMakeProjectPluginPrivate;
|
d = new CMakeProjectPluginPrivate;
|
||||||
|
|
||||||
setupCMakeManager();
|
setupCMakeManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user