ProjectExplorer: Drop LocalApplicationRunConfiguration

The functionality can be provided by producing a suitable Runnable
in the derived classes directly.

Change-Id: I7b8e8fe33fffd2b00176b6cf6633eca4e152e466
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2016-01-25 15:00:20 +01:00
parent 4ea8caccf2
commit 9ae2ce7629
28 changed files with 244 additions and 318 deletions

View File

@@ -30,8 +30,9 @@
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -94,20 +95,17 @@ void basicProjectInformation(Project *project, const QString &proFile, QString *
} }
} }
void extractEnvironmentInformation(LocalApplicationRunConfiguration *localRunConfiguration, static bool isLocal(RunConfiguration *runConfiguration)
QString *workDir, Utils::Environment *env)
{ {
*workDir = Utils::FileUtils::normalizePathName(localRunConfiguration->workingDirectory()); Target *target = runConfiguration ? runConfiguration->target() : 0;
if (auto environmentAspect = localRunConfiguration->extraAspect<EnvironmentAspect>()) Kit *kit = target ? target->kit() : 0;
*env = environmentAspect->environment(); return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
} }
void TestConfiguration::completeTestInformation() void TestConfiguration::completeTestInformation()
{ {
QTC_ASSERT(!m_mainFilePath.isEmpty() || !m_proFile.isEmpty(), return); QTC_ASSERT(!m_mainFilePath.isEmpty() || !m_proFile.isEmpty(), return);
typedef LocalApplicationRunConfiguration LocalRunConfig;
Project *project = SessionManager::startupProject(); Project *project = SessionManager::startupProject();
if (!project) if (!project)
return; return;
@@ -144,21 +142,30 @@ void TestConfiguration::completeTestInformation()
QList<RunConfiguration *> rcs = target->runConfigurations(); QList<RunConfiguration *> rcs = target->runConfigurations();
foreach (RunConfiguration *rc, rcs) { foreach (RunConfiguration *rc, rcs) {
auto config = qobject_cast<LocalRunConfig *>(rc); Runnable runnable = rc->runnable();
if (config && config->executable() == targetFile) { if (isLocal(rc) && runnable.is<StandardRunnable>()) {
extractEnvironmentInformation(config, &workDir, &env); StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
hasDesktopTarget = true; if (stdRunnable.executable == targetFile) {
break; workDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
env = stdRunnable.environment;
hasDesktopTarget = true;
break;
}
} }
} }
// if we could not figure out the run configuration // if we could not figure out the run configuration
// try to use the run configuration of the parent project // try to use the run configuration of the parent project
if (!hasDesktopTarget && targetProject && !targetFile.isEmpty()) { if (!hasDesktopTarget && targetProject && !targetFile.isEmpty()) {
if (auto config = qobject_cast<LocalRunConfig *>(target->activeRunConfiguration())) { if (auto rc = target->activeRunConfiguration()) {
extractEnvironmentInformation(config, &workDir, &env); Runnable runnable = rc->runnable();
hasDesktopTarget = true; if (isLocal(rc) && runnable.is<StandardRunnable>()) {
guessedRunConfiguration = true; StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
workDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
env = stdRunnable.environment;
hasDesktopTarget = true;
guessedRunConfiguration = true;
}
} }
} }

View File

@@ -61,11 +61,11 @@ const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title";
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const QString &target, CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const QString &target,
const QString &workingDirectory, const QString &title) : const QString &workingDirectory, const QString &title) :
LocalApplicationRunConfiguration(parent, id), RunConfiguration(parent, id),
m_buildTarget(target), m_buildTarget(target),
m_title(title) m_title(title)
{ {
addExtraAspect(new LocalEnvironmentAspect(this)); addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.Arguments"))); addExtraAspect(new ArgumentsAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.Arguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.UseTerminal"))); addExtraAspect(new TerminalAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.UseTerminal")));
@@ -77,7 +77,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const
} }
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfiguration *source) : CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source), RunConfiguration(parent, source),
m_buildTarget(source->m_buildTarget), m_buildTarget(source->m_buildTarget),
m_title(source->m_title), m_title(source->m_title),
m_enabled(source->m_enabled) m_enabled(source->m_enabled)
@@ -90,36 +90,25 @@ void CMakeRunConfiguration::ctor()
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
} }
QString CMakeRunConfiguration::executable() const Runnable CMakeRunConfiguration::runnable() const
{ {
return m_buildTarget; StandardRunnable r;
} r.executable = m_buildTarget;
r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments();
ApplicationLauncher::Mode CMakeRunConfiguration::runMode() const r.workingDirectory = extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
{ r.environment = extraAspect<LocalEnvironmentAspect>()->environment();
return extraAspect<TerminalAspect>()->runMode(); r.runMode = extraAspect<TerminalAspect>()->runMode();
} return r;
QString CMakeRunConfiguration::workingDirectory() const
{
const auto *wdAspect = extraAspect<WorkingDirectoryAspect>();
QTC_ASSERT(wdAspect, return baseWorkingDirectory());
return wdAspect->workingDirectory().toString();
} }
QString CMakeRunConfiguration::baseWorkingDirectory() const QString CMakeRunConfiguration::baseWorkingDirectory() const
{ {
const QString exe = executable(); const QString exe = m_buildTarget;
if (!exe.isEmpty()) if (!exe.isEmpty())
return QFileInfo(executable()).absolutePath(); return QFileInfo(m_buildTarget).absolutePath();
return QString(); return QString();
} }
QString CMakeRunConfiguration::commandLineArguments() const
{
return extraAspect<ArgumentsAspect>()->arguments();
}
QString CMakeRunConfiguration::title() const QString CMakeRunConfiguration::title() const
{ {
return m_title; return m_title;
@@ -138,7 +127,7 @@ void CMakeRunConfiguration::setBaseWorkingDirectory(const QString &wd)
QVariantMap CMakeRunConfiguration::toMap() const QVariantMap CMakeRunConfiguration::toMap() const
{ {
QVariantMap map(LocalApplicationRunConfiguration::toMap()); QVariantMap map(RunConfiguration::toMap());
map.insert(QLatin1String(TITLE_KEY), m_title); map.insert(QLatin1String(TITLE_KEY), m_title);
return map; return map;
} }

View File

@@ -26,24 +26,13 @@
#ifndef CMAKERUNCONFIGURATION_H #ifndef CMAKERUNCONFIGURATION_H
#define CMAKERUNCONFIGURATION_H #define CMAKERUNCONFIGURATION_H
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <utils/environment.h> #include <utils/environment.h>
QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
namespace Utils {
class PathChooser;
class DetailsWidget;
}
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
class CMakeTarget; class CMakeRunConfiguration : public ProjectExplorer::RunConfiguration
class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
{ {
Q_OBJECT Q_OBJECT
friend class CMakeRunConfigurationWidget; friend class CMakeRunConfigurationWidget;
@@ -53,10 +42,7 @@ public:
CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target, CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target,
const QString &workingDirectory, const QString &title); const QString &workingDirectory, const QString &title);
QString executable() const override; ProjectExplorer::Runnable runnable() const override;
ProjectExplorer::ApplicationLauncher::Mode runMode() const override;
QString workingDirectory() const override;
QString commandLineArguments() const override;
QWidget *createConfigurationWidget() override; QWidget *createConfigurationWidget() override;
void setExecutable(const QString &executable); void setExecutable(const QString &executable);

View File

@@ -87,7 +87,6 @@
#include <extensionsystem/invoker.h> #include <extensionsystem/invoker.h>
#include <projectexplorer/localapplicationrunconfiguration.h>
#include <projectexplorer/buildmanager.h> #include <projectexplorer/buildmanager.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
@@ -98,6 +97,7 @@
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
#include <projectexplorer/projectexplorersettings.h> #include <projectexplorer/projectexplorersettings.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>

View File

@@ -40,9 +40,9 @@
#include <projectexplorer/devicesupport/deviceprocessesdialog.h> #include <projectexplorer/devicesupport/deviceprocessesdialog.h>
#include <projectexplorer/devicesupport/deviceprocesslist.h> #include <projectexplorer/devicesupport/deviceprocesslist.h>
#include <projectexplorer/environmentaspect.h> // For the environment #include <projectexplorer/environmentaspect.h> // For the environment
#include <projectexplorer/localapplicationrunconfiguration.h> // For LocalApplication*
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
@@ -331,12 +331,13 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
m_runConfig = runConfig; m_runConfig = runConfig;
// Extract as much as possible from available RunConfiguration. // Extract as much as possible from available RunConfiguration.
if (auto localRc = qobject_cast<const LocalApplicationRunConfiguration *>(m_runConfig)) { if (m_runConfig->runnable().is<StandardRunnable>()) {
m_rp.executable = localRc->executable(); auto runnable = m_runConfig->runnable().as<StandardRunnable>();
m_rp.processArgs = localRc->commandLineArguments(); m_rp.executable = runnable.executable;
m_rp.useTerminal = localRc->runMode() == ApplicationLauncher::Console; m_rp.processArgs = runnable.commandLineArguments;
m_rp.useTerminal = runnable.runMode == ApplicationLauncher::Console;
// Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...)
m_rp.workingDirectory = FileUtils::normalizePathName(localRc->workingDirectory()); m_rp.workingDirectory = FileUtils::normalizePathName(runnable.workingDirectory);
} }
// Find a Kit and Target. Either could be missing. // Find a Kit and Target. Either could be missing.
@@ -630,9 +631,11 @@ public:
bool canRun(RunConfiguration *runConfig, Core::Id mode) const override bool canRun(RunConfiguration *runConfig, Core::Id mode) const override
{ {
return (mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain) if (!(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain))
&& (qobject_cast<LocalApplicationRunConfiguration *>(runConfig) return false;
|| isDebuggableScript(runConfig)); return DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
|| isDebuggableScript(runConfig);
} }
IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override

View File

@@ -38,7 +38,7 @@
#include <projectexplorer/projecttree.h> #include <projectexplorer/projecttree.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
@@ -56,6 +56,13 @@ using namespace ProjectExplorer;
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
static bool isLocal(RunConfiguration *runConfiguration)
{
Target *target = runConfiguration ? runConfiguration->target() : 0;
Kit *kit = target ? target->kit() : 0;
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
}
/*! /*!
\class Debugger::Internal::UnstartedAppWatcherDialog \class Debugger::Internal::UnstartedAppWatcherDialog
@@ -88,8 +95,11 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent)
m_kitChooser->setVisible(true); m_kitChooser->setVisible(true);
Project *project = ProjectTree::currentProject(); Project *project = ProjectTree::currentProject();
if (project && project->activeTarget() && project->activeTarget()->kit()) Target *activeTarget = project ? project->activeTarget() : 0;
m_kitChooser->setCurrentKitId(project->activeTarget()->kit()->id()); Kit *kit = activeTarget ? activeTarget->kit() : 0;
if (kit)
m_kitChooser->setCurrentKitId(kit->id());
else if (KitManager::defaultKit()) else if (KitManager::defaultKit())
m_kitChooser->setCurrentKitId(KitManager::defaultKit()->id()); m_kitChooser->setCurrentKitId(KitManager::defaultKit()->id());
@@ -97,13 +107,12 @@ UnstartedAppWatcherDialog::UnstartedAppWatcherDialog(QWidget *parent)
m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable")); m_pathChooser->setHistoryCompleter(QLatin1String("LocalExecutable"));
if (project && project->activeTarget() && project->activeTarget()->activeRunConfiguration()) { if (activeTarget) {
LocalApplicationRunConfiguration *localAppRC = if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) {
qobject_cast<LocalApplicationRunConfiguration *> const Runnable runnable = runConfig->runnable();
(project->activeTarget()->activeRunConfiguration()); if (runnable.is<StandardRunnable>() && isLocal(runConfig))
m_pathChooser->setPath(runnable.as<StandardRunnable>().executable);
if (localAppRC) }
m_pathChooser->setPath(localAppRC->executable());
} }
m_hideOnAttachCheckBox = new QCheckBox(tr("Reopen dialog when application finishes"), this); m_hideOnAttachCheckBox = new QCheckBox(tr("Reopen dialog when application finishes"), this);
@@ -171,20 +180,19 @@ void UnstartedAppWatcherDialog::selectExecutable()
QString path; QString path;
Project *project = ProjectTree::currentProject(); Project *project = ProjectTree::currentProject();
Target *activeTarget = project ? project->activeTarget() : 0;
if (project && project->activeTarget() && project->activeTarget()->activeRunConfiguration()) { if (activeTarget) {
if (RunConfiguration *runConfig = activeTarget->activeRunConfiguration()) {
LocalApplicationRunConfiguration *localAppRC = const Runnable runnable = runConfig->runnable();
qobject_cast<LocalApplicationRunConfiguration *> if (runnable.is<StandardRunnable>() && isLocal(runConfig))
(project->activeTarget()->activeRunConfiguration()); path = QFileInfo(runnable.as<StandardRunnable>().executable).path();
if (localAppRC) }
path = QFileInfo(localAppRC->executable()).path();
} }
if (path.isEmpty()) { if (path.isEmpty()) {
if (project && project->activeTarget() && if (activeTarget && activeTarget->activeBuildConfiguration()) {
project->activeTarget()->activeBuildConfiguration()) { path = activeTarget->activeBuildConfiguration()->buildDirectory().toString();
path = project->activeTarget()->activeBuildConfiguration()->buildDirectory().toString();
} else if (project) { } else if (project) {
path = project->projectDirectory().toString(); path = project->projectDirectory().toString();
} }

View File

@@ -1,54 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#ifndef LOCALAPPLICATIONRUNCONFIGURATION_H
#define LOCALAPPLICATIONRUNCONFIGURATION_H
#include "runconfiguration.h"
#include "applicationlauncher.h"
namespace Utils { class Environment; }
namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT LocalApplicationRunConfiguration : public RunConfiguration
{
Q_OBJECT
public:
virtual QString executable() const = 0;
virtual ApplicationLauncher::Mode runMode() const = 0;
virtual QString workingDirectory() const = 0;
virtual QString commandLineArguments() const = 0;
virtual void addToBaseEnvironment(Utils::Environment &env) const;
protected:
explicit LocalApplicationRunConfiguration(Target *target, Core::Id id);
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
};
} // namespace ProjectExplorer
#endif // LOCALAPPLICATIONRUNCONFIGURATION_H

View File

@@ -24,11 +24,14 @@
****************************************************************************/ ****************************************************************************/
#include "localapplicationruncontrol.h" #include "localapplicationruncontrol.h"
#include "localapplicationrunconfiguration.h" #include "runnables.h"
#include "environmentaspect.h" #include "environmentaspect.h"
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorericons.h> #include <projectexplorer/projectexplorericons.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/environment.h> #include <utils/environment.h>
@@ -37,30 +40,27 @@
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
LocalApplicationRunControlFactory::LocalApplicationRunControlFactory() static bool isLocal(RunConfiguration *runConfiguration)
{
}
LocalApplicationRunControlFactory::~LocalApplicationRunControlFactory()
{ {
Target *target = runConfiguration ? runConfiguration->target() : 0;
Kit *kit = target ? target->kit() : 0;
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
} }
bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{ {
return mode == Constants::NORMAL_RUN_MODE && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); return mode == Constants::NORMAL_RUN_MODE && isLocal(runConfiguration);
} }
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{ {
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(runConfiguration->runnable().is<StandardRunnable>(), return 0);
LocalApplicationRunConfiguration *localRunConfiguration = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); auto runnable = runConfiguration->runnable().as<StandardRunnable>();
auto runControl = new LocalApplicationRunControl(runConfiguration, mode);
QTC_ASSERT(localRunConfiguration, return 0); runControl->setCommand(runnable.executable, runnable.commandLineArguments);
LocalApplicationRunControl *runControl = new LocalApplicationRunControl(localRunConfiguration, mode); runControl->setApplicationLauncherMode(runnable.runMode);
runControl->setCommand(localRunConfiguration->executable(), localRunConfiguration->commandLineArguments()); runControl->setWorkingDirectory(runnable.workingDirectory);
runControl->setApplicationLauncherMode(localRunConfiguration->runMode());
runControl->setWorkingDirectory(localRunConfiguration->workingDirectory());
return runControl; return runControl;
} }

View File

@@ -36,8 +36,6 @@ class LocalApplicationRunControlFactory : public IRunControlFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
LocalApplicationRunControlFactory ();
~LocalApplicationRunControlFactory();
bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
RunControl* create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage); RunControl* create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage);
}; };

View File

@@ -27,7 +27,7 @@
#include "buildconfiguration.h" #include "buildconfiguration.h"
#include "environmentaspectwidget.h" #include "environmentaspectwidget.h"
#include "localapplicationrunconfiguration.h" #include "runnables.h"
#include "kit.h" #include "kit.h"
#include "target.h" #include "target.h"
@@ -72,8 +72,8 @@ Utils::Environment LocalEnvironmentAspect::baseEnvironment() const
env = Utils::Environment::systemEnvironment(); env = Utils::Environment::systemEnvironment();
} }
if (const LocalApplicationRunConfiguration *rc = qobject_cast<const LocalApplicationRunConfiguration *>(runConfiguration())) if (m_baseEnvironmentModifier)
rc->addToBaseEnvironment(env); m_baseEnvironmentModifier(env);
return env; return env;
} }
@@ -84,16 +84,17 @@ void LocalEnvironmentAspect::buildEnvironmentHasChanged()
emit environmentChanged(); emit environmentChanged();
} }
LocalEnvironmentAspect::LocalEnvironmentAspect(RunConfiguration *parent) : LocalEnvironmentAspect::LocalEnvironmentAspect(RunConfiguration *parent,
EnvironmentAspect(parent) const BaseEnvironmentModifier &modifier) :
EnvironmentAspect(parent), m_baseEnvironmentModifier(modifier)
{ {
connect(parent->target(), SIGNAL(environmentChanged()), connect(parent->target(), &Target::environmentChanged,
this, SLOT(buildEnvironmentHasChanged())); this, &LocalEnvironmentAspect::buildEnvironmentHasChanged);
} }
LocalEnvironmentAspect *LocalEnvironmentAspect::create(RunConfiguration *parent) const LocalEnvironmentAspect *LocalEnvironmentAspect::create(RunConfiguration *parent) const
{ {
LocalEnvironmentAspect *result = new LocalEnvironmentAspect(parent); auto result = new LocalEnvironmentAspect(parent, m_baseEnvironmentModifier);
result->setUserEnvironmentChanges(userEnvironmentChanges()); result->setUserEnvironmentChanges(userEnvironmentChanges());
return result; return result;
} }

View File

@@ -35,7 +35,8 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect
Q_OBJECT Q_OBJECT
public: public:
LocalEnvironmentAspect(RunConfiguration *parent); typedef std::function<void(Utils::Environment &)> BaseEnvironmentModifier;
LocalEnvironmentAspect(RunConfiguration *parent, const BaseEnvironmentModifier &modifier);
LocalEnvironmentAspect *create(RunConfiguration *parent) const; LocalEnvironmentAspect *create(RunConfiguration *parent) const;
QList<int> possibleBaseEnvironments() const; QList<int> possibleBaseEnvironments() const;
@@ -51,6 +52,8 @@ private:
SystemEnvironmentBase, SystemEnvironmentBase,
BuildEnvironmentBase BuildEnvironmentBase
}; };
BaseEnvironmentModifier m_baseEnvironmentModifier;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -14,7 +14,7 @@ HEADERS += projectexplorer.h \
environmentaspectwidget.h \ environmentaspectwidget.h \
gcctoolchain.h \ gcctoolchain.h \
importwidget.h \ importwidget.h \
localapplicationrunconfiguration.h \ runnables.h \
localenvironmentaspect.h \ localenvironmentaspect.h \
osparser.h \ osparser.h \
projectexplorer_export.h \ projectexplorer_export.h \
@@ -167,7 +167,6 @@ SOURCES += projectexplorer.cpp \
environmentaspectwidget.cpp \ environmentaspectwidget.cpp \
gcctoolchain.cpp \ gcctoolchain.cpp \
importwidget.cpp \ importwidget.cpp \
localapplicationrunconfiguration.cpp \
localenvironmentaspect.cpp \ localenvironmentaspect.cpp \
osparser.cpp \ osparser.cpp \
projectimporter.cpp \ projectimporter.cpp \

View File

@@ -94,7 +94,6 @@ QtcPlugin {
"kitoptionspage.cpp", "kitoptionspage.h", "kitoptionspage.cpp", "kitoptionspage.h",
"ldparser.cpp", "ldparser.h", "ldparser.cpp", "ldparser.h",
"linuxiccparser.cpp", "linuxiccparser.h", "linuxiccparser.cpp", "linuxiccparser.h",
"localapplicationrunconfiguration.cpp", "localapplicationrunconfiguration.h",
"localapplicationruncontrol.cpp", "localapplicationruncontrol.h", "localapplicationruncontrol.cpp", "localapplicationruncontrol.h",
"localenvironmentaspect.cpp", "localenvironmentaspect.h", "localenvironmentaspect.cpp", "localenvironmentaspect.h",
"metatypedeclarations.h", "metatypedeclarations.h",
@@ -127,6 +126,7 @@ QtcPlugin {
"projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui", "projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui",
"propertiespanel.cpp", "propertiespanel.h", "propertiespanel.cpp", "propertiespanel.h",
"removetaskhandler.cpp", "removetaskhandler.h", "removetaskhandler.cpp", "removetaskhandler.h",
"runnables.h",
"runconfiguration.cpp", "runconfiguration.h", "runconfiguration.cpp", "runconfiguration.h",
"runconfigurationaspects.cpp", "runconfigurationaspects.h", "runconfigurationaspects.cpp", "runconfigurationaspects.h",
"runconfigurationmodel.cpp", "runconfigurationmodel.h", "runconfigurationmodel.cpp", "runconfigurationmodel.h",

View File

@@ -23,32 +23,28 @@
** **
****************************************************************************/ ****************************************************************************/
#include "localapplicationrunconfiguration.h" #ifndef PROJECTEXPLORER_RUNNABLES_H
#define PROJECTEXPLORER_RUNNABLES_H
#include "buildconfiguration.h" #include "runconfiguration.h"
#include <utils/macroexpander.h> #include "applicationlauncher.h"
#include "devicesupport/idevice.h"
#include <projectexplorer/target.h> #include <utils/environment.h>
#include <projectexplorer/project.h>
#include <QDir>
namespace ProjectExplorer { namespace ProjectExplorer {
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, Core::Id id) : class PROJECTEXPLORER_EXPORT StandardRunnable
RunConfiguration(target, id)
{ {
} public:
QString executable;
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) : QString commandLineArguments;
RunConfiguration(target, rc) QString workingDirectory;
{ Utils::Environment environment;
} ApplicationLauncher::Mode runMode;
};
void LocalApplicationRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
{
Q_UNUSED(env);
}
} // namespace ProjectExplorer } // namespace ProjectExplorer
#endif // PROJECTEXPLORER_RUNNABLES_H

View File

@@ -419,7 +419,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *parent, Core::Id id) :
const QString exec = sysEnv.searchInPath(QLatin1String("python")).toString(); const QString exec = sysEnv.searchInPath(QLatin1String("python")).toString();
m_interpreter = exec.isEmpty() ? QLatin1String("python") : exec; m_interpreter = exec.isEmpty() ? QLatin1String("python") : exec;
addExtraAspect(new LocalEnvironmentAspect(this)); addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("PythonEditor.RunConfiguration.Arguments"))); addExtraAspect(new ArgumentsAspect(this, QStringLiteral("PythonEditor.RunConfiguration.Arguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("PythonEditor.RunConfiguration.UseTerminal"))); addExtraAspect(new TerminalAspect(this, QStringLiteral("PythonEditor.RunConfiguration.UseTerminal")));
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());

View File

@@ -61,6 +61,7 @@
#include <QDir> #include <QDir>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace QbsProjectManager { namespace QbsProjectManager {
namespace Internal { namespace Internal {
@@ -106,12 +107,12 @@ const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &u
// -------------------------------------------------------------------- // --------------------------------------------------------------------
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) : QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
LocalApplicationRunConfiguration(parent, id), RunConfiguration(parent, id),
m_uniqueProductName(uniqueProductNameFromId(id)), m_uniqueProductName(uniqueProductNameFromId(id)),
m_currentInstallStep(0), m_currentInstallStep(0),
m_currentBuildStepList(0) m_currentBuildStepList(0)
{ {
addExtraAspect(new LocalEnvironmentAspect(this)); addExtraAspect(new LocalEnvironmentAspect(this, [this](Environment &env) { addToBaseEnvironment(env); }));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments"))); addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory"))); addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
@@ -123,7 +124,7 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
} }
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) : QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source), RunConfiguration(parent, source),
m_uniqueProductName(source->m_uniqueProductName), m_uniqueProductName(source->m_uniqueProductName),
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway. m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
m_currentBuildStepList(0) // ditto m_currentBuildStepList(0) // ditto
@@ -226,6 +227,17 @@ void QbsRunConfiguration::installStepToBeRemoved(int pos)
m_currentInstallStep = 0; m_currentInstallStep = 0;
} }
Runnable QbsRunConfiguration::runnable() const
{
StandardRunnable r;
r.executable = executable();
r.workingDirectory = extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments();
r.runMode = extraAspect<TerminalAspect>()->runMode();
r.environment = extraAspect<LocalEnvironmentAspect>()->environment();
return r;
}
QString QbsRunConfiguration::executable() const QString QbsRunConfiguration::executable() const
{ {
QbsProject *pro = static_cast<QbsProject *>(target()->project()); QbsProject *pro = static_cast<QbsProject *>(target()->project());
@@ -237,11 +249,6 @@ QString QbsRunConfiguration::executable() const
return pro->qbsProject().targetExecutable(product, installOptions()); return pro->qbsProject().targetExecutable(product, installOptions());
} }
ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
{
return extraAspect<TerminalAspect>()->runMode();
}
bool QbsRunConfiguration::isConsoleApplication() const bool QbsRunConfiguration::isConsoleApplication() const
{ {
QbsProject *pro = static_cast<QbsProject *>(target()->project()); QbsProject *pro = static_cast<QbsProject *>(target()->project());
@@ -249,13 +256,6 @@ bool QbsRunConfiguration::isConsoleApplication() const
return product.properties().value(QLatin1String("consoleApplication"), false).toBool(); return product.properties().value(QLatin1String("consoleApplication"), false).toBool();
} }
QString QbsRunConfiguration::workingDirectory() const
{
const auto *wdAspect = extraAspect<WorkingDirectoryAspect>();
QTC_ASSERT(wdAspect, return baseWorkingDirectory());
return wdAspect->workingDirectory().toString();
}
QString QbsRunConfiguration::baseWorkingDirectory() const QString QbsRunConfiguration::baseWorkingDirectory() const
{ {
const QString exe = executable(); const QString exe = executable();
@@ -264,11 +264,6 @@ QString QbsRunConfiguration::baseWorkingDirectory() const
return QString(); return QString();
} }
QString QbsRunConfiguration::commandLineArguments() const
{
return extraAspect<ArgumentsAspect>()->arguments();
}
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
{ {
QbsProject *project = static_cast<QbsProject *>(target()->project()); QbsProject *project = static_cast<QbsProject *>(target()->project());

View File

@@ -26,7 +26,7 @@
#ifndef QBSRUNCONFIGURATION_H #ifndef QBSRUNCONFIGURATION_H
#define QBSRUNCONFIGURATION_H #define QBSRUNCONFIGURATION_H
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <QStringList> #include <QStringList>
#include <QLabel> #include <QLabel>
@@ -54,7 +54,7 @@ namespace Internal {
class QbsInstallStep; class QbsInstallStep;
class QbsRunConfigurationFactory; class QbsRunConfigurationFactory;
class QbsRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration class QbsRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
@@ -69,14 +69,12 @@ public:
QString disabledReason() const override; QString disabledReason() const override;
QWidget *createConfigurationWidget() override; QWidget *createConfigurationWidget() override;
QString executable() const override; ProjectExplorer::Runnable runnable() const override;
ProjectExplorer::ApplicationLauncher::Mode runMode() const override;
QString workingDirectory() const override;
QString commandLineArguments() const override;
QString executable() const;
Utils::OutputFormatter *createOutputFormatter() const override; Utils::OutputFormatter *createOutputFormatter() const override;
void addToBaseEnvironment(Utils::Environment &env) const override; void addToBaseEnvironment(Utils::Environment &env) const;
QString uniqueProductName() const; QString uniqueProductName() const;
bool isConsoleApplication() const; bool isConsoleApplication() const;

View File

@@ -76,10 +76,10 @@ static Utils::FileName pathFromId(Core::Id id)
// //
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core::Id id) : DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core::Id id) :
LocalApplicationRunConfiguration(parent, id), RunConfiguration(parent, id),
m_proFilePath(pathFromId(id)) m_proFilePath(pathFromId(id))
{ {
addExtraAspect(new LocalEnvironmentAspect(this)); addExtraAspect(new LocalEnvironmentAspect(this, [this](Environment &env) { addToBaseEnvironment(env); }));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"))); addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"))); addExtraAspect(new TerminalAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal")));
addExtraAspect(new WorkingDirectoryAspect(this, addExtraAspect(new WorkingDirectoryAspect(this,
@@ -92,7 +92,7 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core:
} }
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, DesktopQmakeRunConfiguration *source) : DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, DesktopQmakeRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source), RunConfiguration(parent, source),
m_proFilePath(source->m_proFilePath), m_proFilePath(source->m_proFilePath),
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix), m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath), m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath),
@@ -200,7 +200,8 @@ DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQm
m_useQvfbCheck = new QCheckBox(tr("Run on QVFb"), this); m_useQvfbCheck = new QCheckBox(tr("Run on QVFb"), this);
m_useQvfbCheck->setToolTip(tr("Check this option to run the application on a Qt Virtual Framebuffer.")); m_useQvfbCheck->setToolTip(tr("Check this option to run the application on a Qt Virtual Framebuffer."));
m_useQvfbCheck->setChecked(m_qmakeRunConfiguration->runMode() == ApplicationLauncher::Console); m_useQvfbCheck->setChecked(m_qmakeRunConfiguration->runnable().as<StandardRunnable>().runMode
== ApplicationLauncher::Console);
m_useQvfbCheck->setVisible(false); m_useQvfbCheck->setVisible(false);
auto innerBox = new QHBoxLayout(); auto innerBox = new QHBoxLayout();
innerBox->addWidget(m_useQvfbCheck); innerBox->addWidget(m_useQvfbCheck);
@@ -301,10 +302,21 @@ QWidget *DesktopQmakeRunConfiguration::createConfigurationWidget()
return new DesktopQmakeRunConfigurationWidget(this); return new DesktopQmakeRunConfigurationWidget(this);
} }
Runnable DesktopQmakeRunConfiguration::runnable() const
{
StandardRunnable r;
r.executable = executable();
r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments();
r.workingDirectory = extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
r.environment = extraAspect<LocalEnvironmentAspect>()->environment();
r.runMode = extraAspect<TerminalAspect>()->runMode();
return r;
}
QVariantMap DesktopQmakeRunConfiguration::toMap() const QVariantMap DesktopQmakeRunConfiguration::toMap() const
{ {
const QDir projectDir = QDir(target()->project()->projectDirectory().toString()); const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
QVariantMap map(LocalApplicationRunConfiguration::toMap()); QVariantMap map(RunConfiguration::toMap());
map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath.toString())); map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath.toString()));
map.insert(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix); map.insert(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix);
map.insert(QLatin1String(USE_LIBRARY_SEARCH_PATH), m_isUsingLibrarySearchPath); map.insert(QLatin1String(USE_LIBRARY_SEARCH_PATH), m_isUsingLibrarySearchPath);
@@ -321,7 +333,7 @@ bool DesktopQmakeRunConfiguration::fromMap(const QVariantMap &map)
m_parseSuccess = qmakeProject()->validParse(m_proFilePath); m_parseSuccess = qmakeProject()->validParse(m_proFilePath);
m_parseInProgress = qmakeProject()->parseInProgress(m_proFilePath); m_parseInProgress = qmakeProject()->parseInProgress(m_proFilePath);
return LocalApplicationRunConfiguration::fromMap(map); return RunConfiguration::fromMap(map);
} }
QString DesktopQmakeRunConfiguration::executable() const QString DesktopQmakeRunConfiguration::executable() const
@@ -330,11 +342,6 @@ QString DesktopQmakeRunConfiguration::executable() const
return extractWorkingDirAndExecutable(node).second; return extractWorkingDirAndExecutable(node).second;
} }
ApplicationLauncher::Mode DesktopQmakeRunConfiguration::runMode() const
{
return extraAspect<TerminalAspect>()->runMode();
}
bool DesktopQmakeRunConfiguration::isUsingDyldImageSuffix() const bool DesktopQmakeRunConfiguration::isUsingDyldImageSuffix() const
{ {
return m_isUsingDyldImageSuffix; return m_isUsingDyldImageSuffix;
@@ -361,22 +368,12 @@ void DesktopQmakeRunConfiguration::setUsingLibrarySearchPath(bool state)
return extraAspect<LocalEnvironmentAspect>()->environmentChanged(); return extraAspect<LocalEnvironmentAspect>()->environmentChanged();
} }
QString DesktopQmakeRunConfiguration::workingDirectory() const
{
return extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
}
QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const
{ {
const QmakeProFileNode *node = qmakeProject()->rootProjectNode()->findProFileFor(m_proFilePath); const QmakeProFileNode *node = qmakeProject()->rootProjectNode()->findProFileFor(m_proFilePath);
return extractWorkingDirAndExecutable(node).first; return extractWorkingDirAndExecutable(node).first;
} }
QString DesktopQmakeRunConfiguration::commandLineArguments() const
{
return extraAspect<ArgumentsAspect>()->arguments();
}
void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
{ {
if (m_isUsingDyldImageSuffix) if (m_isUsingDyldImageSuffix)

View File

@@ -28,7 +28,7 @@
#include <qmakeprojectmanager/qmakerunconfigurationfactory.h> #include <qmakeprojectmanager/qmakerunconfigurationfactory.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
@@ -48,7 +48,7 @@ class QmakeProject;
namespace Internal { namespace Internal {
class DesktopQmakeRunConfigurationFactory; class DesktopQmakeRunConfigurationFactory;
class DesktopQmakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration class DesktopQmakeRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
// to change the display name and arguments and set the userenvironmentchanges // to change the display name and arguments and set the userenvironmentchanges
@@ -62,10 +62,8 @@ public:
QString disabledReason() const override; QString disabledReason() const override;
QWidget *createConfigurationWidget() override; QWidget *createConfigurationWidget() override;
QString executable() const override; ProjectExplorer::Runnable runnable() const override;
ProjectExplorer::ApplicationLauncher::Mode runMode() const override; QString executable() const;
QString workingDirectory() const override;
QString commandLineArguments() const override;
bool isUsingDyldImageSuffix() const; bool isUsingDyldImageSuffix() const;
void setUsingDyldImageSuffix(bool state); void setUsingDyldImageSuffix(bool state);
@@ -79,7 +77,7 @@ public:
Utils::OutputFormatter *createOutputFormatter() const override; Utils::OutputFormatter *createOutputFormatter() const override;
void addToBaseEnvironment(Utils::Environment &env) const override; void addToBaseEnvironment(Utils::Environment &env) const;
signals: signals:
void baseWorkingDirectoryChanged(const QString&); void baseWorkingDirectoryChanged(const QString&);

View File

@@ -28,7 +28,6 @@
#include "qmlprofilerruncontrol.h" #include "qmlprofilerruncontrol.h"
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/localapplicationrunconfiguration.h>
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>

View File

@@ -37,7 +37,7 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/localapplicationruncontrol.h> #include <projectexplorer/localapplicationruncontrol.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <qtsupport/qtsupportconstants.h> #include <qtsupport/qtsupportconstants.h>
#include <qmldebug/qmloutputparser.h> #include <qmldebug/qmloutputparser.h>

View File

@@ -36,7 +36,7 @@
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
@@ -52,6 +52,13 @@ using namespace ProjectExplorer;
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
static bool isLocal(RunConfiguration *runConfiguration)
{
Target *target = runConfiguration ? runConfiguration->target() : 0;
Kit *kit = target ? target->kit() : 0;
return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
}
QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) : QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
IRunControlFactory(parent) IRunControlFactory(parent)
{ {
@@ -59,22 +66,19 @@ QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) :
bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{ {
return mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE return mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && isLocal(runConfiguration);
&& (qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration));
} }
RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{ {
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
QTC_ASSERT(runConfiguration->runnable().is<StandardRunnable>(), return 0);
auto &rcRunnable = runConfiguration->runnable().as<StandardRunnable>();
AnalyzerRunnable runnable;
runnable.debuggee = rcRunnable.executable;
runnable.debuggeeArgs = rcRunnable.commandLineArguments;
Kit *kit = runConfiguration->target()->kit(); Kit *kit = runConfiguration->target()->kit();
// FIXME: This is only used to communicate the connParams settings.
auto localRunConfiguration = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(localRunConfiguration, return 0);
AnalyzerRunnable runnable;
runnable.debuggee = localRunConfiguration->executable();
runnable.debuggeeArgs = localRunConfiguration->commandLineArguments();
AnalyzerConnection connection; AnalyzerConnection connection;
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
if (version) { if (version) {

View File

@@ -49,7 +49,7 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>

View File

@@ -52,7 +52,7 @@ namespace QmlProjectManager {
const char M_CURRENT_FILE[] = "CurrentFile"; const char M_CURRENT_FILE[] = "CurrentFile";
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) : QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) :
LocalApplicationRunConfiguration(parent, id), RunConfiguration(parent, id),
m_scriptFile(QLatin1String(M_CURRENT_FILE)), m_scriptFile(QLatin1String(M_CURRENT_FILE)),
m_isEnabled(false) m_isEnabled(false)
{ {
@@ -61,9 +61,20 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) :
ctor(); ctor();
} }
Runnable QmlProjectRunConfiguration::runnable() const
{
StandardRunnable r;
r.executable = executable();
r.commandLineArguments = commandLineArguments();
r.runMode = ApplicationLauncher::Gui;
r.workingDirectory = canonicalCapsPath(target()->project()->projectFilePath()
.toFileInfo().absolutePath());
return r;
}
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent,
QmlProjectRunConfiguration *source) : QmlProjectRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source), RunConfiguration(parent, source),
m_currentFileFilename(source->m_currentFileFilename), m_currentFileFilename(source->m_currentFileFilename),
m_mainScriptFilename(source->m_mainScriptFilename), m_mainScriptFilename(source->m_mainScriptFilename),
m_scriptFile(source->m_scriptFile), m_scriptFile(source->m_scriptFile),
@@ -114,11 +125,6 @@ QString QmlProjectRunConfiguration::executable() const
return version->qmlviewerCommand(); return version->qmlviewerCommand();
} }
ApplicationLauncher::Mode QmlProjectRunConfiguration::runMode() const
{
return ApplicationLauncher::Gui;
}
QString QmlProjectRunConfiguration::commandLineArguments() const QString QmlProjectRunConfiguration::commandLineArguments() const
{ {
// arguments in .user file // arguments in .user file
@@ -139,11 +145,6 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
return args; return args;
} }
QString QmlProjectRunConfiguration::workingDirectory() const
{
return canonicalCapsPath(target()->project()->projectFilePath().toFileInfo().absolutePath());
}
/* QtDeclarative checks explicitly that the capitalization for any URL / path /* QtDeclarative checks explicitly that the capitalization for any URL / path
is exactly like the capitalization on disk.*/ is exactly like the capitalization on disk.*/
QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName) QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName)

View File

@@ -28,7 +28,7 @@
#include "qmlprojectmanager_global.h" #include "qmlprojectmanager_global.h"
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <QPointer> #include <QPointer>
@@ -46,7 +46,7 @@ namespace Internal {
class QmlProjectRunConfigurationWidget; class QmlProjectRunConfigurationWidget;
} }
class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
friend class Internal::QmlProjectRunConfigurationFactory; friend class Internal::QmlProjectRunConfigurationFactory;
@@ -56,11 +56,8 @@ class QMLPROJECTMANAGER_EXPORT QmlProjectRunConfiguration : public ProjectExplor
public: public:
QmlProjectRunConfiguration(ProjectExplorer::Target *parent, Core::Id id); QmlProjectRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
QString executable() const override; ProjectExplorer::Runnable runnable() const override;
ProjectExplorer::ApplicationLauncher::Mode runMode() const override;
QString commandLineArguments() const override;
QString workingDirectory() const override;
QtSupport::BaseQtVersion *qtVersion() const; QtSupport::BaseQtVersion *qtVersion() const;
enum MainScriptSource { enum MainScriptSource {
@@ -96,6 +93,10 @@ protected:
private: private:
void ctor(); void ctor();
QString executable() const;
QString commandLineArguments() const;
static bool isValidVersion(QtSupport::BaseQtVersion *version); static bool isValidVersion(QtSupport::BaseQtVersion *version);
static QString canonicalCapsPath(const QString &filePath); static QString canonicalCapsPath(const QString &filePath);

View File

@@ -64,21 +64,22 @@ void CustomExecutableRunConfiguration::ctor()
} }
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent) : CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent) :
LocalApplicationRunConfiguration(parent, Core::Id(CUSTOM_EXECUTABLE_ID)), RunConfiguration(parent, CUSTOM_EXECUTABLE_ID),
m_workingDirectory(QLatin1String(Constants::DEFAULT_WORKING_DIR)),
m_dialog(0) m_dialog(0)
{ {
addExtraAspect(new LocalEnvironmentAspect(this)); addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()));
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.Arguments"))); addExtraAspect(new ArgumentsAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.Arguments")));
addExtraAspect(new TerminalAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"))); addExtraAspect(new TerminalAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal")));
if (!parent->activeBuildConfiguration()) if (parent->activeBuildConfiguration())
m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR);
else
m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR_ALTERNATE); m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR_ALTERNATE);
ctor(); ctor();
} }
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent, CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent,
CustomExecutableRunConfiguration *source) : CustomExecutableRunConfiguration *source) :
LocalApplicationRunConfiguration(parent, source), RunConfiguration(parent, source),
m_executable(source->m_executable), m_executable(source->m_executable),
m_workingDirectory(source->m_workingDirectory), m_workingDirectory(source->m_workingDirectory),
m_dialog(0) m_dialog(0)
@@ -236,11 +237,6 @@ bool CustomExecutableRunConfiguration::isConfigured() const
return !m_executable.isEmpty(); return !m_executable.isEmpty();
} }
ApplicationLauncher::Mode CustomExecutableRunConfiguration::runMode() const
{
return extraAspect<TerminalAspect>()->runMode();
}
QString CustomExecutableRunConfiguration::workingDirectory() const QString CustomExecutableRunConfiguration::workingDirectory() const
{ {
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
@@ -249,17 +245,22 @@ QString CustomExecutableRunConfiguration::workingDirectory() const
macroExpander()->expand(baseWorkingDirectory()))); macroExpander()->expand(baseWorkingDirectory())));
} }
Runnable CustomExecutableRunConfiguration::runnable() const
{
StandardRunnable r;
r.executable = executable();
r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments();
r.workingDirectory = workingDirectory();
r.environment = extraAspect<LocalEnvironmentAspect>()->environment();
r.runMode = extraAspect<TerminalAspect>()->runMode();
return r;
}
QString CustomExecutableRunConfiguration::baseWorkingDirectory() const QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
{ {
return m_workingDirectory; return m_workingDirectory;
} }
QString CustomExecutableRunConfiguration::commandLineArguments() const
{
return extraAspect<ArgumentsAspect>()->arguments();
}
QString CustomExecutableRunConfiguration::defaultDisplayName() const QString CustomExecutableRunConfiguration::defaultDisplayName() const
{ {
if (m_executable.isEmpty()) if (m_executable.isEmpty())
@@ -270,7 +271,7 @@ QString CustomExecutableRunConfiguration::defaultDisplayName() const
QVariantMap CustomExecutableRunConfiguration::toMap() const QVariantMap CustomExecutableRunConfiguration::toMap() const
{ {
QVariantMap map(LocalApplicationRunConfiguration::toMap()); QVariantMap map(RunConfiguration::toMap());
map.insert(QLatin1String(EXECUTABLE_KEY), m_executable); map.insert(QLatin1String(EXECUTABLE_KEY), m_executable);
map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory); map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory);
return map; return map;
@@ -282,7 +283,7 @@ bool CustomExecutableRunConfiguration::fromMap(const QVariantMap &map)
m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString(); m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString();
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
return LocalApplicationRunConfiguration::fromMap(map); return RunConfiguration::fromMap(map);
} }
void CustomExecutableRunConfiguration::setExecutable(const QString &executable) void CustomExecutableRunConfiguration::setExecutable(const QString &executable)

View File

@@ -28,7 +28,7 @@
#include "qtsupport_global.h" #include "qtsupport_global.h"
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <QVariantMap> #include <QVariantMap>
@@ -39,7 +39,7 @@ namespace Internal { class CustomExecutableConfigurationWidget; }
class CustomExecutableRunConfigurationFactory; class CustomExecutableRunConfigurationFactory;
class QTSUPPORT_EXPORT CustomExecutableRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration class QTSUPPORT_EXPORT CustomExecutableRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
// the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments // the configuration widget needs to setExecutable setWorkingDirectory and setCommandLineArguments
@@ -54,16 +54,14 @@ public:
* Returns the executable, looks in the environment for it and might even * Returns the executable, looks in the environment for it and might even
* ask the user if none is specified * ask the user if none is specified
*/ */
QString executable() const override; QString executable() const;
QString workingDirectory() const;
ProjectExplorer::Runnable runnable() const override;
/** Returns whether this runconfiguration ever was configured with an executable /** Returns whether this runconfiguration ever was configured with an executable
*/ */
bool isConfigured() const override; bool isConfigured() const override;
ProjectExplorer::ApplicationLauncher::Mode runMode() const override;
QString workingDirectory() const override;
QString commandLineArguments() const override;
QWidget *createConfigurationWidget() override; QWidget *createConfigurationWidget() override;
ProjectExplorer::Abi abi() const override; ProjectExplorer::Abi abi() const override;

View File

@@ -41,7 +41,7 @@
#include <debugger/debuggerrunconfigurationaspect.h> #include <debugger/debuggerrunconfigurationaspect.h>
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/localapplicationrunconfiguration.h> #include <projectexplorer/runnables.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -75,21 +75,19 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
QTC_ASSERT(runControl, return 0); QTC_ASSERT(runControl, return 0);
ApplicationLauncher::Mode localRunMode = ApplicationLauncher::Gui; ApplicationLauncher::Mode localRunMode = ApplicationLauncher::Gui;
IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
Utils::Environment environment; Utils::Environment environment;
AnalyzerRunnable runnable; AnalyzerRunnable runnable;
AnalyzerConnection connection; AnalyzerConnection connection;
QString workingDirectory; QString workingDirectory;
if (auto rc1 = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) { Runnable rcRunnable = runConfiguration->runnable();
EnvironmentAspect *aspect = runConfiguration->extraAspect<EnvironmentAspect>(); if (rcRunnable.is<StandardRunnable>()
if (aspect) && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
environment = aspect->environment(); auto stdRunnable = runConfiguration->runnable().as<StandardRunnable>();
workingDirectory = rc1->workingDirectory(); environment = stdRunnable.environment;
runnable.debuggee = rc1->executable(); workingDirectory = stdRunnable.workingDirectory;
runnable.debuggeeArgs = rc1->commandLineArguments(); runnable.debuggee = stdRunnable.executable;
const IDevice::ConstPtr device = runnable.debuggeeArgs = stdRunnable.commandLineArguments;
DeviceKitInformation::device(runConfiguration->target()->kit());
QTC_ASSERT(device, return 0);
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
QTcpServer server; QTcpServer server;
if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) { if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
qWarning() << "Cannot open port on host for profiling."; qWarning() << "Cannot open port on host for profiling.";
@@ -97,11 +95,11 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
} }
connection.connParams.host = server.serverAddress().toString(); connection.connParams.host = server.serverAddress().toString();
connection.connParams.port = server.serverPort(); connection.connParams.port = server.serverPort();
localRunMode = rc1->runMode(); localRunMode = stdRunnable.runMode;
} else if (auto rc2 = qobject_cast<RemoteLinux::AbstractRemoteLinuxRunConfiguration *>(runConfiguration)) { } else if (auto rc2 = qobject_cast<RemoteLinux::AbstractRemoteLinuxRunConfiguration *>(runConfiguration)) {
runnable.debuggee = rc2->remoteExecutableFilePath(); runnable.debuggee = rc2->remoteExecutableFilePath();
runnable.debuggeeArgs = rc2->arguments(); runnable.debuggeeArgs = rc2->arguments();
connection.connParams = DeviceKitInformation::device(rc2->target()->kit())->sshParameters(); connection.connParams = device->sshParameters();
} else { } else {
QTC_ASSERT(false, return 0); QTC_ASSERT(false, return 0);
} }