Meson: Use setup functions for more plugin items

Change-Id: Ibbb2526d1db980389487e599ddf53e4785d97b5e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-29 16:23:03 +01:00
parent 9a44a543a5
commit 0ef72f3c6c
6 changed files with 58 additions and 36 deletions

View File

@@ -92,7 +92,7 @@ static FilePath machineFilesDir()
return Core::ICore::userResourcePath("Meson-machine-files");
}
FilePath MachineFileManager::machineFile(const Kit *kit)
static FilePath machineFile(const Kit *kit)
{
QTC_ASSERT(kit, return {});
auto baseName
@@ -101,6 +101,20 @@ FilePath MachineFileManager::machineFile(const Kit *kit)
return machineFilesDir().pathAppended(baseName);
}
// MachineFileManager
class MachineFileManager final : public QObject
{
public:
MachineFileManager();
private:
void addMachineFile(const Kit *kit);
void removeMachineFile(const Kit *kit);
void updateMachineFile(const Kit *kit);
void cleanupMachineFiles();
};
MachineFileManager::MachineFileManager()
{
connect(KitManager::instance(), &KitManager::kitAdded,
@@ -268,8 +282,7 @@ QStringList MesonBuildSystem::configArgs(bool isSetup)
if (!isSetup || params.contains("--cross-file") || params.contains("--native-file"))
return m_pendingConfigArgs + bc->mesonConfigArgs();
return QStringList{
QString("--native-file=%1").arg(MachineFileManager::machineFile(kit()).toString())}
return QStringList{QString("--native-file=%1").arg(machineFile(kit()).toString())}
+ m_pendingConfigArgs + bc->mesonConfigArgs();
}
@@ -332,4 +345,9 @@ void MesonBuildSystem::updateKit(ProjectExplorer::Kit *kit)
m_parser.setQtVersion(m_kitData.qtVersion);
}
void setupMesonBuildSystem()
{
static MachineFileManager theMachineFileManager;
}
} // MesonProjectManager::Internal

View File

@@ -17,20 +17,6 @@ namespace MesonProjectManager::Internal {
class MesonBuildConfiguration;
class MachineFileManager final : public QObject
{
public:
MachineFileManager();
static Utils::FilePath machineFile(const ProjectExplorer::Kit *kit);
private:
void addMachineFile(const ProjectExplorer::Kit *kit);
void removeMachineFile(const ProjectExplorer::Kit *kit);
void updateMachineFile(const ProjectExplorer::Kit *kit);
void cleanupMachineFiles();
};
class MesonBuildSystem final : public ProjectExplorer::BuildSystem
{
Q_OBJECT
@@ -68,4 +54,6 @@ private:
KitData m_kitData;
};
void setupMesonBuildSystem();
} // MesonProjectManager::Internal

View File

@@ -54,6 +54,8 @@ const char MESON_INFO[] = "meson-info.json";
const char MESON_TOOL_MANAGER[] = "MesonProjectManager.Tools";
const char MESON_BUILD_STEP_ID[] = "MesonProjectManager.BuildStep";
const char MESON_RUNCONFIG_ID[] = "MesonProjectManager.MesonRunConfiguration";
namespace Targets {
const char all[] = "all";
const char clean[] = "clean";

View File

@@ -10,17 +10,13 @@
#include "toolssettingsaccessor.h"
#include "toolssettingspage.h"
#include <debugger/debuggerruncontrol.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/runcontrol.h>
#include <utils/fsengine/fileiconprovider.h>
using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;
@@ -29,11 +25,7 @@ namespace MesonProjectManager::Internal {
class MesonProjectPluginPrivate
{
public:
MesonRunConfigurationFactory m_runConfigurationFactory;
MesonActionsManager m_actions;
MachineFileManager m_machineFilesManager;
SimpleTargetRunnerFactory m_mesonRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
SimpleDebugRunnerFactory m_mesonDebugRunWorkerFactory{{m_runConfigurationFactory.runConfigurationId()}};
};
class MesonProjectPlugin final : public ExtensionSystem::IPlugin
@@ -55,10 +47,15 @@ private:
setupToolsSettingsPage();
setupToolsSettingsAccessor();
setupMesonBuildSystem();
setupMesonBuildConfiguration();
setupNinjaBuildStep();
setupMesonRunConfiguration();
setupMesonRunAndDebugWorkers();
ProjectManager::registerProjectType<MesonProject>(Constants::Project::MIMETYPE);
FileIconProvider::registerIconOverlayForFilename(Constants::Icons::MESON, "meson.build");
FileIconProvider::registerIconOverlayForFilename(Constants::Icons::MESON, "meson_options.txt");
}

View File

@@ -7,11 +7,15 @@
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/target.h>
#include <utils/hostosinfo.h>
#include <debugger/debuggerruncontrol.h>
using namespace ProjectExplorer;
using namespace Utils;
@@ -75,11 +79,29 @@ public:
UseDyldSuffixAspect useDyldSuffix{this};
};
MesonRunConfigurationFactory::MesonRunConfigurationFactory()
// MesonRunConfigurationFactory
class MesonRunConfigurationFactory final : public RunConfigurationFactory
{
registerRunConfiguration<MesonRunConfiguration>("MesonProjectManager.MesonRunConfiguration");
addSupportedProjectType(Constants::Project::ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
public:
MesonRunConfigurationFactory()
{
registerRunConfiguration<MesonRunConfiguration>(Constants::MESON_RUNCONFIG_ID);
addSupportedProjectType(Constants::Project::ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
};
void setupMesonRunConfiguration()
{
static MesonRunConfigurationFactory theMesonRunConfigurationFactory;
}
void setupMesonRunAndDebugWorkers()
{
using namespace Debugger;
static SimpleTargetRunnerFactory theMesonRunWorkerFactory({Constants::MESON_RUNCONFIG_ID});
static SimpleDebugRunnerFactory theMesonDebugRunWorkerFactory({Constants::MESON_RUNCONFIG_ID});
}
} // MesonProjectManager::Internal

View File

@@ -3,14 +3,9 @@
#pragma once
#include <projectexplorer/runconfiguration.h>
namespace MesonProjectManager::Internal {
class MesonRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
{
public:
MesonRunConfigurationFactory();
};
void setupMesonRunConfiguration();
void setupMesonRunAndDebugWorkers();
} // MesonProjectManager::Internal