diff --git a/src/plugins/baremetal/baremetalrunconfiguration.cpp b/src/plugins/baremetal/baremetalrunconfiguration.cpp index 03e588212b1..905216b0471 100644 --- a/src/plugins/baremetal/baremetalrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalrunconfiguration.cpp @@ -48,7 +48,7 @@ public: explicit BareMetalRunConfiguration(Target *target, Utils::Id id) : RunConfiguration(target, id) { - const auto exeAspect = addAspect(); + const auto exeAspect = addAspect(target); exeAspect->setDisplayStyle(StringAspect::LabelDisplay); exeAspect->setPlaceHolderText(tr("Unknown")); @@ -69,10 +69,10 @@ class BareMetalCustomRunConfiguration final : public RunConfiguration Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::BareMetalCustomRunConfiguration) public: - explicit BareMetalCustomRunConfiguration(Target *target, Utils::Id id) + explicit BareMetalCustomRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - const auto exeAspect = addAspect(); + const auto exeAspect = addAspect(target); exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable"); exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); diff --git a/src/plugins/boot2qt/qdbrunconfiguration.cpp b/src/plugins/boot2qt/qdbrunconfiguration.cpp index 0fce139afa4..3da3a95db4f 100644 --- a/src/plugins/boot2qt/qdbrunconfiguration.cpp +++ b/src/plugins/boot2qt/qdbrunconfiguration.cpp @@ -84,13 +84,12 @@ private: QString defaultDisplayName() const; }; -QdbRunConfiguration::QdbRunConfiguration(Target *target, Utils::Id id) +QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - auto exeAspect = addAspect(); + auto exeAspect = addAspect(target); exeAspect->setSettingsKey("QdbRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Executable on device:")); - exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("QdbRunConfig.AlternateRemoteExecutable", "QdbRunCofig.UseAlternateRemoteExecutable"); diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index 51a2288c492..e54633f89fc 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -77,10 +77,10 @@ static IosDeviceType toIosDeviceType(const SimulatorInfo &device) return iosDeviceType; } -IosRunConfiguration::IosRunConfiguration(Target *target, Utils::Id id) +IosRunConfiguration::IosRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - auto executableAspect = addAspect(); + auto executableAspect = addAspect(target); executableAspect->setDisplayStyle(StringAspect::LabelDisplay); addAspect(); diff --git a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp index 1384ddfda9b..b5b68e21172 100644 --- a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp +++ b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp @@ -44,7 +44,7 @@ MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Ut { auto envAspect = addAspect(target); - addAspect(); + addAspect(target); addAspect(); addAspect(envAspect); addAspect(); diff --git a/src/plugins/nim/project/nimblerunconfiguration.cpp b/src/plugins/nim/project/nimblerunconfiguration.cpp index fc5966c10e5..37970df67bb 100644 --- a/src/plugins/nim/project/nimblerunconfiguration.cpp +++ b/src/plugins/nim/project/nimblerunconfiguration.cpp @@ -52,7 +52,7 @@ public: : RunConfiguration(target, id) { auto envAspect = addAspect(target); - addAspect(); + addAspect(target); addAspect(); addAspect(envAspect); addAspect(); @@ -89,7 +89,7 @@ public: NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id) : RunConfiguration(target, id) { - addAspect()->setExecutable(Nim::nimblePathFromKit(target->kit())); + addAspect(target)->setExecutable(Nim::nimblePathFromKit(target->kit())); addAspect()->setArguments("test"); addAspect(nullptr)->setDefaultWorkingDirectory(project()->projectDirectory()); addAspect(); diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index 0d779a00364..cfbeb55b496 100644 --- a/src/plugins/nim/project/nimrunconfiguration.cpp +++ b/src/plugins/nim/project/nimrunconfiguration.cpp @@ -50,7 +50,7 @@ public: : RunConfiguration(target, id) { auto envAspect = addAspect(target); - addAspect(); + addAspect(target); addAspect(); addAspect(envAspect); addAspect(); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 0e8fe86aefd..56722f07daf 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -41,20 +41,19 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe : CustomExecutableRunConfiguration(target, CUSTOM_EXECUTABLE_RUNCONFIG_ID) {} -CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Utils::Id id) +CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { auto envAspect = addAspect(target); - auto exeAspect = addAspect(); + auto exeAspect = addAspect(nullptr); // nullptr - to enforce host-only operation. exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable"); exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); exeAspect->setHistoryCompleter("Qt.CustomExecutable.History"); exeAspect->setExpectedKind(PathChooser::ExistingCommand); exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); - auto argsAspect = addAspect(); - + addAspect(); addAspect(envAspect); addAspect(); @@ -62,12 +61,6 @@ 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/desktoprunconfiguration.cpp b/src/plugins/projectexplorer/desktoprunconfiguration.cpp index ef0bcec50d6..b25cb15b365 100644 --- a/src/plugins/projectexplorer/desktoprunconfiguration.cpp +++ b/src/plugins/projectexplorer/desktoprunconfiguration.cpp @@ -68,7 +68,7 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Id id, Kind kin { auto envAspect = addAspect(target); - addAspect(); + addAspect(target); addAspect(); addAspect(envAspect); addAspect(); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 09bd39ebba6..43095c1200f 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -217,9 +217,6 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id) 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}; }; diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index a9c6b5cc33a..50758dd2fb0 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -25,7 +25,9 @@ #include "runconfigurationaspects.h" +#include "devicesupport/idevice.h" #include "environmentaspect.h" +#include "kitinformation.h" #include "project.h" #include "projectexplorer.h" #include "projectexplorersettings.h" @@ -515,39 +517,42 @@ void ArgumentsAspect::addToLayout(LayoutBuilder &builder) by the build system's parsing results with an optional manual override. */ -ExecutableAspect::ExecutableAspect() +ExecutableAspect::ExecutableAspect(Target *target) + : m_target(target) { setDisplayName(tr("Executable")); setId("ExecutableAspect"); - setExecutablePathStyle(HostOsInfo::hostOs()); - addDataExtractor(this, &ExecutableAspect::executable, &Data::executable); m_executable.setPlaceHolderText(tr("")); m_executable.setLabelText(tr("Executable:")); m_executable.setDisplayStyle(StringAspect::LabelDisplay); - connect(&m_executable, &StringAspect::changed, - this, &ExecutableAspect::changed); + updateDevice(); + + connect(&m_executable, &StringAspect::changed, this, &ExecutableAspect::changed); } /*! \internal */ + +static IDevice::ConstPtr deviceForTarget(Target *target) +{ + return target ? DeviceKitAspect::device(target->kit()) : IDevice::ConstPtr(); +} + ExecutableAspect::~ExecutableAspect() { delete m_alternativeExecutable; m_alternativeExecutable = nullptr; } -/*! - Sets the display style of the paths to the default used on \a osType, - backslashes on Windows, forward slashes elsewhere. - - \sa Utils::StringAspect::setDisplayFilter() -*/ -void ExecutableAspect::setExecutablePathStyle(OsType osType) +void ExecutableAspect::updateDevice() { + const IDevice::ConstPtr dev = deviceForTarget(m_target); + const OsType osType = dev ? dev->osType() : HostOsInfo::hostOs(); + m_executable.setDisplayFilter([osType](const QString &pathName) { return OsSpecificAspects::pathWithNativeSeparators(osType, pathName); }); @@ -632,10 +637,14 @@ void ExecutableAspect::makeOverridable(const QString &overridingKey, const QStri */ FilePath ExecutableAspect::executable() const { - if (m_alternativeExecutable && m_alternativeExecutable->isChecked()) - return m_alternativeExecutable->filePath(); + FilePath exe = m_alternativeExecutable && m_alternativeExecutable->isChecked() + ? m_alternativeExecutable->filePath() + : m_executable.filePath(); - return m_executable.filePath(); + if (const IDevice::ConstPtr dev = deviceForTarget(m_target)) + exe = dev->filePath(exe.path()); + + return exe; } /*! diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 4d1e84b59bf..191a0b3e516 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -174,7 +174,7 @@ class PROJECTEXPLORER_EXPORT ExecutableAspect : public Utils::BaseAspect Q_OBJECT public: - ExecutableAspect(); + explicit ExecutableAspect(Target *target); // Uses device from target if non-null. ~ExecutableAspect() override; Utils::FilePath executable() const; @@ -185,7 +185,6 @@ public: void addToLayout(Utils::LayoutBuilder &builder) override; void setLabelText(const QString &labelText); void setPlaceHolderText(const QString &placeHolderText); - void setExecutablePathStyle(Utils::OsType osType); void setHistoryCompleter(const QString &historyCompleterKey); void setExpectedKind(const Utils::PathChooser::Kind expectedKind); void setEnvironmentChange(const Utils::EnvironmentChange &change); @@ -202,9 +201,11 @@ protected: private: QString executableText() const; + void updateDevice(); Utils::StringAspect m_executable; Utils::StringAspect *m_alternativeExecutable = nullptr; + Target *m_target = nullptr; }; class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::StringAspect diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp index a5d34a85ae3..0ef1092a675 100644 --- a/src/plugins/qnx/qnxrunconfiguration.cpp +++ b/src/plugins/qnx/qnxrunconfiguration.cpp @@ -47,9 +47,8 @@ namespace Internal { QnxRunConfiguration::QnxRunConfiguration(Target *target, Utils::Id id) : RunConfiguration(target, id) { - auto exeAspect = addAspect(); + auto exeAspect = addAspect(target); exeAspect->setLabelText(tr("Executable on device:")); - exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", "RemoteLinux.RunConfig.UseAlternateRemoteExecutable"); diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index ad87d68b21a..90b292d47af 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -57,7 +57,7 @@ const char CleanInstallRootAspectId[] = "RemoteLinux.MakeInstall.CleanInstallRoo const char FullCommandLineAspectId[] = "RemoteLinux.MakeInstall.FullCommandLine"; const char CustomCommandLineAspectId[] = "RemoteLinux.MakeInstall.CustomCommandLine"; -MakeInstallStep::MakeInstallStep(BuildStepList *parent, Utils::Id id) : MakeStep(parent, id) +MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent, id) { makeCommandAspect()->setVisible(false); buildTargetsAspect()->setVisible(false); @@ -67,7 +67,7 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Utils::Id id) : MakeStep jobCountAspect()->setVisible(false); disabledForSubdirsAspect()->setVisible(false); - const auto makeAspect = addAspect(); + const auto makeAspect = addAspect(parent->target()); makeAspect->setId(MakeAspectId); makeAspect->setSettingsKey(MakeAspectId); makeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index 34b37e9835c..72bb0419c25 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -59,10 +59,9 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar { auto envAspect = addAspect(target); - auto exeAspect = addAspect(); + auto exeAspect = addAspect(target); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Remote executable:")); - exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setDisplayStyle(StringAspect::LineEditDisplay); exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History"); exeAspect->setExpectedKind(PathChooser::Any); diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index 6188629031b..485b343ac35 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -59,9 +59,8 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) { auto envAspect = addAspect(target); - auto exeAspect = addAspect(); + auto exeAspect = addAspect(target); exeAspect->setLabelText(tr("Executable on device:")); - exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", "RemoteLinux.RunConfig.UseAlternateRemoteExecutable");