From 9524a3f0257d3eaa5017c6df00aed7209e1ee74a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 31 May 2022 18:22:07 +0200 Subject: [PATCH] ProjectExplorer: Make target device for executable aspect explicit Just run and host is not enough, build device is needed, too. This fixes the MakeInstall step for remote linux. Change-Id: I3ec797379b7d0d5842780d505d8b87a91286e460 Reviewed-by: Christian Stenger --- .../baremetal/baremetalrunconfiguration.cpp | 4 +- src/plugins/boot2qt/qdbrunconfiguration.cpp | 2 +- src/plugins/ios/iosrunconfiguration.cpp | 2 +- .../project/mesonrunconfiguration.cpp | 51 ++++++++----------- .../nim/project/nimblerunconfiguration.cpp | 5 +- .../nim/project/nimrunconfiguration.cpp | 2 +- .../customexecutablerunconfiguration.cpp | 2 +- .../desktoprunconfiguration.cpp | 2 +- .../runconfigurationaspects.cpp | 22 +++++--- .../projectexplorer/runconfigurationaspects.h | 5 +- src/plugins/qnx/qnxrunconfiguration.cpp | 2 +- src/plugins/remotelinux/makeinstallstep.cpp | 3 +- .../remotelinuxcustomrunconfiguration.cpp | 2 +- .../remotelinuxrunconfiguration.cpp | 2 +- 14 files changed, 55 insertions(+), 51 deletions(-) diff --git a/src/plugins/baremetal/baremetalrunconfiguration.cpp b/src/plugins/baremetal/baremetalrunconfiguration.cpp index f081520bebb..b8961d9476d 100644 --- a/src/plugins/baremetal/baremetalrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalrunconfiguration.cpp @@ -48,7 +48,7 @@ public: explicit BareMetalRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - const auto exeAspect = addAspect(target); + const auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setDisplayStyle(StringAspect::LabelDisplay); exeAspect->setPlaceHolderText(tr("Unknown")); @@ -72,7 +72,7 @@ public: explicit BareMetalCustomRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - const auto exeAspect = addAspect(target); + const auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); 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 98cae5734bc..2141384f6a6 100644 --- a/src/plugins/boot2qt/qdbrunconfiguration.cpp +++ b/src/plugins/boot2qt/qdbrunconfiguration.cpp @@ -87,7 +87,7 @@ private: QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - auto exeAspect = addAspect(target); + auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setSettingsKey("QdbRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setPlaceHolderText(tr("Remote path not set")); diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index 54347566996..d4a93337d65 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -80,7 +80,7 @@ static IosDeviceType toIosDeviceType(const SimulatorInfo &device) IosRunConfiguration::IosRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - auto executableAspect = addAspect(target); + auto executableAspect = addAspect(target, ExecutableAspect::RunDevice); executableAspect->setDisplayStyle(StringAspect::LabelDisplay); addAspect(macroExpander()); diff --git a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp index 84f226ab6f7..bfc3b6ee0ea 100644 --- a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp +++ b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp @@ -36,31 +36,29 @@ #include #include +using namespace ProjectExplorer; + namespace MesonProjectManager { namespace Internal { -MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Utils::Id id) - : ProjectExplorer::RunConfiguration{target, id} +MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id) + : RunConfiguration{target, id} { - auto envAspect = addAspect(target); + auto envAspect = addAspect(target); - addAspect(target); - addAspect(macroExpander()); - addAspect(macroExpander(), envAspect); - addAspect(); + addAspect(target, ExecutableAspect::RunDevice); + addAspect(macroExpander()); + addAspect(macroExpander(), envAspect); + addAspect(); - auto libAspect = addAspect(); - connect(libAspect, - &ProjectExplorer::UseLibraryPathsAspect::changed, - envAspect, - &ProjectExplorer::EnvironmentAspect::environmentChanged); + auto libAspect = addAspect(); + connect(libAspect, &UseLibraryPathsAspect::changed, + envAspect, &EnvironmentAspect::environmentChanged); if (Utils::HostOsInfo::isMacHost()) { - auto dyldAspect = addAspect(); - connect(dyldAspect, - &ProjectExplorer::UseLibraryPathsAspect::changed, - envAspect, - &ProjectExplorer::EnvironmentAspect::environmentChanged); + auto dyldAspect = addAspect(); + connect(dyldAspect, &UseLibraryPathsAspect::changed, + envAspect, &EnvironmentAspect::environmentChanged); envAspect->addModifier([dyldAspect](Utils::Environment &env) { if (dyldAspect->value()) env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug")); @@ -68,17 +66,14 @@ MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Ut } envAspect->addModifier([this, libAspect](Utils::Environment &env) { - ProjectExplorer::BuildTargetInfo bti = buildTargetInfo(); + BuildTargetInfo bti = buildTargetInfo(); if (bti.runEnvModifier) bti.runEnvModifier(env, libAspect->value()); }); setUpdater([this] { updateTargetInformation(); }); - connect(target, - &ProjectExplorer::Target::buildSystemUpdated, - this, - &ProjectExplorer::RunConfiguration::update); + connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); } void MesonRunConfiguration::updateTargetInformation() @@ -86,13 +81,11 @@ void MesonRunConfiguration::updateTargetInformation() if (!activeBuildSystem()) return; - ProjectExplorer::BuildTargetInfo bti = buildTargetInfo(); - auto terminalAspect = aspect(); - terminalAspect->setUseTerminalHint(bti.usesTerminal); - aspect()->setExecutable(bti.targetFilePath); - aspect()->setDefaultWorkingDirectory( - bti.workingDirectory); - emit aspect()->environmentChanged(); + BuildTargetInfo bti = buildTargetInfo(); + aspect()->setUseTerminalHint(bti.usesTerminal); + aspect()->setExecutable(bti.targetFilePath); + aspect()->setDefaultWorkingDirectory(bti.workingDirectory); + emit aspect()->environmentChanged(); } MesonRunConfigurationFactory::MesonRunConfigurationFactory() diff --git a/src/plugins/nim/project/nimblerunconfiguration.cpp b/src/plugins/nim/project/nimblerunconfiguration.cpp index e88e2c11ad6..68d6d06b727 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(target); + addAspect(target, ExecutableAspect::RunDevice); addAspect(macroExpander()); addAspect(macroExpander(), envAspect); addAspect(); @@ -89,7 +89,8 @@ public: NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id) : RunConfiguration(target, id) { - addAspect(target)->setExecutable(Nim::nimblePathFromKit(target->kit())); + addAspect(target, ExecutableAspect::BuildDevice) + ->setExecutable(Nim::nimblePathFromKit(target->kit())); addAspect(macroExpander())->setArguments("test"); addAspect(macroExpander(), nullptr) ->setDefaultWorkingDirectory(project()->projectDirectory()); diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index 925fac47736..af6fb6713f2 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(target); + addAspect(target, ExecutableAspect::RunDevice); addAspect(macroExpander()); addAspect(macroExpander(), envAspect); addAspect(); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index cbd8705f6ff..936411a7f28 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -45,7 +45,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe { auto envAspect = addAspect(target); - auto exeAspect = addAspect(nullptr); // nullptr - to enforce host-only operation. + auto exeAspect = addAspect(target, ExecutableAspect::HostDevice); exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable"); exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); exeAspect->setHistoryCompleter("Qt.CustomExecutable.History"); diff --git a/src/plugins/projectexplorer/desktoprunconfiguration.cpp b/src/plugins/projectexplorer/desktoprunconfiguration.cpp index 663474afdc5..db39def1def 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(target); + addAspect(target, ExecutableAspect::HostDevice); addAspect(macroExpander()); addAspect(macroExpander(), envAspect); addAspect(); diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index ab2e00e7440..eefe7ac4116 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -25,13 +25,12 @@ #include "runconfigurationaspects.h" +#include "devicesupport/devicemanager.h" #include "devicesupport/idevice.h" #include "environmentaspect.h" #include "kitinformation.h" -#include "project.h" #include "projectexplorer.h" #include "projectexplorersettings.h" -#include "runconfiguration.h" #include "target.h" #include @@ -514,8 +513,8 @@ void ArgumentsAspect::addToLayout(LayoutBuilder &builder) by the build system's parsing results with an optional manual override. */ -ExecutableAspect::ExecutableAspect(Target *target) - : m_target(target) +ExecutableAspect::ExecutableAspect(Target *target, ExecutionDeviceSelector selector) + : m_target(target), m_selector(selector) { setDisplayName(tr("Executable")); setId("ExecutableAspect"); @@ -534,9 +533,16 @@ ExecutableAspect::ExecutableAspect(Target *target) \internal */ -static IDevice::ConstPtr deviceForTarget(Target *target) +static IDevice::ConstPtr executionDevice(Target *target, + ExecutableAspect::ExecutionDeviceSelector selector) { - return target ? DeviceKitAspect::device(target->kit()) : IDevice::ConstPtr(); + if (target) { + if (selector == ExecutableAspect::RunDevice) + return DeviceKitAspect::device(target->kit()); + if (selector == ExecutableAspect::BuildDevice) + return BuildDeviceKitAspect::device(target->kit()); + } + return DeviceManager::defaultDesktopDevice(); } ExecutableAspect::~ExecutableAspect() @@ -547,7 +553,7 @@ ExecutableAspect::~ExecutableAspect() void ExecutableAspect::updateDevice() { - const IDevice::ConstPtr dev = deviceForTarget(m_target); + const IDevice::ConstPtr dev = executionDevice(m_target, m_selector); const OsType osType = dev ? dev->osType() : HostOsInfo::hostOs(); m_executable.setDisplayFilter([osType](const QString &pathName) { @@ -638,7 +644,7 @@ FilePath ExecutableAspect::executable() const ? m_alternativeExecutable->filePath() : m_executable.filePath(); - if (const IDevice::ConstPtr dev = deviceForTarget(m_target)) + if (const IDevice::ConstPtr dev = executionDevice(m_target, m_selector)) exe = dev->filePath(exe.path()); return exe; diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 768d89a0430..f9524a3c6a1 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -175,7 +175,9 @@ class PROJECTEXPLORER_EXPORT ExecutableAspect : public Utils::BaseAspect Q_OBJECT public: - explicit ExecutableAspect(Target *target); // Uses device from target if non-null. + enum ExecutionDeviceSelector { HostDevice, BuildDevice, RunDevice }; + + explicit ExecutableAspect(Target *target, ExecutionDeviceSelector selector); ~ExecutableAspect() override; Utils::FilePath executable() const; @@ -207,6 +209,7 @@ private: Utils::StringAspect m_executable; Utils::StringAspect *m_alternativeExecutable = nullptr; Target *m_target = nullptr; + ExecutionDeviceSelector m_selector = RunDevice; }; class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::StringAspect diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp index 39753f8afb4..927a9a94691 100644 --- a/src/plugins/qnx/qnxrunconfiguration.cpp +++ b/src/plugins/qnx/qnxrunconfiguration.cpp @@ -47,7 +47,7 @@ namespace Internal { QnxRunConfiguration::QnxRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - auto exeAspect = addAspect(target); + auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 90b292d47af..08a14ed7dab 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -67,7 +67,8 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent jobCountAspect()->setVisible(false); disabledForSubdirsAspect()->setVisible(false); - const auto makeAspect = addAspect(parent->target()); + const auto makeAspect = addAspect(parent->target(), + ExecutableAspect::BuildDevice); 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 fe704f0705b..38668ae1b54 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -59,7 +59,7 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar { auto envAspect = addAspect(target); - auto exeAspect = addAspect(target); + auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Remote executable:")); exeAspect->setDisplayStyle(StringAspect::LineEditDisplay); diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index cc026da4db1..14f95365613 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -59,7 +59,7 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) { auto envAspect = addAspect(target); - auto exeAspect = addAspect(target); + auto exeAspect = addAspect(target, ExecutableAspect::RunDevice); exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",