forked from qt-creator/qt-creator
ProjectExplorer: Allow to specific target device for EnvironmentAspects
Similar to what is done for ExecutableAspect. The device related part is here not used yet, as only run related setups are affected. This might change with an attempt to unify EnvironmentAspect and RemoteLinuxEnvironmentAspect. Change-Id: I6a620ad1d3443f0e8201c2572689edda1f84593c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -80,7 +80,8 @@ QdbRunConfiguration::QdbRunConfiguration(Target *target, Id id)
|
||||
symbolsAspect->setLabelText(Tr::tr("Executable on host:"));
|
||||
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
|
||||
|
||||
auto envAspect = addAspect<RemoteLinux::RemoteLinuxEnvironmentAspect>(target);
|
||||
auto envAspect = addAspect<RemoteLinux::RemoteLinuxEnvironmentAspect>();
|
||||
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
auto argsAspect = addAspect<ArgumentsAspect>();
|
||||
argsAspect->setMacroExpander(macroExpander());
|
||||
|
@@ -30,6 +30,12 @@ EnvironmentAspect::EnvironmentAspect(AspectContainer *container)
|
||||
addDataExtractor(this, &EnvironmentAspect::environment, &Data::environment);
|
||||
}
|
||||
|
||||
void EnvironmentAspect::setDeviceSelector(Target *target, DeviceSelector selector)
|
||||
{
|
||||
m_target = target;
|
||||
m_selector = selector;
|
||||
}
|
||||
|
||||
int EnvironmentAspect::baseEnvironmentBase() const
|
||||
{
|
||||
return m_base;
|
||||
|
@@ -22,6 +22,9 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspect : public Utils::BaseAspect
|
||||
public:
|
||||
EnvironmentAspect(Utils::AspectContainer *container = nullptr);
|
||||
|
||||
enum DeviceSelector { HostDevice, BuildDevice, RunDevice };
|
||||
void setDeviceSelector(Target *target, DeviceSelector selector);
|
||||
|
||||
// The environment including the user's modifications.
|
||||
Utils::Environment environment() const;
|
||||
|
||||
@@ -50,6 +53,8 @@ public:
|
||||
|
||||
bool isLocal() const { return m_isLocal; }
|
||||
|
||||
Target *target() const { return m_target; }
|
||||
|
||||
bool isPrintOnRunAllowed() const { return m_allowPrintOnRun; }
|
||||
bool isPrintOnRunEnabled() const { return m_printOnRun; }
|
||||
void setPrintOnRun(bool enabled) { m_printOnRun = enabled; }
|
||||
@@ -93,6 +98,8 @@ private:
|
||||
bool m_isLocal = false;
|
||||
bool m_allowPrintOnRun = true;
|
||||
bool m_printOnRun = false;
|
||||
Target *m_target = nullptr;
|
||||
DeviceSelector m_selector = RunDevice;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -40,7 +40,8 @@ public:
|
||||
symbolsAspect->setLabelText(Tr::tr("Executable on host:"));
|
||||
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
|
||||
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>();
|
||||
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
auto argsAspect = addAspect<ArgumentsAspect>();
|
||||
argsAspect->setMacroExpander(macroExpander());
|
||||
|
@@ -32,7 +32,8 @@ private:
|
||||
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>();
|
||||
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice);
|
||||
|
@@ -32,24 +32,26 @@ const int ENVIRONMENTASPECT_VERSION = 1; // Version was introduced in 4.3 with t
|
||||
class RemoteLinuxEnvironmentAspectWidget : public EnvironmentAspectWidget
|
||||
{
|
||||
public:
|
||||
RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect, Target *target)
|
||||
RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect)
|
||||
: EnvironmentAspectWidget(aspect)
|
||||
{
|
||||
auto fetchButton = new QPushButton(Tr::tr("Fetch Device Environment"));
|
||||
addWidget(fetchButton);
|
||||
|
||||
connect(target, &Target::kitChanged, aspect, [aspect] { aspect->setRemoteEnvironment({}); });
|
||||
connect(aspect->target(), &Target::kitChanged, aspect, [aspect] {
|
||||
aspect->setRemoteEnvironment({});
|
||||
});
|
||||
|
||||
connect(fetchButton, &QPushButton::clicked, this, [aspect, target] {
|
||||
if (IDevice::ConstPtr device = DeviceKitAspect::device(target->kit())) {
|
||||
connect(fetchButton, &QPushButton::clicked, this, [aspect] {
|
||||
if (IDevice::ConstPtr device = DeviceKitAspect::device(aspect->target()->kit())) {
|
||||
DeviceFileAccess *access = device->fileAccess();
|
||||
QTC_ASSERT(access, return);
|
||||
aspect->setRemoteEnvironment(access->deviceEnvironment());
|
||||
}
|
||||
});
|
||||
|
||||
envWidget()->setOpenTerminalFunc([target](const Environment &env) {
|
||||
IDevice::ConstPtr device = DeviceKitAspect::device(target->kit());
|
||||
envWidget()->setOpenTerminalFunc([aspect](const Environment &env) {
|
||||
IDevice::ConstPtr device = DeviceKitAspect::device(aspect->target()->kit());
|
||||
if (!device) {
|
||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||
Tr::tr("Cannot Open Terminal"),
|
||||
@@ -70,14 +72,12 @@ static bool displayAlreadySet(const Utils::EnvironmentItems &changes)
|
||||
});
|
||||
}
|
||||
|
||||
RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(Target *target)
|
||||
RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect()
|
||||
{
|
||||
addSupportedBaseEnvironment(Tr::tr("Clean Environment"), {});
|
||||
addPreferredBaseEnvironment(Tr::tr("System Environment"), [this] { return m_remoteEnvironment; });
|
||||
|
||||
setConfigWidgetCreator([this, target] {
|
||||
return new RemoteLinuxEnvironmentAspectWidget(this, target);
|
||||
});
|
||||
setConfigWidgetCreator([this] { return new RemoteLinuxEnvironmentAspectWidget(this); });
|
||||
}
|
||||
|
||||
void RemoteLinuxEnvironmentAspect::setRemoteEnvironment(const Utils::Environment &env)
|
||||
|
@@ -14,7 +14,7 @@ class REMOTELINUX_EXPORT RemoteLinuxEnvironmentAspect : public ProjectExplorer::
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RemoteLinuxEnvironmentAspect(ProjectExplorer::Target *target);
|
||||
RemoteLinuxEnvironmentAspect();
|
||||
|
||||
void setRemoteEnvironment(const Utils::Environment &env);
|
||||
|
||||
|
@@ -33,7 +33,8 @@ public:
|
||||
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
|
||||
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>();
|
||||
envAspect->setDeviceSelector(target, EnvironmentAspect::RunDevice);
|
||||
|
||||
auto exeAspect = addAspect<ExecutableAspect>();
|
||||
exeAspect->setDeviceSelector(target, ExecutableAspect::RunDevice);
|
||||
|
Reference in New Issue
Block a user