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