summaryrefslogtreecommitdiff
path: root/src/plugins/qnx
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2018-04-16 13:28:47 +0200
committerhjk <hjk@qt.io>2018-04-23 10:34:08 +0000
commit4b9945c32981105bfae3ba59f9565757f0dc7417 (patch)
treefe74b67d390b0a8cf7bcf60730a1f4bdb11e260c /src/plugins/qnx
parentef660d8bd03b71dfa51ac08ef72c3ebc1adbbfd7 (diff)
downloadqt-creator-4b9945c32981105bfae3ba59f9565757f0dc7417.tar.gz
ProjectExplorer: Rework executable display handling in runconfigs
The basic idea is to provide an easy-to-configure reusable building block to provide an "Executable" in a run configuration. This patch here extracts some generic from the previous ExecutableAspect into a BaseStringAspect and bases the new ExecutableAspect implementation on it. It also adds the the ability to make it editable or to manually override an executable, and adds a SymbolFile aspect for the accompanying sources of debug information. Use in RemoteLinux and Qnx for starters and demonstration purposes. In the end the Qnx runconfiguration widget does not depend on the RemoteLinux implementation anymore by replacing the previous code-sharing-by-inheritance by direct (and less) code. Change-Id: I91b55820455256a8526e39458364b6cb74e63cd7 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/qnx')
-rw-r--r--src/plugins/qnx/qnxdebugsupport.cpp8
-rw-r--r--src/plugins/qnx/qnxrunconfiguration.cpp68
-rw-r--r--src/plugins/qnx/qnxrunconfiguration.h14
-rw-r--r--src/plugins/qnx/slog2inforunner.cpp6
4 files changed, 39 insertions, 57 deletions
diff --git a/src/plugins/qnx/qnxdebugsupport.cpp b/src/plugins/qnx/qnxdebugsupport.cpp
index d68c091113..95284459e8 100644
--- a/src/plugins/qnx/qnxdebugsupport.cpp
+++ b/src/plugins/qnx/qnxdebugsupport.cpp
@@ -45,6 +45,7 @@
#include <projectexplorer/kitchooser.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
@@ -157,7 +158,6 @@ QnxDebugSupport::QnxDebugSupport(RunControl *runControl)
setSolibSearchPath(searchPaths(k));
if (auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k)))
setSysRoot(qtVersion->qnxTarget());
- setSymbolFile(runConfig->localExecutableFilePath());
}
@@ -263,8 +263,10 @@ void QnxAttachDebugSupport::showProcessesDialog()
const int pid = process.pid;
// QString projectSourceDirectory = dlg.projectSource();
QString localExecutable = dlg.localExecutable();
- if (localExecutable.isEmpty())
- localExecutable = runConfig->localExecutableFilePath();
+ if (localExecutable.isEmpty()) {
+ if (auto aspect = runConfig->extraAspect<SymbolFileAspect>())
+ localExecutable = aspect->fileName().toString();
+ }
auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE);
auto debugger = new QnxAttachDebugSupport(runControl);
diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp
index 592f5a8692..0b4c184e73 100644
--- a/src/plugins/qnx/qnxrunconfiguration.cpp
+++ b/src/plugins/qnx/qnxrunconfiguration.cpp
@@ -26,17 +26,12 @@
#include "qnxrunconfiguration.h"
#include "qnxconstants.h"
-#include "qnxdevicefactory.h"
#include <projectexplorer/runnables.h>
-#include <projectexplorer/target.h>
-
-#include <remotelinux/remotelinuxrunconfigurationwidget.h>
#include <utils/environment.h>
-#include <QLabel>
-#include <QLineEdit>
+#include <QFormLayout>
using namespace ProjectExplorer;
using namespace RemoteLinux;
@@ -44,60 +39,41 @@ using namespace RemoteLinux;
namespace Qnx {
namespace Internal {
-const char QtLibPathKey[] = "Qt4ProjectManager.QnxRunConfiguration.QtLibPath";
-
QnxRunConfiguration::QnxRunConfiguration(Target *target)
: RemoteLinuxRunConfiguration(target, Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)
-{}
+{
+ auto libAspect = new QtLibPathAspect(this);
+ libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath");
+ libAspect->setLabelText(tr("Path to Qt libraries on device"));
+ addExtraAspect(libAspect);
+}
Runnable QnxRunConfiguration::runnable() const
{
auto r = RemoteLinuxRunConfiguration::runnable().as<StandardRunnable>();
- if (!m_qtLibPath.isEmpty()) {
- r.environment.appendOrSet(QLatin1String("LD_LIBRARY_PATH"),
- m_qtLibPath + QLatin1String("/lib:$LD_LIBRARY_PATH"));
- r.environment.appendOrSet(QLatin1String("QML_IMPORT_PATH"),
- m_qtLibPath + QLatin1String("/imports:$QML_IMPORT_PATH"));
- r.environment.appendOrSet(QLatin1String("QML2_IMPORT_PATH"),
- m_qtLibPath + QLatin1String("/qml:$QML2_IMPORT_PATH"));
- r.environment.appendOrSet(QLatin1String("QT_PLUGIN_PATH"),
- m_qtLibPath + QLatin1String("/plugins:$QT_PLUGIN_PATH"));
- r.environment.set(QLatin1String("QT_QPA_FONTDIR"),
- m_qtLibPath + QLatin1String("/lib/fonts"));
+ QString libPath = extraAspect<QtLibPathAspect>()->value();
+ if (!libPath.isEmpty()) {
+ r.environment.appendOrSet("LD_LIBRARY_PATH", libPath + "/lib:$LD_LIBRARY_PATH");
+ r.environment.appendOrSet("QML_IMPORT_PATH", libPath + "/imports:$QML_IMPORT_PATH");
+ r.environment.appendOrSet("QML2_IMPORT_PATH", libPath + "/qml:$QML2_IMPORT_PATH");
+ r.environment.appendOrSet("QT_PLUGIN_PATH", libPath + "/plugins:$QT_PLUGIN_PATH");
+ r.environment.set("QT_QPA_FONTDIR", libPath + "/lib/fonts");
}
return r;
}
QWidget *QnxRunConfiguration::createConfigurationWidget()
{
- auto rcWidget = qobject_cast<RemoteLinuxRunConfigurationWidget *>
- (RemoteLinuxRunConfiguration::createConfigurationWidget());
-
- auto label = new QLabel(tr("Path to Qt libraries on device:"));
- auto lineEdit = new QLineEdit(m_qtLibPath);
-
- connect(lineEdit, &QLineEdit::textChanged,
- this, [this](const QString &path) { m_qtLibPath = path; });
-
- rcWidget->addFormLayoutRow(label, lineEdit);
+ auto widget = new QWidget;
+ auto formLayout = new QFormLayout(widget);
- return rcWidget;
-}
-
-QVariantMap QnxRunConfiguration::toMap() const
-{
- QVariantMap map(RemoteLinuxRunConfiguration::toMap());
- map.insert(QLatin1String(QtLibPathKey), m_qtLibPath);
- return map;
-}
-
-bool QnxRunConfiguration::fromMap(const QVariantMap &map)
-{
- if (!RemoteLinuxRunConfiguration::fromMap(map))
- return false;
+ extraAspect<ExecutableAspect>()->addToMainConfigurationWidget(widget, formLayout);
+ extraAspect<SymbolFileAspect>()->addToMainConfigurationWidget(widget, formLayout);
+ extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(widget, formLayout);
+ extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(widget, formLayout);
+ extraAspect<QtLibPathAspect>()->addToMainConfigurationWidget(widget, formLayout);
- m_qtLibPath = map.value(QLatin1String(QtLibPathKey)).toString();
- return true;
+ return wrapWidget(widget);
}
// QnxRunConfigurationFactory
diff --git a/src/plugins/qnx/qnxrunconfiguration.h b/src/plugins/qnx/qnxrunconfiguration.h
index 3d8036023f..9cb0813850 100644
--- a/src/plugins/qnx/qnxrunconfiguration.h
+++ b/src/plugins/qnx/qnxrunconfiguration.h
@@ -25,11 +25,20 @@
#pragma once
+#include <projectexplorer/runconfigurationaspects.h>
#include <remotelinux/remotelinuxrunconfiguration.h>
namespace Qnx {
namespace Internal {
+class QtLibPathAspect : public ProjectExplorer::BaseStringAspect
+{
+ Q_OBJECT
+
+public:
+ QtLibPathAspect(ProjectExplorer::RunConfiguration *rc) : BaseStringAspect(rc) {}
+};
+
class QnxRunConfiguration : public RemoteLinux::RemoteLinuxRunConfiguration
{
Q_OBJECT
@@ -40,11 +49,6 @@ public:
private:
ProjectExplorer::Runnable runnable() const override;
QWidget *createConfigurationWidget() override;
-
- QVariantMap toMap() const override;
- bool fromMap(const QVariantMap &map) override;
-
- QString m_qtLibPath;
};
class QnxRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp
index b5075285b4..8fd0e541b5 100644
--- a/src/plugins/qnx/slog2inforunner.cpp
+++ b/src/plugins/qnx/slog2inforunner.cpp
@@ -29,7 +29,9 @@
#include "qnxdeviceprocess.h"
#include "qnxrunconfiguration.h"
+#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runnables.h>
+
#include <utils/qtcassert.h>
#include <QRegExp>
@@ -44,9 +46,7 @@ Slog2InfoRunner::Slog2InfoRunner(RunControl *runControl)
: RunWorker(runControl)
{
setDisplayName("Slog2InfoRunner");
- auto qnxRunConfig = qobject_cast<QnxRunConfiguration *>(runControl->runConfiguration());
- QTC_ASSERT(qnxRunConfig, return);
- m_applicationId = FileName::fromString(qnxRunConfig->remoteExecutableFilePath()).fileName();
+ m_applicationId = runControl->runConfiguration()->extraAspect<ExecutableAspect>()->executable().fileName();
// See QTCREATORBUG-10712 for details.
// We need to limit length of ApplicationId to 63 otherwise it would not match one in slog2info.