Meson: Compactify MesonRunConfiguration setup

Change-Id: I10a600b601301283dbdc960d9e07e5587b52c031
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-05-25 09:23:04 +02:00
parent 6ab66690af
commit 4136b6e795
2 changed files with 47 additions and 61 deletions

View File

@@ -6,22 +6,22 @@
#include "mesonpluginconstants.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/desktoprunconfiguration.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <utils/environment.h>
#include <utils/hostosinfo.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace MesonProjectManager {
namespace Internal {
namespace MesonProjectManager::Internal {
MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id)
: RunConfiguration{target, id}
class MesonRunConfiguration final : public RunConfiguration
{
public:
MesonRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id)
{
auto envAspect = addAspect<EnvironmentAspect>();
envAspect->setSupportForBuildEnvironment(target);
@@ -35,7 +35,7 @@ MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id)
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
if (Utils::HostOsInfo::isMacHost()) {
if (HostOsInfo::isMacHost()) {
auto dyldAspect = addAspect<UseDyldSuffixAspect>();
connect(dyldAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
@@ -45,19 +45,13 @@ MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id)
});
}
envAspect->addModifier([this, libAspect](Utils::Environment &env) {
envAspect->addModifier([this, libAspect](Environment &env) {
BuildTargetInfo bti = buildTargetInfo();
if (bti.runEnvModifier)
bti.runEnvModifier(env, libAspect->value());
});
setUpdater([this] { updateTargetInformation(); });
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
}
void MesonRunConfiguration::updateTargetInformation()
{
setUpdater([this] {
if (!activeBuildSystem())
return;
@@ -66,7 +60,11 @@ void MesonRunConfiguration::updateTargetInformation()
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
emit aspect<EnvironmentAspect>()->environmentChanged();
});
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
}
};
MesonRunConfigurationFactory::MesonRunConfigurationFactory()
{
@@ -75,5 +73,4 @@ MesonRunConfigurationFactory::MesonRunConfigurationFactory()
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
} // namespace Internal
} // namespace MesonProjectManager
} // MesonProjectManager::Internal

View File

@@ -5,17 +5,7 @@
#include <projectexplorer/runconfiguration.h>
namespace MesonProjectManager {
namespace Internal {
class MesonRunConfiguration final : public ProjectExplorer::RunConfiguration
{
public:
MesonRunConfiguration(ProjectExplorer::Target *target, Utils::Id id);
private:
void updateTargetInformation();
};
namespace MesonProjectManager::Internal {
class MesonRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
{
@@ -23,5 +13,4 @@ public:
MesonRunConfigurationFactory();
};
} // namespace Internal
} // namespace MesonProjectManager
} // MesonProjectManager::Internal