RemoteLinux: Use aspects more directly in RunConfiguration

This also unconditionally adds the X11ForwardingAspect.

Change-Id: I691d3b8fd8dc2c632938f256e34e3130c8524e5d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2023-07-14 11:28:59 +02:00
parent 0fdee5e000
commit 7a279669ef

View File

@@ -28,47 +28,45 @@ class RemoteLinuxRunConfiguration final : public RunConfiguration
{ {
public: public:
RemoteLinuxRunConfiguration(Target *target, Id id); RemoteLinuxRunConfiguration(Target *target, Id id);
RemoteLinuxEnvironmentAspect environment{this};
ExecutableAspect executable{this};
SymbolFileAspect symbolFile{this};
ArgumentsAspect arguments{this};
WorkingDirectoryAspect workingDir{this};
TerminalAspect terminal{this};
X11ForwardingAspect x11Forwarding{this};
UseLibraryPathsAspect useLibraryPath{this};
}; };
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(); environment.setDeviceSelector(target, EnvironmentAspect::RunDevice);
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
auto exeAspect = addAspect<ExecutableAspect>(); executable.setDeviceSelector(target, ExecutableAspect::RunDevice);
exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice); executable.setLabelText(Tr::tr("Executable on device:"));
exeAspect->setLabelText(Tr::tr("Executable on device:")); executable.setPlaceHolderText(Tr::tr("Remote path not set"));
exeAspect->setPlaceHolderText(Tr::tr("Remote path not set")); executable.makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",
exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",
"RemoteLinux.RunConfig.UseAlternateRemoteExecutable"); "RemoteLinux.RunConfig.UseAlternateRemoteExecutable");
exeAspect->setHistoryCompleter("RemoteLinux.AlternateExecutable.History"); executable.setHistoryCompleter("RemoteLinux.AlternateExecutable.History");
auto symbolsAspect = addAspect<SymbolFileAspect>(); symbolFile.setLabelText(Tr::tr("Executable on host:"));
symbolsAspect->setLabelText(Tr::tr("Executable on host:")); symbolFile.setDisplayStyle(SymbolFileAspect::LabelDisplay);
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
auto argsAspect = addAspect<ArgumentsAspect>(); arguments.setMacroExpander(macroExpander());
argsAspect->setMacroExpander(macroExpander());
auto workingDirAspect = addAspect<WorkingDirectoryAspect>(); workingDir.setMacroExpander(macroExpander());
workingDirAspect->setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment);
workingDirAspect->setEnvironment(envAspect);
if (HostOsInfo::isAnyUnixHost()) terminal.setVisible(HostOsInfo::isAnyUnixHost());
addAspect<TerminalAspect>();
if (HostOsInfo::isAnyUnixHost()) { x11Forwarding.setMacroExpander(macroExpander());
auto x11Forwarding = addAspect<X11ForwardingAspect>();
x11Forwarding->setMacroExpander(macroExpander());
}
auto libAspect = addAspect<UseLibraryPathsAspect>(); connect(&useLibraryPath, &BaseAspect::changed,
libAspect->setValue(false); &environment, &EnvironmentAspect::environmentChanged);
connect(libAspect, &UseLibraryPathsAspect::changed,
envAspect, &EnvironmentAspect::environmentChanged);
setUpdater([this, target, exeAspect, symbolsAspect, libAspect] { setUpdater([this, target] {
const IDeviceConstPtr buildDevice = BuildDeviceKitAspect::device(target->kit()); const IDeviceConstPtr buildDevice = BuildDeviceKitAspect::device(target->kit());
const IDeviceConstPtr runDevice = DeviceKitAspect::device(target->kit()); const IDeviceConstPtr runDevice = DeviceKitAspect::device(target->kit());
QTC_ASSERT(buildDevice, return); QTC_ASSERT(buildDevice, return);
@@ -78,15 +76,15 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
const DeploymentData deploymentData = target->deploymentData(); const DeploymentData deploymentData = target->deploymentData();
const DeployableFile depFile = deploymentData.deployableForLocalFile(localExecutable); const DeployableFile depFile = deploymentData.deployableForLocalFile(localExecutable);
exeAspect->setExecutable(runDevice->filePath(depFile.remoteFilePath())); executable.setExecutable(runDevice->filePath(depFile.remoteFilePath()));
symbolsAspect->setValue(localExecutable); symbolFile.setValue(localExecutable);
libAspect->setEnabled(buildDevice == runDevice); useLibraryPath.setEnabled(buildDevice == runDevice);
}); });
envAspect->addModifier([this, libAspect](Environment &env) { environment.addModifier([this](Environment &env) {
BuildTargetInfo bti = buildTargetInfo(); BuildTargetInfo bti = buildTargetInfo();
if (bti.runEnvModifier) if (bti.runEnvModifier)
bti.runEnvModifier(env, libAspect->value()); bti.runEnvModifier(env, useLibraryPath());
}); });
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);