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 <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-05-31 18:22:07 +02:00
parent b9627ddba7
commit 9524a3f025
14 changed files with 55 additions and 51 deletions

View File

@@ -48,7 +48,7 @@ public:
explicit BareMetalRunConfiguration(Target *target, Id id) explicit BareMetalRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
const auto exeAspect = addAspect<ExecutableAspect>(target); const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setDisplayStyle(StringAspect::LabelDisplay); exeAspect->setDisplayStyle(StringAspect::LabelDisplay);
exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setPlaceHolderText(tr("Unknown"));
@@ -72,7 +72,7 @@ public:
explicit BareMetalCustomRunConfiguration(Target *target, Id id) explicit BareMetalCustomRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
const auto exeAspect = addAspect<ExecutableAspect>(target); const auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable"); exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable");
exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setPlaceHolderText(tr("Unknown"));
exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);

View File

@@ -87,7 +87,7 @@ private:
QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id) QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto exeAspect = addAspect<ExecutableAspect>(target); auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setSettingsKey("QdbRunConfig.RemoteExecutable"); exeAspect->setSettingsKey("QdbRunConfig.RemoteExecutable");
exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setLabelText(tr("Executable on device:"));
exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->setPlaceHolderText(tr("Remote path not set"));

View File

@@ -80,7 +80,7 @@ static IosDeviceType toIosDeviceType(const SimulatorInfo &device)
IosRunConfiguration::IosRunConfiguration(Target *target, Id id) IosRunConfiguration::IosRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto executableAspect = addAspect<ExecutableAspect>(target); auto executableAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
executableAspect->setDisplayStyle(StringAspect::LabelDisplay); executableAspect->setDisplayStyle(StringAspect::LabelDisplay);
addAspect<ArgumentsAspect>(macroExpander()); addAspect<ArgumentsAspect>(macroExpander());

View File

@@ -36,31 +36,29 @@
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
using namespace ProjectExplorer;
namespace MesonProjectManager { namespace MesonProjectManager {
namespace Internal { namespace Internal {
MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Utils::Id id) MesonRunConfiguration::MesonRunConfiguration(Target *target, Utils::Id id)
: ProjectExplorer::RunConfiguration{target, id} : RunConfiguration{target, id}
{ {
auto envAspect = addAspect<ProjectExplorer::LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ProjectExplorer::ExecutableAspect>(target); addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
addAspect<ProjectExplorer::ArgumentsAspect>(macroExpander()); addAspect<ArgumentsAspect>(macroExpander());
addAspect<ProjectExplorer::WorkingDirectoryAspect>(macroExpander(), envAspect); addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect);
addAspect<ProjectExplorer::TerminalAspect>(); addAspect<TerminalAspect>();
auto libAspect = addAspect<ProjectExplorer::UseLibraryPathsAspect>(); auto libAspect = addAspect<UseLibraryPathsAspect>();
connect(libAspect, connect(libAspect, &UseLibraryPathsAspect::changed,
&ProjectExplorer::UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged);
envAspect,
&ProjectExplorer::EnvironmentAspect::environmentChanged);
if (Utils::HostOsInfo::isMacHost()) { if (Utils::HostOsInfo::isMacHost()) {
auto dyldAspect = addAspect<ProjectExplorer::UseDyldSuffixAspect>(); auto dyldAspect = addAspect<UseDyldSuffixAspect>();
connect(dyldAspect, connect(dyldAspect, &UseLibraryPathsAspect::changed,
&ProjectExplorer::UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged);
envAspect,
&ProjectExplorer::EnvironmentAspect::environmentChanged);
envAspect->addModifier([dyldAspect](Utils::Environment &env) { envAspect->addModifier([dyldAspect](Utils::Environment &env) {
if (dyldAspect->value()) if (dyldAspect->value())
env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug")); 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) { envAspect->addModifier([this, libAspect](Utils::Environment &env) {
ProjectExplorer::BuildTargetInfo bti = buildTargetInfo(); BuildTargetInfo bti = buildTargetInfo();
if (bti.runEnvModifier) if (bti.runEnvModifier)
bti.runEnvModifier(env, libAspect->value()); bti.runEnvModifier(env, libAspect->value());
}); });
setUpdater([this] { updateTargetInformation(); }); setUpdater([this] { updateTargetInformation(); });
connect(target, connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
&ProjectExplorer::Target::buildSystemUpdated,
this,
&ProjectExplorer::RunConfiguration::update);
} }
void MesonRunConfiguration::updateTargetInformation() void MesonRunConfiguration::updateTargetInformation()
@@ -86,13 +81,11 @@ void MesonRunConfiguration::updateTargetInformation()
if (!activeBuildSystem()) if (!activeBuildSystem())
return; return;
ProjectExplorer::BuildTargetInfo bti = buildTargetInfo(); BuildTargetInfo bti = buildTargetInfo();
auto terminalAspect = aspect<ProjectExplorer::TerminalAspect>(); aspect<TerminalAspect>()->setUseTerminalHint(bti.usesTerminal);
terminalAspect->setUseTerminalHint(bti.usesTerminal); aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
aspect<ProjectExplorer::ExecutableAspect>()->setExecutable(bti.targetFilePath); aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
aspect<ProjectExplorer::WorkingDirectoryAspect>()->setDefaultWorkingDirectory( emit aspect<LocalEnvironmentAspect>()->environmentChanged();
bti.workingDirectory);
emit aspect<ProjectExplorer::LocalEnvironmentAspect>()->environmentChanged();
} }
MesonRunConfigurationFactory::MesonRunConfigurationFactory() MesonRunConfigurationFactory::MesonRunConfigurationFactory()

View File

@@ -52,7 +52,7 @@ public:
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ExecutableAspect>(target); addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
addAspect<ArgumentsAspect>(macroExpander()); addAspect<ArgumentsAspect>(macroExpander());
addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect); addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
@@ -89,7 +89,8 @@ public:
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id) NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
addAspect<ExecutableAspect>(target)->setExecutable(Nim::nimblePathFromKit(target->kit())); addAspect<ExecutableAspect>(target, ExecutableAspect::BuildDevice)
->setExecutable(Nim::nimblePathFromKit(target->kit()));
addAspect<ArgumentsAspect>(macroExpander())->setArguments("test"); addAspect<ArgumentsAspect>(macroExpander())->setArguments("test");
addAspect<WorkingDirectoryAspect>(macroExpander(), nullptr) addAspect<WorkingDirectoryAspect>(macroExpander(), nullptr)
->setDefaultWorkingDirectory(project()->projectDirectory()); ->setDefaultWorkingDirectory(project()->projectDirectory());

View File

@@ -50,7 +50,7 @@ public:
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ExecutableAspect>(target); addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
addAspect<ArgumentsAspect>(macroExpander()); addAspect<ArgumentsAspect>(macroExpander());
addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect); addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();

View File

@@ -45,7 +45,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
{ {
auto envAspect = addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
auto exeAspect = addAspect<ExecutableAspect>(nullptr); // nullptr - to enforce host-only operation. auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::HostDevice);
exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable"); exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable");
exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); exeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
exeAspect->setHistoryCompleter("Qt.CustomExecutable.History"); exeAspect->setHistoryCompleter("Qt.CustomExecutable.History");

View File

@@ -68,7 +68,7 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Id id, Kind kin
{ {
auto envAspect = addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ExecutableAspect>(target); addAspect<ExecutableAspect>(target, ExecutableAspect::HostDevice);
addAspect<ArgumentsAspect>(macroExpander()); addAspect<ArgumentsAspect>(macroExpander());
addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect); addAspect<WorkingDirectoryAspect>(macroExpander(), envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();

View File

@@ -25,13 +25,12 @@
#include "runconfigurationaspects.h" #include "runconfigurationaspects.h"
#include "devicesupport/devicemanager.h"
#include "devicesupport/idevice.h" #include "devicesupport/idevice.h"
#include "environmentaspect.h" #include "environmentaspect.h"
#include "kitinformation.h" #include "kitinformation.h"
#include "project.h"
#include "projectexplorer.h" #include "projectexplorer.h"
#include "projectexplorersettings.h" #include "projectexplorersettings.h"
#include "runconfiguration.h"
#include "target.h" #include "target.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -514,8 +513,8 @@ void ArgumentsAspect::addToLayout(LayoutBuilder &builder)
by the build system's parsing results with an optional manual override. by the build system's parsing results with an optional manual override.
*/ */
ExecutableAspect::ExecutableAspect(Target *target) ExecutableAspect::ExecutableAspect(Target *target, ExecutionDeviceSelector selector)
: m_target(target) : m_target(target), m_selector(selector)
{ {
setDisplayName(tr("Executable")); setDisplayName(tr("Executable"));
setId("ExecutableAspect"); setId("ExecutableAspect");
@@ -534,9 +533,16 @@ ExecutableAspect::ExecutableAspect(Target *target)
\internal \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() ExecutableAspect::~ExecutableAspect()
@@ -547,7 +553,7 @@ ExecutableAspect::~ExecutableAspect()
void ExecutableAspect::updateDevice() 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(); const OsType osType = dev ? dev->osType() : HostOsInfo::hostOs();
m_executable.setDisplayFilter([osType](const QString &pathName) { m_executable.setDisplayFilter([osType](const QString &pathName) {
@@ -638,7 +644,7 @@ FilePath ExecutableAspect::executable() const
? m_alternativeExecutable->filePath() ? m_alternativeExecutable->filePath()
: m_executable.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()); exe = dev->filePath(exe.path());
return exe; return exe;

View File

@@ -175,7 +175,9 @@ class PROJECTEXPLORER_EXPORT ExecutableAspect : public Utils::BaseAspect
Q_OBJECT Q_OBJECT
public: 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; ~ExecutableAspect() override;
Utils::FilePath executable() const; Utils::FilePath executable() const;
@@ -207,6 +209,7 @@ private:
Utils::StringAspect m_executable; Utils::StringAspect m_executable;
Utils::StringAspect *m_alternativeExecutable = nullptr; Utils::StringAspect *m_alternativeExecutable = nullptr;
Target *m_target = nullptr; Target *m_target = nullptr;
ExecutionDeviceSelector m_selector = RunDevice;
}; };
class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::StringAspect class PROJECTEXPLORER_EXPORT SymbolFileAspect : public Utils::StringAspect

View File

@@ -47,7 +47,7 @@ namespace Internal {
QnxRunConfiguration::QnxRunConfiguration(Target *target, Id id) QnxRunConfiguration::QnxRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto exeAspect = addAspect<ExecutableAspect>(target); auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setLabelText(tr("Executable on device:"));
exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->setPlaceHolderText(tr("Remote path not set"));
exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",

View File

@@ -67,7 +67,8 @@ MakeInstallStep::MakeInstallStep(BuildStepList *parent, Id id) : MakeStep(parent
jobCountAspect()->setVisible(false); jobCountAspect()->setVisible(false);
disabledForSubdirsAspect()->setVisible(false); disabledForSubdirsAspect()->setVisible(false);
const auto makeAspect = addAspect<ExecutableAspect>(parent->target()); const auto makeAspect = addAspect<ExecutableAspect>(parent->target(),
ExecutableAspect::BuildDevice);
makeAspect->setId(MakeAspectId); makeAspect->setId(MakeAspectId);
makeAspect->setSettingsKey(MakeAspectId); makeAspect->setSettingsKey(MakeAspectId);
makeAspect->setDisplayStyle(StringAspect::PathChooserDisplay); makeAspect->setDisplayStyle(StringAspect::PathChooserDisplay);

View File

@@ -59,7 +59,7 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target); auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
auto exeAspect = addAspect<ExecutableAspect>(target); auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
exeAspect->setLabelText(tr("Remote executable:")); exeAspect->setLabelText(tr("Remote executable:"));
exeAspect->setDisplayStyle(StringAspect::LineEditDisplay); exeAspect->setDisplayStyle(StringAspect::LineEditDisplay);

View File

@@ -59,7 +59,7 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target); auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
auto exeAspect = addAspect<ExecutableAspect>(target); auto exeAspect = addAspect<ExecutableAspect>(target, ExecutableAspect::RunDevice);
exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setLabelText(tr("Executable on device:"));
exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->setPlaceHolderText(tr("Remote path not set"));
exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable",