ProjectExplorer: Use aspects more directly in customexe runconfig

Change-Id: I0c68c3a3b5fcaa0b25f12b9feed5023400e0bd00
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-07-12 17:31:24 +02:00
parent f31007f40a
commit f16f09c390
2 changed files with 22 additions and 26 deletions

View File

@@ -23,38 +23,27 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id)
{
auto envAspect = addAspect<EnvironmentAspect>();
envAspect->setSupportForBuildEnvironment(target);
environment.setSupportForBuildEnvironment(target);
auto exeAspect = addAspect<ExecutableAspect>();
exeAspect->setDeviceSelector(target, ExecutableAspect::HostDevice);
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
exeAspect->setReadOnly(false);
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");
exeAspect->setExpectedKind(PathChooser::ExistingCommand);
exeAspect->setEnvironment(envAspect->environment());
executable.setDeviceSelector(target, ExecutableAspect::HostDevice);
executable.setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
executable.setReadOnly(false);
executable.setHistoryCompleter("Qt.CustomExecutable.History");
executable.setExpectedKind(PathChooser::ExistingCommand);
executable.setEnvironment(environment.environment());
auto argsAspect = addAspect<ArgumentsAspect>();
argsAspect->setMacroExpander(macroExpander());
arguments.setMacroExpander(macroExpander());
auto workingDirAspect = addAspect<WorkingDirectoryAspect>();
workingDirAspect->setMacroExpander(macroExpander());
workingDirAspect->setEnvironment(envAspect);
workingDir.setMacroExpander(macroExpander());
workingDir.setEnvironment(&environment);
addAspect<TerminalAspect>();
connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] {
exeAspect->setEnvironment(envAspect->environment());
connect(&environment, &EnvironmentAspect::environmentChanged, this, [this] {
executable.setEnvironment(environment.environment());
});
setDefaultDisplayName(defaultDisplayName());
}
FilePath CustomExecutableRunConfiguration::executable() const
{
return aspect<ExecutableAspect>()->executable();
}
bool CustomExecutableRunConfiguration::isEnabled() const
{
return true;
@@ -64,8 +53,8 @@ Runnable CustomExecutableRunConfiguration::runnable() const
{
Runnable r;
r.command = commandLine();
r.environment = aspect<EnvironmentAspect>()->environment();
r.workingDirectory = aspect<WorkingDirectoryAspect>()->workingDirectory();
r.environment = environment.environment();
r.workingDirectory = workingDir();
if (!r.command.isEmpty()) {
const FilePath expanded = macroExpander()->expand(r.command.executable());

View File

@@ -3,6 +3,8 @@
#pragma once
#include "environmentaspect.h"
#include "runconfigurationaspects.h"
#include "runcontrol.h"
namespace ProjectExplorer {
@@ -23,7 +25,12 @@ private:
Tasks checkForIssues() const override;
void configurationDialogFinished();
Utils::FilePath executable() const;
EnvironmentAspect environment{this};
ExecutableAspect executable{this};
ArgumentsAspect arguments{this};
WorkingDirectoryAspect workingDir{this};
TerminalAspect terminal{this};
};
class CustomExecutableRunConfigurationFactory : public FixedRunConfigurationFactory