From 0d733e68b55db6e5a690e6a7bb8e0afece999c9a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 10 May 2022 16:30:26 +0200 Subject: [PATCH] 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 Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/applicationlauncher.cpp | 5 +---- .../projectexplorer/customexecutablerunconfiguration.cpp | 9 ++++++++- src/plugins/projectexplorer/runconfiguration.cpp | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 1a25e6cada6..8e913fff6c5 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -338,10 +338,7 @@ void ApplicationLauncherPrivate::start() m_state = Run; m_stopRequested = false; - CommandLine cmd = 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.setCommand(m_runnable.command); m_process.setWorkingDirectory(m_runnable.workingDirectory); m_process.setEnvironment(m_runnable.environment); m_process.setExtraData(m_runnable.extraData); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 7a842b52ccb..0e8fe86aefd 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -53,7 +53,8 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe exeAspect->setExpectedKind(PathChooser::ExistingCommand); exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); - addAspect(); + auto argsAspect = addAspect(); + addAspect(envAspect); addAspect(); @@ -61,6 +62,12 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe 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()); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 542bae58016..09bd39ebba6 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -209,13 +209,17 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id) [this] { return commandLine().executable(); }); - m_commandLineGetter = [this] { + m_commandLineGetter = [target, this] { FilePath executable; if (const auto executableAspect = aspect()) executable = executableAspect->executable(); QString arguments; if (const auto argumentsAspect = aspect()) arguments = argumentsAspect->arguments(macroExpander()); + + if (IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit())) + executable = dev->filePath(executable.path()); + return CommandLine{executable, arguments, CommandLine::Raw}; };