forked from qt-creator/qt-creator
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:
@@ -23,38 +23,27 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
|
|||||||
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Id id)
|
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Id id)
|
||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
auto envAspect = addAspect<EnvironmentAspect>();
|
environment.setSupportForBuildEnvironment(target);
|
||||||
envAspect->setSupportForBuildEnvironment(target);
|
|
||||||
|
|
||||||
auto exeAspect = addAspect<ExecutableAspect>();
|
executable.setDeviceSelector(target, ExecutableAspect::HostDevice);
|
||||||
exeAspect->setDeviceSelector(target, ExecutableAspect::HostDevice);
|
executable.setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
|
||||||
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
|
executable.setReadOnly(false);
|
||||||
exeAspect->setReadOnly(false);
|
executable.setHistoryCompleter("Qt.CustomExecutable.History");
|
||||||
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");
|
executable.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
exeAspect->setExpectedKind(PathChooser::ExistingCommand);
|
executable.setEnvironment(environment.environment());
|
||||||
exeAspect->setEnvironment(envAspect->environment());
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
addAspect<TerminalAspect>();
|
connect(&environment, &EnvironmentAspect::environmentChanged, this, [this] {
|
||||||
|
executable.setEnvironment(environment.environment());
|
||||||
connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] {
|
|
||||||
exeAspect->setEnvironment(envAspect->environment());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath CustomExecutableRunConfiguration::executable() const
|
|
||||||
{
|
|
||||||
return aspect<ExecutableAspect>()->executable();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CustomExecutableRunConfiguration::isEnabled() const
|
bool CustomExecutableRunConfiguration::isEnabled() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -64,8 +53,8 @@ Runnable CustomExecutableRunConfiguration::runnable() const
|
|||||||
{
|
{
|
||||||
Runnable r;
|
Runnable r;
|
||||||
r.command = commandLine();
|
r.command = commandLine();
|
||||||
r.environment = aspect<EnvironmentAspect>()->environment();
|
r.environment = environment.environment();
|
||||||
r.workingDirectory = aspect<WorkingDirectoryAspect>()->workingDirectory();
|
r.workingDirectory = workingDir();
|
||||||
|
|
||||||
if (!r.command.isEmpty()) {
|
if (!r.command.isEmpty()) {
|
||||||
const FilePath expanded = macroExpander()->expand(r.command.executable());
|
const FilePath expanded = macroExpander()->expand(r.command.executable());
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "environmentaspect.h"
|
||||||
|
#include "runconfigurationaspects.h"
|
||||||
#include "runcontrol.h"
|
#include "runcontrol.h"
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -23,7 +25,12 @@ private:
|
|||||||
Tasks checkForIssues() const override;
|
Tasks checkForIssues() const override;
|
||||||
|
|
||||||
void configurationDialogFinished();
|
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
|
class CustomExecutableRunConfigurationFactory : public FixedRunConfigurationFactory
|
||||||
|
Reference in New Issue
Block a user