2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "runconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "project.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
#include "toolchain.h"
|
2011-08-18 13:46:52 +02:00
|
|
|
#include "abi.h"
|
2009-10-28 17:21:27 +01:00
|
|
|
#include "buildconfiguration.h"
|
2017-01-25 16:18:30 +01:00
|
|
|
#include "environmentaspect.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitinformation.h"
|
2017-03-10 09:05:52 +01:00
|
|
|
#include "runnables.h"
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
|
2017-01-05 12:49:45 +01:00
|
|
|
#include <utils/algorithm.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2017-03-10 09:05:52 +01:00
|
|
|
#include <utils/outputformatter.h>
|
2017-02-27 17:25:58 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2017-03-10 09:05:52 +01:00
|
|
|
#include <utils/utilsicons.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2013-03-26 11:32:14 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2017-03-10 09:05:52 +01:00
|
|
|
#include <QDir>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2017-03-10 09:05:52 +01:00
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-02-01 12:15:44 +01:00
|
|
|
#ifdef Q_OS_OSX
|
2012-02-23 17:40:48 +01:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
2017-02-27 11:49:00 +01:00
|
|
|
#if defined (WITH_JOURNALD)
|
|
|
|
|
#include "journaldwatcher.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-01-16 15:53:53 +01:00
|
|
|
using namespace Utils;
|
2017-03-29 14:08:44 +02:00
|
|
|
using namespace ProjectExplorer::Internal;
|
2011-07-06 10:25:18 +02:00
|
|
|
|
2017-01-16 15:53:53 +01:00
|
|
|
namespace ProjectExplorer {
|
2011-07-06 10:25:18 +02:00
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ISettingsAspect
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
ISettingsAspect *ISettingsAspect::clone() const
|
|
|
|
|
{
|
|
|
|
|
ISettingsAspect *other = create();
|
|
|
|
|
QVariantMap data;
|
|
|
|
|
toMap(data);
|
|
|
|
|
other->fromMap(data);
|
|
|
|
|
return other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// IRunConfigurationAspect
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
IRunConfigurationAspect::IRunConfigurationAspect(RunConfiguration *runConfig) :
|
|
|
|
|
m_runConfiguration(runConfig)
|
|
|
|
|
{ }
|
2013-08-12 17:04:10 +02:00
|
|
|
|
|
|
|
|
IRunConfigurationAspect::~IRunConfigurationAspect()
|
|
|
|
|
{
|
|
|
|
|
delete m_projectSettings;
|
|
|
|
|
}
|
2012-02-17 19:05:11 +01:00
|
|
|
|
2013-06-05 08:43:52 +03:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns the widget used to configure this run configuration. Ownership is
|
|
|
|
|
transferred to the caller.
|
2013-06-05 08:43:52 +03:00
|
|
|
*/
|
2013-08-12 17:04:10 +02:00
|
|
|
|
2016-04-21 19:07:07 +02:00
|
|
|
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget() const
|
2013-03-27 17:17:24 +01:00
|
|
|
{
|
2016-04-21 19:07:07 +02:00
|
|
|
return m_runConfigWidgetCreator ? m_runConfigWidgetCreator() : nullptr;
|
2013-03-27 17:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
void IRunConfigurationAspect::setProjectSettings(ISettingsAspect *settings)
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::setGlobalSettings(ISettingsAspect *settings)
|
|
|
|
|
{
|
|
|
|
|
m_globalSettings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::setUsingGlobalSettings(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_useGlobalSettings = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ISettingsAspect *IRunConfigurationAspect::currentSettings() const
|
|
|
|
|
{
|
|
|
|
|
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings->fromMap(map);
|
|
|
|
|
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::toMap(QVariantMap &map) const
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings->toMap(map);
|
|
|
|
|
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-21 19:07:07 +02:00
|
|
|
void IRunConfigurationAspect::setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator)
|
|
|
|
|
{
|
|
|
|
|
m_runConfigWidgetCreator = runConfigWidgetCreator;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-12 16:41:29 +01:00
|
|
|
IRunConfigurationAspect *IRunConfigurationAspect::clone(RunConfiguration *runConfig) const
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
2014-12-12 16:41:29 +01:00
|
|
|
IRunConfigurationAspect *other = create(runConfig);
|
2013-08-24 23:39:47 +03:00
|
|
|
if (m_projectSettings)
|
|
|
|
|
other->m_projectSettings = m_projectSettings->clone();
|
2013-08-12 17:04:10 +02:00
|
|
|
other->m_globalSettings = m_globalSettings;
|
|
|
|
|
other->m_useGlobalSettings = m_useGlobalSettings;
|
|
|
|
|
return other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_globalSettings, return);
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
m_globalSettings->toMap(map);
|
|
|
|
|
m_projectSettings->fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 17:17:24 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunConfiguration
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The RunConfiguration class is the base class for a run configuration.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
A run configuration specifies how a target should be run, while a runner
|
|
|
|
|
does the actual running.
|
|
|
|
|
|
|
|
|
|
All RunControls and the target hold a shared pointer to the run
|
|
|
|
|
configuration. That is, the lifetime of the run configuration might exceed
|
|
|
|
|
the life of the target.
|
2011-04-14 12:58:14 +02:00
|
|
|
The user might still have a RunControl running (or output tab of that RunControl open)
|
|
|
|
|
and yet unloaded the target.
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
Also, a run configuration might be already removed from the list of run
|
|
|
|
|
configurations
|
2011-04-14 12:58:14 +02:00
|
|
|
for a target, but still be runnable via the output tab.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
2017-01-05 12:49:45 +01:00
|
|
|
ProjectConfiguration(target, id)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2013-03-27 13:03:15 +01:00
|
|
|
ctor();
|
2017-01-05 12:49:45 +01:00
|
|
|
|
|
|
|
|
addExtraAspects();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
2017-01-05 12:49:45 +01:00
|
|
|
ProjectConfiguration(target, source)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2013-03-27 13:03:15 +01:00
|
|
|
ctor();
|
2012-09-20 14:42:57 +02:00
|
|
|
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
|
2013-03-22 15:18:52 +01:00
|
|
|
IRunConfigurationAspect *clone = aspect->clone(this);
|
|
|
|
|
if (clone)
|
|
|
|
|
m_aspects.append(clone);
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration::~RunConfiguration()
|
|
|
|
|
{
|
2011-02-28 12:23:12 +01:00
|
|
|
qDeleteAll(m_aspects);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfiguration::addExtraAspects()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
|
2013-04-05 17:27:45 +02:00
|
|
|
addExtraAspect(factory->createRunConfigurationAspect(this));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-05 17:27:45 +02:00
|
|
|
void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
|
|
|
|
{
|
|
|
|
|
if (aspect)
|
|
|
|
|
m_aspects += aspect;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 13:03:15 +01:00
|
|
|
void RunConfiguration::ctor()
|
|
|
|
|
{
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(this, &RunConfiguration::enabledChanged,
|
|
|
|
|
this, &RunConfiguration::requestRunActionsUpdate);
|
2014-11-05 14:01:26 +01:00
|
|
|
|
2014-11-05 15:45:56 +01:00
|
|
|
Utils::MacroExpander *expander = macroExpander();
|
|
|
|
|
expander->setDisplayName(tr("Run Settings"));
|
|
|
|
|
expander->setAccumulating(true);
|
|
|
|
|
expander->registerSubProvider([this]() -> Utils::MacroExpander * {
|
|
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
return bc ? bc->macroExpander() : target()->macroExpander();
|
|
|
|
|
});
|
2017-03-17 15:33:07 +02:00
|
|
|
expander->registerPrefix("CurrentRun:Env", tr("Variables in the current run environment"),
|
2017-01-25 16:18:30 +01:00
|
|
|
[this](const QString &var) {
|
|
|
|
|
const auto envAspect = extraAspect<EnvironmentAspect>();
|
|
|
|
|
return envAspect ? envAspect->environment().value(var) : QString();
|
|
|
|
|
});
|
2016-03-31 17:09:56 +03:00
|
|
|
expander->registerVariable(Constants::VAR_CURRENTRUN_NAME,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer", "The currently active run configuration's name."),
|
|
|
|
|
[this] { return displayName(); }, false);
|
2013-03-27 13:03:15 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Checks whether a run configuration is enabled.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-05-26 15:33:24 +02:00
|
|
|
bool RunConfiguration::isEnabled() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
QString RunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool RunConfiguration::isConfigured() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 17:31:49 +02:00
|
|
|
RunConfiguration::ConfigurationState RunConfiguration::ensureConfigured(QString *errorMessage)
|
2012-09-13 11:27:15 +02:00
|
|
|
{
|
|
|
|
|
if (isConfigured())
|
2014-07-30 17:31:49 +02:00
|
|
|
return Configured;
|
2012-09-13 11:27:15 +02:00
|
|
|
if (errorMessage)
|
|
|
|
|
*errorMessage = tr("Unknown error.");
|
2014-07-30 17:31:49 +02:00
|
|
|
return UnConfigured;
|
2012-09-13 11:27:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
BuildConfiguration *RunConfiguration::activeBuildConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!target())
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2010-02-08 15:50:06 +01:00
|
|
|
return target()->activeBuildConfiguration();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *RunConfiguration::target() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Target *>(parent());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
QVariantMap RunConfiguration::toMap() const
|
|
|
|
|
{
|
2012-02-22 11:56:08 +01:00
|
|
|
QVariantMap map = ProjectConfiguration::toMap();
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
2013-08-12 17:05:52 +02:00
|
|
|
aspect->toMap(map);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:59:04 +02:00
|
|
|
Abi RunConfiguration::abi() const
|
2011-02-01 18:36:00 +01:00
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
return Abi::hostAbi();
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), Constants::CXX_LANGUAGE_ID);
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!tc)
|
|
|
|
|
return Abi::hostAbi();
|
|
|
|
|
return tc->targetAbi();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
bool RunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
2012-02-22 12:36:39 +01:00
|
|
|
aspect->fromMap(map);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return ProjectConfiguration::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunConfigurationAspect class provides an additional
|
|
|
|
|
configuration aspect.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Aspects are a mechanism to add RunControl-specific options to a run
|
|
|
|
|
configuration without subclassing the run configuration for every addition.
|
|
|
|
|
This prevents a combinatorial explosion of subclasses and eliminates
|
|
|
|
|
the need to add all options to the base class.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns extra aspects.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
\sa ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
|
|
|
|
{
|
|
|
|
|
return m_aspects;
|
|
|
|
|
}
|
2017-01-05 12:49:45 +01:00
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const
|
|
|
|
|
{
|
2017-01-05 12:49:45 +01:00
|
|
|
return Utils::findOrDefault(m_aspects, Utils::equal(&IRunConfigurationAspect::id, id));
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2016-01-20 14:50:34 +01:00
|
|
|
/*!
|
|
|
|
|
\internal
|
|
|
|
|
|
|
|
|
|
\class ProjectExplorer::Runnable
|
|
|
|
|
|
|
|
|
|
\brief The ProjectExplorer::Runnable class wraps information needed
|
|
|
|
|
to execute a process on a target device.
|
|
|
|
|
|
|
|
|
|
A target specific \l RunConfiguration implementation can specify
|
|
|
|
|
what information it considers necessary to execute a process
|
|
|
|
|
on the target. Target specific) \n IRunControlFactory implementation
|
|
|
|
|
can use that information either unmodified or tweak it or ignore
|
|
|
|
|
it when setting up a RunControl.
|
|
|
|
|
|
|
|
|
|
From Qt Creator's core perspective a Runnable object is opaque.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\internal
|
|
|
|
|
|
|
|
|
|
\brief Returns a \l Runnable described by this RunConfiguration.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Runnable RunConfiguration::runnable() const
|
|
|
|
|
{
|
|
|
|
|
return Runnable();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
Utils::OutputFormatter *RunConfiguration::createOutputFormatter() const
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
2011-04-15 12:59:44 +02:00
|
|
|
return new Utils::OutputFormatter();
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationFactory
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunConfigurationFactory class restores run configurations from
|
|
|
|
|
settings.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
The run configuration factory is used for restoring run configurations from
|
2013-09-10 17:16:10 +02:00
|
|
|
settings and for creating new run configurations in the \gui {Run Settings}
|
|
|
|
|
dialog.
|
|
|
|
|
To restore run configurations, use the
|
|
|
|
|
\c {bool canRestore(Target *parent, const QString &id)}
|
|
|
|
|
and \c {RunConfiguration* create(Target *parent, const QString &id)}
|
|
|
|
|
functions.
|
|
|
|
|
|
|
|
|
|
To generate a list of creatable run configurations, use the
|
|
|
|
|
\c {QStringList availableCreationIds(Target *parent)} and
|
|
|
|
|
\c {QString displayNameForType(const QString&)} functions. To create a
|
|
|
|
|
run configuration, use \c create().
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QStringList ProjectExplorer::IRunConfigurationFactory::availableCreationIds(Target *parent) const
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Shows the list of possible additions to a target. Returns a list of types.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-07-01 11:08:26 +02:00
|
|
|
\fn QString ProjectExplorer::IRunConfigurationFactory::displayNameForId(Core::Id id) const
|
2013-09-10 17:16:10 +02:00
|
|
|
Translates the types to names to display to the user.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
2013-03-26 16:39:41 +01:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2013-03-26 16:39:41 +01:00
|
|
|
RunConfiguration *rc = doCreate(parent, id);
|
|
|
|
|
if (!rc)
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2013-03-26 16:39:41 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 14:53:12 +01:00
|
|
|
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2013-03-28 14:53:12 +01:00
|
|
|
RunConfiguration *rc = doRestore(parent, map);
|
|
|
|
|
if (!rc->fromMap(map)) {
|
|
|
|
|
delete rc;
|
2016-04-13 15:52:14 +02:00
|
|
|
rc = nullptr;
|
2013-03-28 14:53:12 +01:00
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObject<IRunConfigurationFactory>(
|
|
|
|
|
[&parent, &map](IRunConfigurationFactory *factory) {
|
|
|
|
|
return factory->canRestore(parent, map);
|
|
|
|
|
});
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, RunConfiguration *rc)
|
|
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObject<IRunConfigurationFactory>(
|
|
|
|
|
[&parent, rc](IRunConfigurationFactory *factory) {
|
|
|
|
|
return factory->canClone(parent, rc);
|
|
|
|
|
});
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> IRunConfigurationFactory::find(Target *parent)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2014-05-08 11:58:23 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>(
|
|
|
|
|
[&parent](IRunConfigurationFactory *factory) {
|
|
|
|
|
return !factory->availableCreationIds(parent).isEmpty();
|
|
|
|
|
});
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunControlFactory
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunControlFactory class creates RunControl objects matching a
|
|
|
|
|
run configuration.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-05-23 16:13:55 +02:00
|
|
|
\fn RunConfigWidget *ProjectExplorer::IRunConfigurationAspect::createConfigurationWidget()
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns a widget used to configure this runner. Ownership is transferred to
|
|
|
|
|
the caller.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
Returns null if @p \a runConfiguration is not suitable for RunControls from this
|
2013-09-10 17:16:10 +02:00
|
|
|
factory, or no user-accessible
|
2011-04-14 12:58:14 +02:00
|
|
|
configuration is required.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
IRunControlFactory::IRunControlFactory(QObject *parent)
|
2009-06-16 15:11:47 +02:00
|
|
|
: QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
Returns an IRunConfigurationAspect to carry options for RunControls this
|
|
|
|
|
factory can create.
|
|
|
|
|
|
|
|
|
|
If no extra options are required, it is allowed to return null like the
|
|
|
|
|
default implementation does. This function is intended to be called from the
|
|
|
|
|
RunConfiguration constructor, so passing a RunConfiguration pointer makes
|
|
|
|
|
no sense because that object is under construction at the time.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-03-26 16:39:41 +01:00
|
|
|
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
2011-02-28 12:23:12 +01:00
|
|
|
{
|
2013-03-26 16:39:41 +01:00
|
|
|
Q_UNUSED(rc);
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2011-02-28 12:23:12 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunControl
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The RunControl class instances represent one item that is run.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QIcon ProjectExplorer::RunControl::icon() const
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns the icon to be shown in the Outputwindow.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
TODO the icon differs currently only per "mode", so this is more flexible
|
|
|
|
|
than it needs to be.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2016-02-01 12:15:44 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
ToolRunner *trivialToolRunner()
|
|
|
|
|
{
|
|
|
|
|
static ToolRunner runner(nullptr);
|
|
|
|
|
return &runner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TargetRunner *trivialTargetRunner()
|
|
|
|
|
{
|
|
|
|
|
static TargetRunner runner(nullptr);
|
|
|
|
|
return &runner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RunControlPrivate : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
public:
|
2017-03-29 14:08:44 +02:00
|
|
|
RunControlPrivate(RunControl *parent, RunConfiguration *runConfiguration, Core::Id mode)
|
|
|
|
|
: q(parent), runMode(mode), runConfiguration(runConfiguration)
|
2016-02-01 12:15:44 +01:00
|
|
|
{
|
2017-04-13 09:01:54 +02:00
|
|
|
icon = Icons::RUN_SMALL_TOOLBAR;
|
2016-02-01 12:15:44 +01:00
|
|
|
if (runConfiguration) {
|
2017-04-11 13:34:33 +02:00
|
|
|
runnable = runConfiguration->runnable();
|
2016-02-01 12:15:44 +01:00
|
|
|
displayName = runConfiguration->displayName();
|
|
|
|
|
outputFormatter = runConfiguration->createOutputFormatter();
|
2016-02-01 12:37:35 +01:00
|
|
|
device = DeviceKitInformation::device(runConfiguration->target()->kit());
|
|
|
|
|
project = runConfiguration->target()->project();
|
2016-02-01 12:15:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-09-17 15:24:32 +02:00
|
|
|
|
2016-02-01 12:15:44 +01:00
|
|
|
~RunControlPrivate()
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
QTC_CHECK(state == State::Stopped);
|
|
|
|
|
if (targetRunner != trivialTargetRunner())
|
|
|
|
|
delete targetRunner;
|
|
|
|
|
if (toolRunner != trivialToolRunner())
|
|
|
|
|
delete toolRunner;
|
2016-02-01 12:15:44 +01:00
|
|
|
delete outputFormatter;
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
2015-09-17 15:24:32 +02:00
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
enum class State {
|
|
|
|
|
Initialized, // Default value after creation.
|
|
|
|
|
TargetPreparing, // initiateStart() was called, target boots up, connects, etc
|
|
|
|
|
ToolPreparing, // Target is acessible, tool boots
|
|
|
|
|
TargetStarting, // Late corrections on the target side after tool is available.
|
|
|
|
|
ToolStarting, // Actual process/tool starts.
|
|
|
|
|
Running, // All good and running.
|
|
|
|
|
ToolStopping, // initiateStop() was called, stop application/tool
|
|
|
|
|
TargetStopping, // Potential clean up on target, set idle state, etc.
|
|
|
|
|
Stopped, // all good, but stopped. Can possibly be re-started
|
|
|
|
|
};
|
|
|
|
|
Q_ENUM(State)
|
|
|
|
|
|
|
|
|
|
void checkState(State expectedState);
|
|
|
|
|
void setState(State state);
|
|
|
|
|
|
|
|
|
|
void initiateStart();
|
|
|
|
|
void onTargetPrepared();
|
|
|
|
|
void onToolPrepared();
|
|
|
|
|
void onTargetStarted();
|
|
|
|
|
void onToolStarted();
|
|
|
|
|
|
|
|
|
|
void initiateStop();
|
|
|
|
|
void onToolStopped();
|
|
|
|
|
void onTargetStopped();
|
|
|
|
|
|
|
|
|
|
void onToolFailed(const QString &msg);
|
|
|
|
|
void onTargetFailed(const QString &msg);
|
|
|
|
|
void handleFailure();
|
|
|
|
|
|
|
|
|
|
static bool isAllowedTransition(State from, State to);
|
|
|
|
|
|
|
|
|
|
RunControl *q;
|
2016-02-01 12:15:44 +01:00
|
|
|
QString displayName;
|
|
|
|
|
Runnable runnable;
|
2016-02-01 12:37:35 +01:00
|
|
|
IDevice::ConstPtr device;
|
2016-02-01 12:15:44 +01:00
|
|
|
Connection connection;
|
|
|
|
|
Core::Id runMode;
|
|
|
|
|
Utils::Icon icon;
|
2017-03-24 17:06:13 +01:00
|
|
|
const QPointer<RunConfiguration> runConfiguration; // Not owned.
|
|
|
|
|
QPointer<Project> project; // Not owned.
|
2017-03-29 11:01:16 +02:00
|
|
|
QPointer<TargetRunner> targetRunner; // Owned. QPointer as "extra safety" for now.
|
2017-03-24 17:06:13 +01:00
|
|
|
QPointer<ToolRunner> toolRunner; // Owned. QPointer as "extra safety" for now.
|
2016-04-13 15:52:14 +02:00
|
|
|
Utils::OutputFormatter *outputFormatter = nullptr;
|
2017-04-11 12:40:45 +02:00
|
|
|
std::function<bool(bool*)> promptToStop;
|
2016-02-01 12:15:44 +01:00
|
|
|
|
|
|
|
|
// A handle to the actual application process.
|
2017-01-16 15:53:53 +01:00
|
|
|
Utils::ProcessHandle applicationProcessHandle;
|
2016-02-01 12:15:44 +01:00
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
State state = State::Initialized;
|
2017-04-07 11:09:12 +02:00
|
|
|
bool supportsReRunning = true;
|
2017-02-27 17:25:58 +01:00
|
|
|
|
2016-02-01 12:15:44 +01:00
|
|
|
#ifdef Q_OS_OSX
|
2017-03-01 09:55:32 +01:00
|
|
|
// This is used to bring apps in the foreground on Mac
|
2016-02-01 12:15:44 +01:00
|
|
|
int foregroundCount;
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
using namespace Internal;
|
|
|
|
|
|
2016-04-13 15:52:14 +02:00
|
|
|
RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) :
|
2017-03-29 14:08:44 +02:00
|
|
|
d(new RunControlPrivate(this, runConfiguration, mode))
|
2017-02-27 11:49:00 +01:00
|
|
|
{
|
|
|
|
|
#ifdef WITH_JOURNALD
|
|
|
|
|
JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) {
|
|
|
|
|
if (entry.value("_MACHINE_ID") != JournaldWatcher::instance()->machineId())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QByteArray pid = entry.value("_PID");
|
|
|
|
|
if (pid.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const qint64 pidNum = static_cast<qint64>(QString::fromLatin1(pid).toInt());
|
|
|
|
|
if (pidNum != d->applicationProcessHandle.pid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QString message = QString::fromUtf8(entry.value("MESSAGE")) + "\n";
|
|
|
|
|
appendMessageRequested(this, message, Utils::OutputFormat::LogMessageFormat);
|
|
|
|
|
});
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
RunControl::~RunControl()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-02-27 11:49:00 +01:00
|
|
|
#ifdef WITH_JOURNALD
|
|
|
|
|
JournaldWatcher::instance()->unsubscribe(this);
|
|
|
|
|
#endif
|
2016-02-01 12:15:44 +01:00
|
|
|
delete d;
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
2009-10-08 18:37:18 +02:00
|
|
|
|
2017-03-13 13:48:55 +01:00
|
|
|
void RunControl::initiateStart()
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
if (!d->targetRunner)
|
|
|
|
|
setTargetRunner(trivialTargetRunner());
|
|
|
|
|
if (!d->toolRunner)
|
|
|
|
|
setToolRunner(trivialToolRunner());
|
|
|
|
|
emit aboutToStart();
|
|
|
|
|
start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::start()
|
|
|
|
|
{
|
|
|
|
|
d->initiateStart();
|
2017-03-13 13:48:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::initiateStop()
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::stop()
|
|
|
|
|
{
|
|
|
|
|
d->initiateStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::initiateStart()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::Initialized);
|
|
|
|
|
setState(State::TargetPreparing);
|
|
|
|
|
targetRunner->prepare();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onTargetPrepared()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::TargetPreparing);
|
|
|
|
|
setState(State::ToolPreparing);
|
|
|
|
|
toolRunner->prepare();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onToolPrepared()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::ToolPreparing);
|
|
|
|
|
setState(State::TargetStarting);
|
|
|
|
|
targetRunner->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onTargetStarted()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::TargetStarting);
|
|
|
|
|
setState(State::ToolStarting);
|
|
|
|
|
toolRunner->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onToolStarted()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::ToolStarting);
|
|
|
|
|
setState(State::Running);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::initiateStop()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::Running);
|
|
|
|
|
setState(State::ToolStopping);
|
|
|
|
|
toolRunner->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onToolStopped()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::ToolStopping);
|
|
|
|
|
setState(State::TargetStopping);
|
|
|
|
|
targetRunner->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onTargetStopped()
|
|
|
|
|
{
|
|
|
|
|
checkState(State::TargetStopping);
|
|
|
|
|
setState(State::Stopped);
|
|
|
|
|
QTC_CHECK(applicationProcessHandle.isValid());
|
|
|
|
|
q->setApplicationProcessHandle(Utils::ProcessHandle());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onTargetFailed(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
if (!msg.isEmpty())
|
|
|
|
|
q->appendMessage(msg, ErrorMessageFormat);
|
|
|
|
|
|
|
|
|
|
handleFailure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::onToolFailed(const QString &msg)
|
|
|
|
|
{
|
|
|
|
|
if (!msg.isEmpty())
|
|
|
|
|
q->appendMessage(msg, ErrorMessageFormat);
|
|
|
|
|
|
|
|
|
|
handleFailure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::handleFailure()
|
|
|
|
|
{
|
|
|
|
|
switch (state) {
|
|
|
|
|
case State::Initialized:
|
|
|
|
|
case State::TargetPreparing:
|
|
|
|
|
case State::ToolPreparing:
|
|
|
|
|
case State::TargetStarting:
|
|
|
|
|
case State::ToolStarting:
|
|
|
|
|
case State::Running:
|
|
|
|
|
case State::ToolStopping:
|
|
|
|
|
case State::TargetStopping:
|
|
|
|
|
case State::Stopped:
|
|
|
|
|
setState(State::Stopped);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-03-13 13:48:55 +01:00
|
|
|
}
|
|
|
|
|
|
2016-10-10 15:43:22 +03:00
|
|
|
Utils::OutputFormatter *RunControl::outputFormatter() const
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->outputFormatter;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
Core::Id RunControl::runMode() const
|
2010-04-30 13:19:31 +02:00
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->runMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Runnable &RunControl::runnable() const
|
|
|
|
|
{
|
|
|
|
|
return d->runnable;
|
2010-04-30 13:19:31 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-18 17:11:31 +01:00
|
|
|
void RunControl::setRunnable(const Runnable &runnable)
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
d->runnable = runnable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Connection &RunControl::connection() const
|
|
|
|
|
{
|
|
|
|
|
return d->connection;
|
2016-01-18 17:11:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setConnection(const Connection &connection)
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
d->connection = connection;
|
2016-01-18 17:11:31 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-24 17:06:13 +01:00
|
|
|
ToolRunner *RunControl::toolRunner() const
|
|
|
|
|
{
|
|
|
|
|
return d->toolRunner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setToolRunner(ToolRunner *tool)
|
|
|
|
|
{
|
|
|
|
|
d->toolRunner = tool;
|
2017-03-29 14:08:44 +02:00
|
|
|
connect(d->toolRunner, &ToolRunner::prepared, d, &RunControlPrivate::onToolPrepared);
|
|
|
|
|
connect(d->toolRunner, &ToolRunner::started, d, &RunControlPrivate::onToolStarted);
|
|
|
|
|
connect(d->toolRunner, &ToolRunner::stopped, d, &RunControlPrivate::onToolStopped);
|
|
|
|
|
connect(d->toolRunner, &ToolRunner::failed, d, &RunControlPrivate::onToolFailed);
|
2017-03-24 17:06:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
TargetRunner *RunControl::targetRunner() const
|
|
|
|
|
{
|
|
|
|
|
return d->targetRunner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setTargetRunner(TargetRunner *runner)
|
|
|
|
|
{
|
|
|
|
|
d->targetRunner = runner;
|
2017-03-29 14:08:44 +02:00
|
|
|
connect(d->targetRunner, &TargetRunner::prepared, d, &RunControlPrivate::onTargetPrepared);
|
|
|
|
|
connect(d->targetRunner, &TargetRunner::started, d, &RunControlPrivate::onTargetStarted);
|
|
|
|
|
connect(d->targetRunner, &TargetRunner::stopped, d, &RunControlPrivate::onTargetStopped);
|
|
|
|
|
connect(d->targetRunner, &TargetRunner::failed, d, &RunControlPrivate::onTargetFailed);
|
2017-03-29 11:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
QString RunControl::displayName() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->displayName;
|
2009-10-08 18:37:18 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-21 18:19:23 +01:00
|
|
|
void RunControl::setDisplayName(const QString &displayName)
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
d->displayName = displayName;
|
2016-01-21 18:19:23 +01:00
|
|
|
}
|
|
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
void RunControl::setIcon(const Utils::Icon &icon)
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
d->icon = icon;
|
2015-11-23 16:41:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::Icon RunControl::icon() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->icon;
|
2015-11-23 16:41:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-17 09:06:59 +02:00
|
|
|
Abi RunControl::abi() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
if (const RunConfiguration *rc = d->runConfiguration.data())
|
2011-08-17 09:06:59 +02:00
|
|
|
return rc->abi();
|
|
|
|
|
return Abi();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-01 12:37:35 +01:00
|
|
|
IDevice::ConstPtr RunControl::device() const
|
|
|
|
|
{
|
|
|
|
|
return d->device;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 15:06:07 +02:00
|
|
|
RunConfiguration *RunControl::runConfiguration() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->runConfiguration.data();
|
2012-08-31 15:06:07 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-17 15:24:32 +02:00
|
|
|
Project *RunControl::project() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->project.data();
|
2015-09-17 15:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
2016-02-01 14:30:13 +01:00
|
|
|
bool RunControl::canReUseOutputPane(const RunControl *other) const
|
|
|
|
|
{
|
|
|
|
|
if (other->isRunning())
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-05-11 16:29:03 +02:00
|
|
|
return d->runnable.canReUseOutputPane(other->d->runnable);
|
2016-02-01 14:30:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-01 09:55:32 +01:00
|
|
|
/*!
|
|
|
|
|
A handle to the application process.
|
|
|
|
|
|
|
|
|
|
This is typically a process id, but should be treated as
|
|
|
|
|
opaque handle to the process controled by this \c RunControl.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
ProcessHandle RunControl::applicationProcessHandle() const
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
return d->applicationProcessHandle;
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
if (d->applicationProcessHandle != handle) {
|
|
|
|
|
d->applicationProcessHandle = handle;
|
2017-02-27 17:25:58 +01:00
|
|
|
emit applicationProcessHandleChanged(QPrivateSignal());
|
2011-07-06 10:25:18 +02:00
|
|
|
}
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
Prompts to stop. If \a optionalPrompt is passed, a \gui {Do not ask again}
|
|
|
|
|
checkbox is displayed and the result is returned in \a *optionalPrompt.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::promptToStop(bool *optionalPrompt) const
|
2010-08-20 14:19:25 +02:00
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2011-01-17 13:52:14 +01:00
|
|
|
if (optionalPrompt && !*optionalPrompt)
|
|
|
|
|
return true;
|
|
|
|
|
|
2017-04-11 12:40:45 +02:00
|
|
|
// Overridden.
|
|
|
|
|
if (d->promptToStop)
|
|
|
|
|
return d->promptToStop(optionalPrompt);
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running.<center/>"
|
|
|
|
|
"<center>Force it to quit?</center></body></html>").arg(displayName());
|
|
|
|
|
return showPromptToStopDialog(tr("Application Still Running"), msg,
|
2017-01-11 21:48:46 +02:00
|
|
|
tr("Force &Quit"), tr("&Keep Running"),
|
2011-01-17 13:52:14 +01:00
|
|
|
optionalPrompt);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-11 12:40:45 +02:00
|
|
|
void RunControl::setPromptToStop(const std::function<bool (bool *)> &promptToStop)
|
|
|
|
|
{
|
|
|
|
|
d->promptToStop = promptToStop;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 11:09:12 +02:00
|
|
|
bool RunControl::supportsReRunning() const
|
|
|
|
|
{
|
|
|
|
|
return d->supportsReRunning;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setSupportsReRunning(bool reRunningSupported)
|
|
|
|
|
{
|
|
|
|
|
d->supportsReRunning = reRunningSupported;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 17:25:58 +01:00
|
|
|
bool RunControl::isRunning() const
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
return d->state == RunControlPrivate::State::Running;
|
2017-02-27 17:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Prompts to terminate the application with the \gui {Do not ask again}
|
|
|
|
|
checkbox.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::showPromptToStopDialog(const QString &title,
|
|
|
|
|
const QString &text,
|
|
|
|
|
const QString &stopButtonText,
|
|
|
|
|
const QString &cancelButtonText,
|
|
|
|
|
bool *prompt) const
|
|
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2011-01-17 13:52:14 +01:00
|
|
|
// Show a question message box where user can uncheck this
|
|
|
|
|
// question for this class.
|
2012-01-24 15:36:40 +01:00
|
|
|
Utils::CheckableMessageBox messageBox(Core::ICore::mainWindow());
|
2011-01-17 13:52:14 +01:00
|
|
|
messageBox.setWindowTitle(title);
|
|
|
|
|
messageBox.setText(text);
|
|
|
|
|
messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel);
|
|
|
|
|
if (!stopButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Yes)->setText(stopButtonText);
|
|
|
|
|
if (!cancelButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Cancel)->setText(cancelButtonText);
|
|
|
|
|
messageBox.setDefaultButton(QDialogButtonBox::Yes);
|
|
|
|
|
if (prompt) {
|
2013-10-31 15:39:49 +01:00
|
|
|
messageBox.setCheckBoxText(Utils::CheckableMessageBox::msgDoNotAskAgain());
|
2011-01-17 13:52:14 +01:00
|
|
|
messageBox.setChecked(false);
|
|
|
|
|
} else {
|
|
|
|
|
messageBox.setCheckBoxVisible(false);
|
|
|
|
|
}
|
|
|
|
|
messageBox.exec();
|
|
|
|
|
const bool close = messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
|
|
|
|
if (close && prompt && messageBox.isChecked())
|
|
|
|
|
*prompt = false;
|
|
|
|
|
return close;
|
2010-08-20 14:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
bool RunControlPrivate::isAllowedTransition(State from, State to)
|
2017-03-13 13:48:55 +01:00
|
|
|
{
|
|
|
|
|
switch (from) {
|
2017-03-29 14:08:44 +02:00
|
|
|
case State::Initialized:
|
|
|
|
|
return to == State::TargetPreparing;
|
|
|
|
|
case State::TargetPreparing:
|
|
|
|
|
return to == State::ToolPreparing;
|
|
|
|
|
case State::ToolPreparing:
|
|
|
|
|
return to == State::TargetStarting;
|
|
|
|
|
case State::TargetStarting:
|
|
|
|
|
return to == State::ToolStarting;
|
|
|
|
|
case State::ToolStarting:
|
|
|
|
|
return to == State::Running;
|
|
|
|
|
case State::Running:
|
|
|
|
|
return to == State::ToolStopping
|
|
|
|
|
|| to == State::Stopped;
|
|
|
|
|
case State::ToolStopping:
|
|
|
|
|
return to == State::TargetStopping;
|
|
|
|
|
case State::TargetStopping:
|
|
|
|
|
return to == State::Stopped;
|
|
|
|
|
case State::Stopped:
|
2017-03-13 13:48:55 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "UNKNOWN DEBUGGER STATE:" << from;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
void RunControlPrivate::checkState(State expectedState)
|
|
|
|
|
{
|
|
|
|
|
if (state != expectedState)
|
|
|
|
|
qDebug() << "Unexpected state " << expectedState << " have: " << state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControlPrivate::setState(State newState)
|
2017-03-13 13:48:55 +01:00
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
if (!isAllowedTransition(state, newState))
|
|
|
|
|
qDebug() << "Invalid run state transition from " << state << " to " << newState;
|
|
|
|
|
|
|
|
|
|
state = newState;
|
|
|
|
|
|
|
|
|
|
// Extra reporting.
|
|
|
|
|
switch (state) {
|
|
|
|
|
case State::Running:
|
|
|
|
|
emit q->started();
|
|
|
|
|
break;
|
|
|
|
|
case State::Stopped:
|
|
|
|
|
emit q->finished();
|
|
|
|
|
state = State::Initialized; // Reset for potential re-running.
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2017-03-13 13:48:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-01 09:55:32 +01:00
|
|
|
/*!
|
|
|
|
|
Brings the application determined by this RunControl's \c applicationProcessHandle
|
|
|
|
|
to the foreground.
|
|
|
|
|
|
|
|
|
|
The default implementation raises the application on Mac, and does
|
|
|
|
|
nothing elsewhere.
|
|
|
|
|
*/
|
|
|
|
|
void RunControl::bringApplicationToForeground()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
#ifdef Q_OS_OSX
|
|
|
|
|
d->foregroundCount = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
bringApplicationToForegroundInternal();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 17:25:58 +01:00
|
|
|
void RunControl::reportApplicationStart()
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
// QTC_CHECK(false); FIXME: Legacy, ToolRunner should emit started() instead.
|
|
|
|
|
d->onToolStarted();
|
|
|
|
|
emit started();
|
2017-02-27 17:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::reportApplicationStop()
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
// QTC_CHECK(false); FIXME: Legacy, ToolRunner should emit stopped() instead.
|
|
|
|
|
if (d->state == RunControlPrivate::State::Stopped) {
|
2017-03-13 13:48:55 +01:00
|
|
|
// FIXME: Currently various tool implementations call reportApplicationStop()
|
|
|
|
|
// multiple times. Fix it there and then add a soft assert here.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-03-29 14:08:44 +02:00
|
|
|
d->onToolStopped();
|
|
|
|
|
emit finished();
|
2017-02-27 17:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void RunControl::bringApplicationToForegroundInternal()
|
|
|
|
|
{
|
2016-02-01 12:15:44 +01:00
|
|
|
#ifdef Q_OS_OSX
|
2008-12-02 12:01:29 +01:00
|
|
|
ProcessSerialNumber psn;
|
2017-03-01 09:55:32 +01:00
|
|
|
GetProcessForPID(d->applicationProcessHandle.pid(), &psn);
|
2016-02-01 12:15:44 +01:00
|
|
|
if (SetFrontProcess(&psn) == procNotFound && d->foregroundCount < 15) {
|
2008-12-02 12:01:29 +01:00
|
|
|
// somehow the mac/carbon api says
|
|
|
|
|
// "-600 no eligible process with specified process id"
|
|
|
|
|
// if we call SetFrontProcess too early
|
2016-02-01 12:15:44 +01:00
|
|
|
++d->foregroundCount;
|
2016-01-29 16:38:37 +02:00
|
|
|
QTimer::singleShot(200, this, &RunControl::bringApplicationToForegroundInternal);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2011-01-07 18:57:54 +01:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
|
2011-01-07 18:57:54 +01:00
|
|
|
{
|
2016-05-13 11:27:51 +02:00
|
|
|
emit appendMessageRequested(this, msg, format);
|
2011-01-07 18:57:54 +01:00
|
|
|
}
|
2015-06-29 10:36:29 +03:00
|
|
|
|
2016-05-11 16:29:03 +02:00
|
|
|
bool Runnable::canReUseOutputPane(const Runnable &other) const
|
2016-02-01 14:30:13 +01:00
|
|
|
{
|
2016-05-11 16:29:03 +02:00
|
|
|
return d ? d->canReUseOutputPane(other.d) : (other.d.get() == 0);
|
2016-02-01 14:30:13 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-10 09:05:52 +01:00
|
|
|
|
2017-03-13 17:01:59 +01:00
|
|
|
// FIXME: Remove once ApplicationLauncher signalling does not depend on device.
|
|
|
|
|
static bool isSynchronousLauncher(RunControl *runControl)
|
|
|
|
|
{
|
|
|
|
|
RunConfiguration *runConfig = runControl->runConfiguration();
|
|
|
|
|
Target *target = runConfig ? runConfig->target() : nullptr;
|
|
|
|
|
Kit *kit = target ? target->kit() : nullptr;
|
|
|
|
|
Core::Id deviceId = DeviceTypeKitInformation::deviceTypeId(kit);
|
|
|
|
|
return !deviceId.isValid() || deviceId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
|
|
|
|
|
// SimpleTargetRunner
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
SimpleTargetRunner::SimpleTargetRunner(RunControl *runControl)
|
|
|
|
|
: TargetRunner(runControl)
|
2017-03-10 09:05:52 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
void SimpleTargetRunner::start()
|
2017-03-10 09:05:52 +01:00
|
|
|
{
|
2017-03-29 11:01:16 +02:00
|
|
|
m_launcher.disconnect(this);
|
2017-03-10 09:05:52 +01:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
Runnable r = runControl()->runnable();
|
2017-03-10 09:05:52 +01:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
if (isSynchronousLauncher(runControl())) {
|
2017-03-13 17:01:59 +01:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::appendMessage,
|
|
|
|
|
this, &TargetRunner::appendMessage);
|
|
|
|
|
connect(&m_launcher, &ApplicationLauncher::processStarted,
|
|
|
|
|
this, &SimpleTargetRunner::onProcessStarted);
|
|
|
|
|
connect(&m_launcher, &ApplicationLauncher::processExited,
|
|
|
|
|
this, &SimpleTargetRunner::onProcessFinished);
|
2017-03-13 17:01:59 +01:00
|
|
|
|
|
|
|
|
QTC_ASSERT(r.is<StandardRunnable>(), return);
|
|
|
|
|
const QString executable = r.as<StandardRunnable>().executable;
|
|
|
|
|
if (executable.isEmpty()) {
|
2017-03-29 14:08:44 +02:00
|
|
|
emit failed(RunControl::tr("No executable specified.") + '\n');
|
2017-03-13 17:01:59 +01:00
|
|
|
} else if (!QFileInfo::exists(executable)) {
|
2017-03-29 14:08:44 +02:00
|
|
|
emit failed(RunControl::tr("Executable %1 does not exist.")
|
|
|
|
|
.arg(QDir::toNativeSeparators(executable)) + '\n');
|
2017-03-13 17:01:59 +01:00
|
|
|
} else {
|
|
|
|
|
QString msg = RunControl::tr("Starting %1...").arg(QDir::toNativeSeparators(executable)) + '\n';
|
|
|
|
|
appendMessage(msg, Utils::NormalMessageFormat);
|
2017-03-29 11:01:16 +02:00
|
|
|
m_launcher.start(r);
|
2017-03-13 17:01:59 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-10 09:05:52 +01:00
|
|
|
} else {
|
2017-03-13 17:01:59 +01:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::reportError,
|
2017-03-29 14:08:44 +02:00
|
|
|
this, &TargetRunner::failed);
|
2017-03-13 17:01:59 +01:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::remoteStderr,
|
2017-03-13 17:01:59 +01:00
|
|
|
this, [this](const QByteArray &output) {
|
|
|
|
|
appendMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
|
|
|
|
|
});
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::remoteStdout,
|
2017-03-13 17:01:59 +01:00
|
|
|
this, [this](const QByteArray &output) {
|
|
|
|
|
appendMessage(QString::fromUtf8(output), Utils::StdOutFormatSameLine);
|
|
|
|
|
});
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::finished,
|
2017-03-13 17:01:59 +01:00
|
|
|
this, [this] {
|
2017-03-29 11:01:16 +02:00
|
|
|
m_launcher.disconnect(this);
|
2017-03-29 14:08:44 +02:00
|
|
|
emit stopped();
|
2017-03-13 17:01:59 +01:00
|
|
|
});
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
connect(&m_launcher, &ApplicationLauncher::reportProgress,
|
2017-03-13 17:01:59 +01:00
|
|
|
this, [this](const QString &progressString) {
|
|
|
|
|
appendMessage(progressString + '\n', Utils::NormalMessageFormat);
|
|
|
|
|
});
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
m_launcher.start(r, runControl()->device());
|
2017-03-10 09:05:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
void SimpleTargetRunner::stop()
|
2017-03-10 09:05:52 +01:00
|
|
|
{
|
2017-03-29 11:01:16 +02:00
|
|
|
m_launcher.stop();
|
2017-03-10 09:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
void SimpleTargetRunner::onProcessStarted()
|
2017-03-10 09:05:52 +01:00
|
|
|
{
|
|
|
|
|
// Console processes only know their pid after being started
|
2017-03-29 14:08:44 +02:00
|
|
|
emit started();
|
2017-03-29 11:01:16 +02:00
|
|
|
runControl()->setApplicationProcessHandle(m_launcher.applicationPID());
|
|
|
|
|
runControl()->bringApplicationToForeground();
|
2017-03-10 09:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
void SimpleTargetRunner::onProcessFinished(int exitCode, QProcess::ExitStatus status)
|
2017-03-10 09:05:52 +01:00
|
|
|
{
|
|
|
|
|
QString msg;
|
2017-03-29 11:01:16 +02:00
|
|
|
QString exe = runControl()->runnable().as<StandardRunnable>().executable;
|
2017-03-10 09:05:52 +01:00
|
|
|
if (status == QProcess::CrashExit)
|
|
|
|
|
msg = tr("%1 crashed.").arg(QDir::toNativeSeparators(exe));
|
|
|
|
|
else
|
|
|
|
|
msg = tr("%1 exited with code %2").arg(QDir::toNativeSeparators(exe)).arg(exitCode);
|
2017-03-29 11:01:16 +02:00
|
|
|
appendMessage(msg + '\n', Utils::NormalMessageFormat);
|
2017-03-29 14:08:44 +02:00
|
|
|
emit stopped();
|
2017-03-29 11:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
|
2017-03-29 11:01:16 +02:00
|
|
|
// TargetRunner
|
|
|
|
|
|
|
|
|
|
TargetRunner::TargetRunner(RunControl *runControl)
|
|
|
|
|
: m_runControl(runControl)
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
if (runControl)
|
|
|
|
|
runControl->setTargetRunner(this);
|
2017-03-29 11:01:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunControl *TargetRunner::runControl() const
|
|
|
|
|
{
|
|
|
|
|
return m_runControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetRunner::appendMessage(const QString &msg, OutputFormat format)
|
|
|
|
|
{
|
|
|
|
|
m_runControl->appendMessage(msg, format);
|
2017-03-10 09:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
|
2017-03-24 17:06:13 +01:00
|
|
|
// ToolRunner
|
|
|
|
|
|
|
|
|
|
ToolRunner::ToolRunner(RunControl *runControl)
|
|
|
|
|
: m_runControl(runControl)
|
|
|
|
|
{
|
2017-03-29 14:08:44 +02:00
|
|
|
if (runControl)
|
|
|
|
|
runControl->setToolRunner(this);
|
2017-03-24 17:06:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunControl *ToolRunner::runControl() const
|
|
|
|
|
{
|
|
|
|
|
return m_runControl;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 09:07:29 +02:00
|
|
|
void ToolRunner::appendMessage(const QString &msg, OutputFormat format)
|
|
|
|
|
{
|
|
|
|
|
m_runControl->appendMessage(msg, format);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 16:14:58 +02:00
|
|
|
IDevice::ConstPtr ToolRunner::device() const
|
|
|
|
|
{
|
|
|
|
|
return m_runControl->device();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
} // namespace ProjectExplorer
|