aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/boot2qt
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-07-07 19:27:39 +0200
committerhjk <hjk@qt.io>2023-07-12 14:01:57 +0000
commit8ba6f11e9ca21c7c3d2e7ad876a6934f9af3d51f (patch)
treece185f122196fc0cb24f9e2a69d2db62594e0c1b /src/plugins/boot2qt
parent323f29a3bdcb741047ed66241bd50ef147a9405d (diff)
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>
Diffstat (limited to 'src/plugins/boot2qt')
-rw-r--r--src/plugins/boot2qt/qdbrunconfiguration.cpp145
1 files changed, 63 insertions, 82 deletions
diff --git a/src/plugins/boot2qt/qdbrunconfiguration.cpp b/src/plugins/boot2qt/qdbrunconfiguration.cpp
index cba9aef178..ebb5840239 100644
--- a/src/plugins/boot2qt/qdbrunconfiguration.cpp
+++ b/src/plugins/boot2qt/qdbrunconfiguration.cpp
@@ -25,105 +25,86 @@ using namespace Utils;
namespace Qdb::Internal {
-// FullCommandLineAspect
+// QdbRunConfiguration
-class FullCommandLineAspect : public StringAspect
+class QdbRunConfiguration : public RunConfiguration
{
public:
- explicit FullCommandLineAspect(RunConfiguration *rc)
+ QdbRunConfiguration(Target *target, Id id)
+ : RunConfiguration(target, id)
{
- setLabelText(Tr::tr("Full command line:"));
+ 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:"));
- auto exeAspect = rc->aspect<ExecutableAspect>();
- auto argumentsAspect = rc->aspect<ArgumentsAspect>();
+ 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);
+ });
- auto updateCommandLine = [this, exeAspect, argumentsAspect] {
- CommandLine plain{exeAspect->executable(), argumentsAspect->arguments(), CommandLine::Raw};
+ 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);
- setValue(cmd.toUserOutput());
+ fullCommand.setValue(cmd.toUserOutput());
};
- connect(argumentsAspect, &ArgumentsAspect::changed, this, updateCommandLine);
- connect(exeAspect, &ExecutableAspect::changed, this, updateCommandLine);
- updateCommandLine();
+ connect(&arguments, &BaseAspect::changed, this, updateFullCommand);
+ connect(&executable, &BaseAspect::changed, this, updateFullCommand);
+ updateFullCommand();
}
-};
-
-
-// QdbRunConfiguration
-
-class QdbRunConfiguration : public RunConfiguration
-{
-public:
- QdbRunConfiguration(Target *target, Utils::Id id);
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 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;
+ }
-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."));
+ QString defaultDisplayName() const
+ {
+ return RunConfigurationFactory::decoratedTargetName(buildKey(), target());
}
- return tasks;
-}
-QString QdbRunConfiguration::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