forked from qt-creator/qt-creator
Boot2Qt: Use aspects more directly in QdbRunConfiguration
Change-Id: I8a199f449824ff973f5278f39172307be0e11438 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -25,105 +25,86 @@ using namespace Utils;
|
||||
|
||||
namespace Qdb::Internal {
|
||||
|
||||
// FullCommandLineAspect
|
||||
|
||||
class FullCommandLineAspect : public StringAspect
|
||||
{
|
||||
public:
|
||||
explicit FullCommandLineAspect(RunConfiguration *rc)
|
||||
{
|
||||
setLabelText(Tr::tr("Full command line:"));
|
||||
|
||||
auto exeAspect = rc->aspect<ExecutableAspect>();
|
||||
auto argumentsAspect = rc->aspect<ArgumentsAspect>();
|
||||
|
||||
auto updateCommandLine = [this, exeAspect, argumentsAspect] {
|
||||
CommandLine plain{exeAspect->executable(), argumentsAspect->arguments(), CommandLine::Raw};
|
||||
CommandLine cmd;
|
||||
cmd.setExecutable(plain.executable().withNewPath(Constants::AppcontrollerFilepath));
|
||||
cmd.addCommandLineAsArgs(plain);
|
||||
setValue(cmd.toUserOutput());
|
||||
};
|
||||
|
||||
connect(argumentsAspect, &ArgumentsAspect::changed, this, updateCommandLine);
|
||||
connect(exeAspect, &ExecutableAspect::changed, this, updateCommandLine);
|
||||
updateCommandLine();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// QdbRunConfiguration
|
||||
|
||||
class QdbRunConfiguration : public RunConfiguration
|
||||
{
|
||||
public:
|
||||
QdbRunConfiguration(Target *target, Utils::Id id);
|
||||
QdbRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
setDefaultDisplayName(Tr::tr("Run on Boot2Qt Device"));
|
||||
|
||||
executable.setDeviceSelector(target, ExecutableAspect::RunDevice);
|
||||
executable.setSettingsKey("QdbRunConfig.RemoteExecutable");
|
||||
executable.setLabelText(Tr::tr("Executable on device:"));
|
||||
executable.setPlaceHolderText(Tr::tr("Remote path not set"));
|
||||
executable.makeOverridable("QdbRunConfig.AlternateRemoteExecutable",
|
||||
"QdbRunCofig.UseAlternateRemoteExecutable");
|
||||
|
||||
symbolFile.setSettingsKey("QdbRunConfig.LocalExecutable");
|
||||
symbolFile.setLabelText(Tr::tr("Executable on host:"));
|
||||
symbolFile.setDisplayStyle(SymbolFileAspect::LabelDisplay);
|
||||
|
||||
environment.setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
arguments.setMacroExpander(macroExpander());
|
||||
|
||||
workingDir.setMacroExpander(macroExpander());
|
||||
workingDir.setEnvironment(&environment);
|
||||
|
||||
fullCommand.setLabelText(Tr::tr("Full command line:"));
|
||||
|
||||
setUpdater([this, target] {
|
||||
const BuildTargetInfo bti = buildTargetInfo();
|
||||
const FilePath localExecutable = bti.targetFilePath;
|
||||
const DeployableFile depFile = target->deploymentData().deployableForLocalFile(localExecutable);
|
||||
IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit());
|
||||
QTC_ASSERT(dev, return);
|
||||
executable.setExecutable(dev->filePath(depFile.remoteFilePath()));
|
||||
symbolFile.setValue(localExecutable);
|
||||
});
|
||||
|
||||
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
||||
connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update);
|
||||
connect(target, &Target::kitChanged, this, &RunConfiguration::update);
|
||||
|
||||
auto updateFullCommand = [this] {
|
||||
CommandLine plain{executable(), arguments(), CommandLine::Raw};
|
||||
CommandLine cmd;
|
||||
cmd.setExecutable(plain.executable().withNewPath(Constants::AppcontrollerFilepath));
|
||||
cmd.addCommandLineAsArgs(plain);
|
||||
fullCommand.setValue(cmd.toUserOutput());
|
||||
};
|
||||
|
||||
connect(&arguments, &BaseAspect::changed, this, updateFullCommand);
|
||||
connect(&executable, &BaseAspect::changed, this, updateFullCommand);
|
||||
updateFullCommand();
|
||||
}
|
||||
|
||||
private:
|
||||
Tasks checkForIssues() const override;
|
||||
QString defaultDisplayName() const;
|
||||
};
|
||||
|
||||
QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice);
|
||||
exeAspect->setSettingsKey("QdbRunConfig.RemoteExecutable");
|
||||
exeAspect->setLabelText(Tr::tr("Executable on device:"));
|
||||
exeAspect->setPlaceHolderText(Tr::tr("Remote path not set"));
|
||||
exeAspect->makeOverridable("QdbRunConfig.AlternateRemoteExecutable",
|
||||
"QdbRunCofig.UseAlternateRemoteExecutable");
|
||||
|
||||
auto symbolsAspect = addAspect<SymbolFileAspect>();
|
||||
symbolsAspect->setSettingsKey("QdbRunConfig.LocalExecutable");
|
||||
symbolsAspect->setLabelText(Tr::tr("Executable on host:"));
|
||||
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
|
||||
|
||||
auto envAspect = addAspect<RemoteLinux::RemoteLinuxEnvironmentAspect>();
|
||||
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
auto argsAspect = addAspect<ArgumentsAspect>();
|
||||
argsAspect->setMacroExpander(macroExpander());
|
||||
|
||||
auto workingDirAspect = addAspect<WorkingDirectoryAspect>();
|
||||
workingDirAspect->setMacroExpander(macroExpander());
|
||||
|
||||
workingDirAspect->setEnvironment(envAspect);
|
||||
|
||||
addAspect<FullCommandLineAspect>(this);
|
||||
|
||||
setUpdater([this, target, exeAspect, symbolsAspect] {
|
||||
const BuildTargetInfo bti = buildTargetInfo();
|
||||
const FilePath localExecutable = bti.targetFilePath;
|
||||
const DeployableFile depFile = target->deploymentData().deployableForLocalFile(localExecutable);
|
||||
IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit());
|
||||
QTC_ASSERT(dev, return);
|
||||
exeAspect->setExecutable(dev->filePath(depFile.remoteFilePath()));
|
||||
symbolsAspect->setValue(localExecutable);
|
||||
});
|
||||
|
||||
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
||||
connect(target, &Target::deploymentDataChanged, this, &RunConfiguration::update);
|
||||
connect(target, &Target::kitChanged, this, &RunConfiguration::update);
|
||||
|
||||
setDefaultDisplayName(Tr::tr("Run on Boot2Qt Device"));
|
||||
}
|
||||
|
||||
Tasks QdbRunConfiguration::checkForIssues() const
|
||||
{
|
||||
Tasks tasks;
|
||||
if (aspect<ExecutableAspect>()->executable().toString().isEmpty()) {
|
||||
tasks << BuildSystemTask(Task::Warning, Tr::tr("The remote executable must be set "
|
||||
"in order to run on a Boot2Qt device."));
|
||||
Tasks checkForIssues() const override
|
||||
{
|
||||
Tasks tasks;
|
||||
if (executable().isEmpty()) {
|
||||
tasks << BuildSystemTask(Task::Warning, Tr::tr("The remote executable must be set "
|
||||
"in order to run on a Boot2Qt device."));
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
|
||||
QString QdbRunConfiguration::defaultDisplayName() const
|
||||
{
|
||||
return RunConfigurationFactory::decoratedTargetName(buildKey(), target());
|
||||
}
|
||||
QString defaultDisplayName() const
|
||||
{
|
||||
return RunConfigurationFactory::decoratedTargetName(buildKey(), target());
|
||||
}
|
||||
|
||||
ExecutableAspect executable{this};
|
||||
SymbolFileAspect symbolFile{this};
|
||||
RemoteLinux::RemoteLinuxEnvironmentAspect environment{this};
|
||||
ArgumentsAspect arguments{this};
|
||||
WorkingDirectoryAspect workingDir{this};
|
||||
StringAspect fullCommand{this};
|
||||
};
|
||||
|
||||
// QdbRunConfigurationFactory
|
||||
|
||||
|
Reference in New Issue
Block a user