Commit 9ae2ce76 authored by hjk's avatar hjk

ProjectExplorer: Drop LocalApplicationRunConfiguration

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

Change-Id: I7b8e8fe33fffd2b00176b6cf6633eca4e152e466
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 4ea8cacc
...@@ -30,8 +30,9 @@ ...@@ -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 * ...@@ -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() ...@@ -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;
}
} }
} }
......
...@@ -61,11 +61,11 @@ const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title"; ...@@ -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 ...@@ -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() ...@@ -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) ...@@ -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;
} }
......
...@@ -26,24 +26,13 @@ ...@@ -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: ...@@ -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);
......
...@@ -87,7 +87,6 @@ ...@@ -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 @@ ...@@ -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>
......
...@@ -40,9 +40,9 @@ ...@@ -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 ...@@ -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: ...@@ -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
......
...@@ -38,7 +38,7 @@ ...@@ -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; ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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();
} }
......
/****************************************************************************
**
** 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
...@@ -24,11 +24,14 @@ ...@@ -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 @@ ...@@ -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;
} }
......
...@@ -36,8 +36,6 @@ class LocalApplicationRunControlFactory : public IRunControlFactory ...@@ -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);
}; };
......
...@@ -27,7 +27,7 @@ ...@@ -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 ...@@ -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() ...@@ -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;
} }
......
...@@ -35,7 +35,8 @@ class PROJECTEXPLORER_EXPORT LocalEnvironmentAspect : public EnvironmentAspect ...@@ -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: ...@@ -51,6 +52,8 @@ private:
SystemEnvironmentBase, SystemEnvironmentBase,
BuildEnvironmentBase BuildEnvironmentBase
}; };