ProjectExplorer: Create Runnables with full device paths in RunConfig

... instead of fixing them later in the ApplicationLauncher as used
by all SimpleTargetRunners.

The mapping to device paths happens now in the default commandline
getter on paths from the ExecutableAspect. This is (only) wrong in the
case of (local) custom runconfig with a device present, so this needs
a custom commmandline getter not doing the transformation.

Change-Id: I525bc0ea59b5e7caf7a445a1a723d6f5b152162d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-05-10 16:30:26 +02:00
parent ef2c551121
commit 0d733e68b5
3 changed files with 14 additions and 6 deletions

View File

@@ -338,10 +338,7 @@ void ApplicationLauncherPrivate::start()
m_state = Run; m_state = Run;
m_stopRequested = false; m_stopRequested = false;
CommandLine cmd = m_runnable.command; m_process.setCommand(m_runnable.command);
// FIXME: RunConfiguration::runnable() should give us the correct, on-device path, instead of fixing it up here.
cmd.setExecutable(m_runnable.device->mapToGlobalPath(cmd.executable()));
m_process.setCommand(cmd);
m_process.setWorkingDirectory(m_runnable.workingDirectory); m_process.setWorkingDirectory(m_runnable.workingDirectory);
m_process.setEnvironment(m_runnable.environment); m_process.setEnvironment(m_runnable.environment);
m_process.setExtraData(m_runnable.extraData); m_process.setExtraData(m_runnable.extraData);

View File

@@ -53,7 +53,8 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
exeAspect->setExpectedKind(PathChooser::ExistingCommand); exeAspect->setExpectedKind(PathChooser::ExistingCommand);
exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment()));
addAspect<ArgumentsAspect>(); auto argsAspect = addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(envAspect); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
@@ -61,6 +62,12 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment()));
}); });
setCommandLineGetter([exeAspect, argsAspect, this] {
const FilePath executable = exeAspect->executable();
const QString arguments = argsAspect->arguments(macroExpander());
return CommandLine{executable, arguments, CommandLine::Raw};
});
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
} }

View File

@@ -209,13 +209,17 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
[this] { return commandLine().executable(); }); [this] { return commandLine().executable(); });
m_commandLineGetter = [this] { m_commandLineGetter = [target, this] {
FilePath executable; FilePath executable;
if (const auto executableAspect = aspect<ExecutableAspect>()) if (const auto executableAspect = aspect<ExecutableAspect>())
executable = executableAspect->executable(); executable = executableAspect->executable();
QString arguments; QString arguments;
if (const auto argumentsAspect = aspect<ArgumentsAspect>()) if (const auto argumentsAspect = aspect<ArgumentsAspect>())
arguments = argumentsAspect->arguments(macroExpander()); arguments = argumentsAspect->arguments(macroExpander());
if (IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit()))
executable = dev->filePath(executable.path());
return CommandLine{executable, arguments, CommandLine::Raw}; return CommandLine{executable, arguments, CommandLine::Raw};
}; };