2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
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
|
|
|
|
2009-10-28 17:21:27 +01:00
|
|
|
#include "buildconfiguration.h"
|
2019-10-25 09:55:32 +02:00
|
|
|
#include "buildsystem.h"
|
2017-01-25 16:18:30 +01:00
|
|
|
#include "environmentaspect.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitinformation.h"
|
2019-08-02 12:00:39 +02:00
|
|
|
#include "kitinformation.h"
|
|
|
|
|
#include "project.h"
|
|
|
|
|
#include "projectexplorer.h"
|
2022-06-22 15:43:33 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2023-01-13 12:38:22 +01:00
|
|
|
#include "projectexplorertr.h"
|
2023-02-14 15:47:22 +01:00
|
|
|
#include "projectmanager.h"
|
2019-12-04 17:23:02 +01:00
|
|
|
#include "projectnodes.h"
|
2018-04-20 13:40:15 +02:00
|
|
|
#include "runconfigurationaspects.h"
|
2019-08-02 12:00:39 +02:00
|
|
|
#include "runcontrol.h"
|
|
|
|
|
#include "target.h"
|
2017-03-10 09:05:52 +01:00
|
|
|
|
2022-04-12 21:01:45 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
|
2022-04-12 21:01:45 +02:00
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
|
2017-01-05 12:49:45 +01:00
|
|
|
#include <utils/algorithm.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2018-03-20 13:09:16 +01:00
|
|
|
#include <utils/detailswidget.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.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>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/variablechooser.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
|
2019-01-31 18:23:10 +01:00
|
|
|
#include <QHash>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2017-03-10 09:05:52 +01:00
|
|
|
#include <QTimer>
|
2017-05-09 10:25:11 +02:00
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
#include <QSettings>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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
|
|
|
|
2019-08-12 12:42:21 +02:00
|
|
|
const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
|
2023-06-27 16:26:56 +02:00
|
|
|
const char CUSTOMIZED_KEY[] = "ProjectExplorer.RunConfiguration.Customized";
|
2019-08-12 12:42:21 +02:00
|
|
|
|
2019-08-28 08:55:28 +02:00
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// IRunConfigurationAspect
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2022-04-08 11:35:54 +02:00
|
|
|
GlobalOrProjectAspect::GlobalOrProjectAspect()
|
|
|
|
|
{
|
|
|
|
|
addDataExtractor(this, &GlobalOrProjectAspect::currentSettings, &Data::currentSettings);
|
|
|
|
|
}
|
2013-08-12 17:04:10 +02:00
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
GlobalOrProjectAspect::~GlobalOrProjectAspect()
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
delete m_projectSettings;
|
|
|
|
|
}
|
2012-02-17 19:05:11 +01:00
|
|
|
|
2023-07-21 16:39:05 +02:00
|
|
|
void GlobalOrProjectAspect::setProjectSettings(AspectContainer *settings)
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
m_projectSettings = settings;
|
2023-07-20 09:09:47 +02:00
|
|
|
m_projectSettings->setAutoApply(true);
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 16:39:05 +02:00
|
|
|
void GlobalOrProjectAspect::setGlobalSettings(AspectContainer *settings)
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
m_globalSettings = settings;
|
2023-07-20 09:09:47 +02:00
|
|
|
m_projectSettings->setAutoApply(false);
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
void GlobalOrProjectAspect::setUsingGlobalSettings(bool value)
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
m_useGlobalSettings = value;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 16:39:05 +02:00
|
|
|
AspectContainer *GlobalOrProjectAspect::currentSettings() const
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
void GlobalOrProjectAspect::fromMap(const QVariantMap &map)
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
2017-11-09 16:06:19 +01:00
|
|
|
if (m_projectSettings)
|
|
|
|
|
m_projectSettings->fromMap(map);
|
2020-12-17 15:43:10 +01:00
|
|
|
m_useGlobalSettings = map.value(id().toString() + ".UseGlobalSettings", true).toBool();
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
void GlobalOrProjectAspect::toMap(QVariantMap &map) const
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
2017-11-09 16:06:19 +01:00
|
|
|
if (m_projectSettings)
|
|
|
|
|
m_projectSettings->toMap(map);
|
2020-12-17 15:43:10 +01:00
|
|
|
map.insert(id().toString() + ".UseGlobalSettings", m_useGlobalSettings);
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-18 07:18:40 +01:00
|
|
|
void GlobalOrProjectAspect::toActiveMap(QVariantMap &data) const
|
|
|
|
|
{
|
|
|
|
|
if (m_useGlobalSettings)
|
|
|
|
|
m_globalSettings->toMap(data);
|
|
|
|
|
else if (m_projectSettings)
|
|
|
|
|
m_projectSettings->toMap(data);
|
2021-02-22 11:31:11 +01:00
|
|
|
// The debugger accesses the data directly, so this can actually happen.
|
|
|
|
|
//else
|
|
|
|
|
// QTC_CHECK(false);
|
2021-02-18 07:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
void GlobalOrProjectAspect::resetProjectToGlobalSettings()
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_globalSettings, return);
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
m_globalSettings->toMap(map);
|
2017-11-09 16:06:19 +01:00
|
|
|
if (m_projectSettings)
|
|
|
|
|
m_projectSettings->fromMap(map);
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-27 17:17:24 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunConfiguration
|
2020-06-12 07:05:08 +02:00
|
|
|
\inmodule QtCreator
|
|
|
|
|
\inheaderfile projectexplorer/runconfiguration.h
|
|
|
|
|
|
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.
|
|
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
The target owns the RunConfigurations and a RunControl will need to copy all
|
2017-07-17 14:34:05 +02:00
|
|
|
necessary data as the RunControl may continue to exist after the RunConfiguration
|
|
|
|
|
has been destroyed.
|
|
|
|
|
|
2019-08-14 15:28:03 +02:00
|
|
|
A RunConfiguration disables itself if the project has no parsing
|
2017-07-17 14:34:05 +02:00
|
|
|
data available. The disabledReason() method can be used to get a user-facing string
|
|
|
|
|
describing why the RunConfiguration considers itself unfit for use.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2017-07-14 09:36:09 +02:00
|
|
|
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
|
2023-07-10 10:02:37 +02:00
|
|
|
: ProjectConfiguration(target, target, id)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2023-06-27 16:26:56 +02:00
|
|
|
forceDisplayNameSerialization();
|
2020-01-20 14:42:34 +01:00
|
|
|
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
2017-09-01 13:23:02 +02:00
|
|
|
|
2023-01-13 12:38:22 +01:00
|
|
|
m_expander.setDisplayName(Tr::tr("Run Settings"));
|
2020-02-18 14:44:58 +01:00
|
|
|
m_expander.setAccumulating(true);
|
|
|
|
|
m_expander.registerSubProvider([target] {
|
2017-09-01 13:23:02 +02:00
|
|
|
BuildConfiguration *bc = target->activeBuildConfiguration();
|
|
|
|
|
return bc ? bc->macroExpander() : target->macroExpander();
|
|
|
|
|
});
|
2023-01-13 12:38:22 +01:00
|
|
|
m_expander.registerPrefix("RunConfig:Env", Tr::tr("Variables in the run environment."),
|
2021-04-08 14:17:42 +02:00
|
|
|
[this](const QString &var) {
|
|
|
|
|
const auto envAspect = aspect<EnvironmentAspect>();
|
|
|
|
|
return envAspect ? envAspect->environment().expandedValueForKey(var) : QString();
|
|
|
|
|
});
|
|
|
|
|
m_expander.registerVariable("RunConfig:WorkingDir",
|
2023-01-13 12:38:22 +01:00
|
|
|
Tr::tr("The run configuration's working directory."),
|
2021-04-08 14:17:42 +02:00
|
|
|
[this] {
|
|
|
|
|
const auto wdAspect = aspect<WorkingDirectoryAspect>();
|
2021-09-22 16:26:12 +02:00
|
|
|
return wdAspect ? wdAspect->workingDirectory().toString() : QString();
|
2021-04-08 14:17:42 +02:00
|
|
|
});
|
2023-01-13 12:38:22 +01:00
|
|
|
m_expander.registerVariable("RunConfig:Name", Tr::tr("The run configuration's name."),
|
2021-04-08 14:17:42 +02:00
|
|
|
[this] { return displayName(); });
|
|
|
|
|
m_expander.registerFileVariables("RunConfig:Executable",
|
2023-01-13 12:38:22 +01:00
|
|
|
Tr::tr("The run configuration's executable."),
|
2021-06-01 18:18:02 +02:00
|
|
|
[this] { return commandLine().executable(); });
|
2021-04-08 14:17:42 +02:00
|
|
|
|
|
|
|
|
|
2022-05-11 16:51:46 +02:00
|
|
|
m_commandLineGetter = [this] {
|
2019-06-11 14:39:39 +02:00
|
|
|
FilePath executable;
|
2019-05-23 18:10:34 +02:00
|
|
|
if (const auto executableAspect = aspect<ExecutableAspect>())
|
2019-06-11 14:39:39 +02:00
|
|
|
executable = executableAspect->executable();
|
|
|
|
|
QString arguments;
|
|
|
|
|
if (const auto argumentsAspect = aspect<ArgumentsAspect>())
|
2022-05-11 16:51:46 +02:00
|
|
|
arguments = argumentsAspect->arguments();
|
2022-05-10 16:30:26 +02:00
|
|
|
|
2019-06-11 14:39:39 +02:00
|
|
|
return CommandLine{executable, arguments, CommandLine::Raw};
|
2019-05-23 18:10:34 +02:00
|
|
|
};
|
2017-09-01 13:23:02 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 15:48:16 +02:00
|
|
|
RunConfiguration::~RunConfiguration() = default;
|
2017-09-01 13:23:02 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
QString RunConfiguration::disabledReason() const
|
2019-04-03 18:43:28 +02:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
BuildSystem *bs = activeBuildSystem();
|
2023-01-13 12:38:22 +01:00
|
|
|
return bs ? bs->disabledReason(m_buildKey) : Tr::tr("No build system active");
|
2019-04-03 18:43:28 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
bool RunConfiguration::isEnabled() const
|
2017-07-17 14:34:05 +02:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
BuildSystem *bs = activeBuildSystem();
|
|
|
|
|
return bs && bs->hasParsingData();
|
2017-07-17 14:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-20 13:40:15 +02:00
|
|
|
QWidget *RunConfiguration::createConfigurationWidget()
|
|
|
|
|
{
|
2023-04-27 08:24:43 +02:00
|
|
|
Layouting::Form form;
|
2023-05-22 13:30:11 +02:00
|
|
|
for (BaseAspect *aspect : std::as_const(*this)) {
|
2023-05-02 17:20:57 +02:00
|
|
|
if (aspect->isVisible()) {
|
2023-04-27 08:24:43 +02:00
|
|
|
form.addItem(aspect);
|
2023-05-02 17:20:57 +02:00
|
|
|
form.addItem(Layouting::br);
|
|
|
|
|
}
|
2018-09-04 08:38:44 +02:00
|
|
|
}
|
2023-05-02 12:51:03 +02:00
|
|
|
form.addItem(Layouting::noMargin);
|
|
|
|
|
auto widget = form.emerge();
|
2021-03-11 19:02:42 +01:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
VariableChooser::addSupportForChildWidgets(widget, &m_expander);
|
2018-04-20 13:40:15 +02:00
|
|
|
|
2018-09-26 09:17:55 +02:00
|
|
|
auto detailsWidget = new Utils::DetailsWidget;
|
|
|
|
|
detailsWidget->setState(DetailsWidget::NoSummary);
|
|
|
|
|
detailsWidget->setWidget(widget);
|
|
|
|
|
return detailsWidget;
|
2018-04-20 13:40:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-18 13:54:35 +01:00
|
|
|
bool RunConfiguration::isConfigured() const
|
|
|
|
|
{
|
|
|
|
|
return !Utils::anyOf(checkForIssues(), [](const Task &t) { return t.type == Task::Error; });
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 16:26:56 +02:00
|
|
|
bool RunConfiguration::isCustomized() const
|
|
|
|
|
{
|
|
|
|
|
if (m_customized)
|
|
|
|
|
return true;
|
2023-07-21 17:44:01 +02:00
|
|
|
QVariantMap state;
|
|
|
|
|
toMapSimple(state);
|
2023-06-27 16:26:56 +02:00
|
|
|
|
|
|
|
|
// TODO: Why do we save this at all? It's a computed value.
|
|
|
|
|
state.remove("RunConfiguration.WorkingDirectory.default");
|
|
|
|
|
|
|
|
|
|
return state != m_pristineState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RunConfiguration::hasCreator() const
|
|
|
|
|
{
|
|
|
|
|
return Utils::contains(RunConfigurationFactory::creatorsForTarget(target()),
|
|
|
|
|
[this](const RunConfigurationCreationInfo &info) {
|
|
|
|
|
return info.factory->runConfigurationId() == id() && info.buildKey == buildKey();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfiguration::setPristineState()
|
|
|
|
|
{
|
|
|
|
|
if (!m_customized) {
|
2023-07-21 17:44:01 +02:00
|
|
|
m_pristineState.clear();
|
|
|
|
|
toMapSimple(m_pristineState);
|
2023-06-27 16:26:56 +02:00
|
|
|
m_pristineState.remove("RunConfiguration.WorkingDirectory.default");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 09:36:09 +02:00
|
|
|
void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
2011-02-28 12:23:12 +01:00
|
|
|
{
|
2017-07-14 09:36:09 +02:00
|
|
|
theAspectFactories.push_back(aspectFactory);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-08 11:35:54 +02:00
|
|
|
QMap<Utils::Id, QVariantMap> RunConfiguration::settingsData() const
|
2019-08-27 16:44:42 +02:00
|
|
|
{
|
2020-06-26 13:59:38 +02:00
|
|
|
QMap<Utils::Id, QVariantMap> data;
|
2023-05-22 13:30:11 +02:00
|
|
|
for (BaseAspect *aspect : *this)
|
2021-02-18 07:18:40 +01:00
|
|
|
aspect->toActiveMap(data[aspect->id()]);
|
2019-08-27 16:44:42 +02:00
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 15:12:24 +02:00
|
|
|
AspectContainerData RunConfiguration::aspectData() const
|
2022-04-08 11:35:54 +02:00
|
|
|
{
|
2022-04-08 15:12:24 +02:00
|
|
|
AspectContainerData data;
|
2023-05-22 13:30:11 +02:00
|
|
|
for (BaseAspect *aspect : *this)
|
2022-05-11 16:51:46 +02:00
|
|
|
data.append(aspect->extractData());
|
2022-04-08 15:12:24 +02:00
|
|
|
return data;
|
2022-04-08 11:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
BuildSystem *RunConfiguration::activeBuildSystem() const
|
|
|
|
|
{
|
|
|
|
|
return target()->buildSystem();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 11:10:11 +01:00
|
|
|
void RunConfiguration::setUpdater(const Updater &updater)
|
|
|
|
|
{
|
|
|
|
|
m_updater = updater;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-05 16:28:52 +01:00
|
|
|
Task RunConfiguration::createConfigurationIssue(const QString &description) const
|
|
|
|
|
{
|
2020-01-15 08:56:11 +01:00
|
|
|
return BuildSystemTask(Task::Error, description);
|
2019-12-05 16:28:52 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 17:44:01 +02:00
|
|
|
void RunConfiguration::toMap(QVariantMap &map) const
|
2010-09-01 11:34:34 +02:00
|
|
|
{
|
2023-07-21 17:44:01 +02:00
|
|
|
toMapSimple(map);
|
2023-06-27 16:26:56 +02:00
|
|
|
map.insert(CUSTOMIZED_KEY, isCustomized());
|
|
|
|
|
}
|
2012-02-22 11:56:08 +01:00
|
|
|
|
2023-07-21 17:44:01 +02:00
|
|
|
void RunConfiguration::toMapSimple(QVariantMap &map) const
|
2023-06-27 16:26:56 +02:00
|
|
|
{
|
2023-07-21 17:44:01 +02:00
|
|
|
ProjectConfiguration::toMap(map);
|
2019-08-12 12:42:21 +02:00
|
|
|
map.insert(BUILD_KEY, m_buildKey);
|
|
|
|
|
|
2018-04-09 12:33:10 +02:00
|
|
|
// FIXME: Remove this id mangling, e.g. by using a separate entry for the build key.
|
|
|
|
|
if (!m_buildKey.isEmpty()) {
|
2020-06-26 13:59:38 +02:00
|
|
|
const Utils::Id mangled = id().withSuffix(m_buildKey);
|
2018-04-09 12:33:10 +02:00
|
|
|
map.insert(settingsIdKey(), mangled.toSetting());
|
|
|
|
|
}
|
2010-09-01 11:34:34 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-11 14:39:39 +02:00
|
|
|
void RunConfiguration::setCommandLineGetter(const CommandLineGetter &cmdGetter)
|
2019-05-23 18:10:34 +02:00
|
|
|
{
|
2019-06-11 14:39:39 +02:00
|
|
|
m_commandLineGetter = cmdGetter;
|
2019-05-23 18:10:34 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-11 14:39:39 +02:00
|
|
|
CommandLine RunConfiguration::commandLine() const
|
2019-05-23 18:10:34 +02:00
|
|
|
{
|
2019-06-11 14:39:39 +02:00
|
|
|
return m_commandLineGetter();
|
2019-05-23 18:10:34 +02:00
|
|
|
}
|
|
|
|
|
|
2023-04-24 17:25:13 +02:00
|
|
|
bool RunConfiguration::isPrintEnvironmentEnabled() const
|
|
|
|
|
{
|
|
|
|
|
if (const auto envAspect = aspect<EnvironmentAspect>())
|
|
|
|
|
return envAspect->isPrintOnRunEnabled();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 17:14:25 +02:00
|
|
|
void RunConfiguration::setRunnableModifier(const RunnableModifier &runnableModifier)
|
|
|
|
|
{
|
|
|
|
|
m_runnableModifier = runnableModifier;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 11:10:11 +01:00
|
|
|
void RunConfiguration::update()
|
|
|
|
|
{
|
2019-12-04 09:19:50 +01:00
|
|
|
if (m_updater)
|
|
|
|
|
m_updater();
|
|
|
|
|
|
|
|
|
|
emit enabledChanged();
|
2020-01-20 14:42:34 +01:00
|
|
|
|
2020-02-24 14:58:36 +01:00
|
|
|
const bool isActive = target()->isActive() && target()->activeRunConfiguration() == this;
|
|
|
|
|
|
2023-02-14 15:47:22 +01:00
|
|
|
if (isActive && project() == ProjectManager::startupProject())
|
2020-02-24 15:55:15 +01:00
|
|
|
ProjectExplorerPlugin::updateRunActions();
|
2019-11-25 11:10:11 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-26 08:37:56 +02:00
|
|
|
BuildTargetInfo RunConfiguration::buildTargetInfo() const
|
|
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
BuildSystem *bs = target()->buildSystem();
|
|
|
|
|
QTC_ASSERT(bs, return {});
|
|
|
|
|
return bs->buildTarget(m_buildKey);
|
2018-04-26 08:37:56 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-04 17:23:02 +01:00
|
|
|
ProjectNode *RunConfiguration::productNode() const
|
|
|
|
|
{
|
|
|
|
|
return project()->rootProjectNode()->findProjectNode([this](const ProjectNode *candidate) {
|
|
|
|
|
return candidate->buildKey() == buildKey();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 18:23:50 +02:00
|
|
|
void RunConfiguration::fromMap(const QVariantMap &map)
|
2010-09-01 11:34:34 +02:00
|
|
|
{
|
2023-07-21 18:23:50 +02:00
|
|
|
ProjectConfiguration::fromMap(map);
|
|
|
|
|
if (hasError())
|
|
|
|
|
return;
|
2018-04-09 12:33:10 +02:00
|
|
|
|
2023-06-27 16:26:56 +02:00
|
|
|
m_customized = m_customized || map.value(CUSTOMIZED_KEY, false).toBool();
|
2019-08-12 12:42:21 +02:00
|
|
|
m_buildKey = map.value(BUILD_KEY).toString();
|
|
|
|
|
|
|
|
|
|
if (m_buildKey.isEmpty()) {
|
2020-06-26 13:59:38 +02:00
|
|
|
const Utils::Id mangledId = Utils::Id::fromSetting(map.value(settingsIdKey()));
|
2019-08-12 12:42:21 +02:00
|
|
|
m_buildKey = mangledId.suffixAfter(id());
|
2019-10-17 13:02:43 +02:00
|
|
|
|
|
|
|
|
// Hack for cmake projects 4.10 -> 4.11.
|
|
|
|
|
const QString magicSeparator = "///::///";
|
|
|
|
|
const int magicIndex = m_buildKey.indexOf(magicSeparator);
|
|
|
|
|
if (magicIndex != -1)
|
|
|
|
|
m_buildKey = m_buildKey.mid(magicIndex + magicSeparator.length());
|
2019-08-12 12:42:21 +02:00
|
|
|
}
|
2010-09-01 11:34:34 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
|
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
|
2017-07-18 10:39:03 +02:00
|
|
|
on the target. Target specific) \n RunWorker implementation
|
2016-01-20 14:50:34 +01:00
|
|
|
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
|
|
|
|
|
{
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable r;
|
2021-08-10 09:19:30 +02:00
|
|
|
r.command = commandLine();
|
2018-09-07 13:29:45 +02:00
|
|
|
if (auto workingDirectoryAspect = aspect<WorkingDirectoryAspect>())
|
2023-06-23 10:15:47 +02:00
|
|
|
r.workingDirectory = r.command.executable().withNewMappedPath(workingDirectoryAspect->workingDirectory());
|
2018-09-07 13:29:45 +02:00
|
|
|
if (auto environmentAspect = aspect<EnvironmentAspect>())
|
|
|
|
|
r.environment = environmentAspect->environment();
|
2023-06-20 09:27:47 +02:00
|
|
|
if (auto forwardingAspect = aspect<X11ForwardingAspect>())
|
|
|
|
|
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display());
|
2021-04-12 17:14:25 +02:00
|
|
|
if (m_runnableModifier)
|
|
|
|
|
m_runnableModifier(r);
|
2018-04-20 13:40:15 +02:00
|
|
|
return r;
|
2016-01-20 14:50:34 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2020-06-12 07:05:08 +02:00
|
|
|
\class ProjectExplorer::RunConfigurationFactory
|
|
|
|
|
\inmodule QtCreator
|
|
|
|
|
\inheaderfile projectexplorer/runconfiguration.h
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
\brief The RunConfigurationFactory class is used to create and persist
|
|
|
|
|
run configurations.
|
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.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
A RunConfigurationFactory instance is responsible for handling one type of
|
|
|
|
|
run configurations. This can be restricted to certain project and device
|
|
|
|
|
types.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
RunConfigurationFactory instances register themselves into a global list on
|
|
|
|
|
construction and deregister on destruction. It is recommended to make them
|
|
|
|
|
a plain data member of a structure that is allocated in your plugin's
|
|
|
|
|
ExtensionSystem::IPlugin::initialize() method.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
static QList<RunConfigurationFactory *> g_runConfigurationFactories;
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2020-06-12 07:05:08 +02:00
|
|
|
Constructs a RunConfigurationFactory instance and registers it into a global
|
|
|
|
|
list.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
Derived classes should set suitably properties to specify the type of
|
|
|
|
|
run configurations they can handle.
|
|
|
|
|
*/
|
2017-12-08 17:20:48 +01:00
|
|
|
|
2018-03-06 17:14:43 +01:00
|
|
|
RunConfigurationFactory::RunConfigurationFactory()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-12-08 17:20:48 +01:00
|
|
|
g_runConfigurationFactories.append(this);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
/*!
|
|
|
|
|
De-registers the instance from the global list of factories and destructs it.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-03-06 17:14:43 +01:00
|
|
|
RunConfigurationFactory::~RunConfigurationFactory()
|
2017-12-08 17:20:48 +01:00
|
|
|
{
|
|
|
|
|
g_runConfigurationFactories.removeOne(this);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 10:32:56 +01:00
|
|
|
QString RunConfigurationFactory::decoratedTargetName(const QString &targetName, Target *target)
|
2018-02-14 10:25:47 +01:00
|
|
|
{
|
2021-04-01 12:19:11 +02:00
|
|
|
QString displayName = targetName;
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id devType = DeviceTypeKitAspect::deviceTypeId(target->kit());
|
2018-02-14 10:25:47 +01:00
|
|
|
if (devType != Constants::DESKTOP_DEVICE_TYPE) {
|
2019-02-06 12:50:51 +01:00
|
|
|
if (IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit())) {
|
2018-02-15 16:52:50 +01:00
|
|
|
if (displayName.isEmpty()) {
|
|
|
|
|
//: Shown in Run configuration if no executable is given, %1 is device name
|
2023-01-13 12:38:22 +01:00
|
|
|
displayName = Tr::tr("Run on %{Device:Name}");
|
2018-02-15 16:52:50 +01:00
|
|
|
} else {
|
|
|
|
|
//: Shown in Run configuration, Add menu: "name of runnable (on device name)"
|
2023-01-13 12:38:22 +01:00
|
|
|
displayName = Tr::tr("%1 (on %{Device:Name})").arg(displayName);
|
2018-02-15 16:52:50 +01:00
|
|
|
}
|
|
|
|
|
}
|
2018-02-14 10:25:47 +01:00
|
|
|
}
|
|
|
|
|
return displayName;
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
QList<RunConfigurationCreationInfo>
|
2020-03-23 14:14:03 +01:00
|
|
|
RunConfigurationFactory::availableCreators(Target *target) const
|
2017-11-20 11:56:19 +01:00
|
|
|
{
|
2020-03-23 14:14:03 +01:00
|
|
|
const QList<BuildTargetInfo> buildTargets = target->buildSystem()->applicationTargets();
|
2018-02-21 12:30:09 +01:00
|
|
|
const bool hasAnyQtcRunnable = Utils::anyOf(buildTargets,
|
|
|
|
|
Utils::equal(&BuildTargetInfo::isQtcRunnable, true));
|
|
|
|
|
return Utils::transform(buildTargets, [&](const BuildTargetInfo &ti) {
|
2018-03-07 09:32:04 +01:00
|
|
|
QString displayName = ti.displayName;
|
|
|
|
|
if (displayName.isEmpty())
|
2020-03-23 14:14:03 +01:00
|
|
|
displayName = decoratedTargetName(ti.buildKey, target);
|
2018-03-21 09:44:33 +01:00
|
|
|
else if (m_decorateDisplayNames)
|
2020-03-23 14:14:03 +01:00
|
|
|
displayName = decoratedTargetName(displayName, target);
|
2018-05-03 17:22:13 +02:00
|
|
|
RunConfigurationCreationInfo rci;
|
|
|
|
|
rci.factory = this;
|
|
|
|
|
rci.buildKey = ti.buildKey;
|
2019-02-19 12:56:28 +01:00
|
|
|
rci.projectFilePath = ti.projectFilePath;
|
2018-05-03 17:22:13 +02:00
|
|
|
rci.displayName = displayName;
|
2019-01-31 18:23:10 +01:00
|
|
|
rci.displayNameUniquifier = ti.displayNameUniquifier;
|
2018-02-21 12:30:09 +01:00
|
|
|
rci.creationMode = ti.isQtcRunnable || !hasAnyQtcRunnable
|
|
|
|
|
? RunConfigurationCreationInfo::AlwaysCreate
|
|
|
|
|
: RunConfigurationCreationInfo::ManualCreationOnly;
|
|
|
|
|
rci.useTerminal = ti.usesTerminal;
|
|
|
|
|
rci.buildKey = ti.buildKey;
|
|
|
|
|
return rci;
|
2018-01-19 15:02:02 +01:00
|
|
|
});
|
2017-11-20 11:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 08:24:47 +01:00
|
|
|
/*!
|
2020-06-12 07:05:08 +02:00
|
|
|
Adds a device type for which this RunConfigurationFactory
|
2018-03-19 13:18:27 +01:00
|
|
|
can create RunConfigurations.
|
2017-11-17 08:24:47 +01:00
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
If this function is never called for a RunConfigurationFactory,
|
|
|
|
|
the factory will create RunConfiguration objects for all device types.
|
|
|
|
|
|
|
|
|
|
This function should be used in the constructor of derived classes.
|
|
|
|
|
|
|
|
|
|
\sa addSupportedProjectType()
|
2017-11-17 08:24:47 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
void RunConfigurationFactory::addSupportedTargetDeviceType(Utils::Id id)
|
2018-02-22 08:36:45 +01:00
|
|
|
{
|
|
|
|
|
m_supportedTargetDeviceTypes.append(id);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 09:44:33 +01:00
|
|
|
void RunConfigurationFactory::setDecorateDisplayNames(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_decorateDisplayNames = on;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-12 07:05:08 +02:00
|
|
|
/*!
|
|
|
|
|
Adds a project type for which this RunConfigurationFactory
|
|
|
|
|
can create RunConfigurations.
|
|
|
|
|
|
|
|
|
|
If this function is never called for a RunConfigurationFactory,
|
|
|
|
|
the factory will create RunConfigurations for all project types.
|
|
|
|
|
|
|
|
|
|
This function should be used in the constructor of derived classes.
|
|
|
|
|
|
|
|
|
|
\sa addSupportedTargetDeviceType()
|
|
|
|
|
*/
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
void RunConfigurationFactory::addSupportedProjectType(Utils::Id id)
|
2017-12-08 14:50:57 +01:00
|
|
|
{
|
|
|
|
|
m_supportedProjectTypes.append(id);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-06 17:14:43 +01:00
|
|
|
bool RunConfigurationFactory::canHandle(Target *target) const
|
2017-11-17 08:24:47 +01:00
|
|
|
{
|
2017-12-08 14:50:57 +01:00
|
|
|
const Project *project = target->project();
|
|
|
|
|
Kit *kit = target->kit();
|
2017-11-17 08:24:47 +01:00
|
|
|
|
2018-04-18 13:39:05 +02:00
|
|
|
if (containsType(target->project()->projectIssues(kit), Task::TaskType::Error))
|
2017-11-17 08:24:47 +01:00
|
|
|
return false;
|
|
|
|
|
|
2017-12-08 14:50:57 +01:00
|
|
|
if (!m_supportedProjectTypes.isEmpty())
|
|
|
|
|
if (!m_supportedProjectTypes.contains(project->id()))
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-11-17 08:24:47 +01:00
|
|
|
if (!m_supportedTargetDeviceTypes.isEmpty())
|
|
|
|
|
if (!m_supportedTargetDeviceTypes.contains(
|
2019-02-06 12:50:51 +01:00
|
|
|
DeviceTypeKitAspect::deviceTypeId(kit)))
|
2017-11-17 08:24:47 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 17:49:33 +02:00
|
|
|
RunConfiguration *RunConfigurationFactory::create(Target *target) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_creator, return nullptr);
|
|
|
|
|
RunConfiguration *rc = m_creator(target);
|
|
|
|
|
QTC_ASSERT(rc, return nullptr);
|
|
|
|
|
|
|
|
|
|
// Add the universal aspects.
|
|
|
|
|
for (const RunConfiguration::AspectFactory &factory : theAspectFactories)
|
2023-05-22 13:30:11 +02:00
|
|
|
rc->registerAspect(factory(target));
|
2019-10-01 17:49:33 +02:00
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-08 12:39:03 +01:00
|
|
|
RunConfiguration *RunConfigurationCreationInfo::create(Target *target) const
|
2017-11-20 11:56:19 +01:00
|
|
|
{
|
2018-03-08 12:39:03 +01:00
|
|
|
QTC_ASSERT(factory->canHandle(target), return nullptr);
|
2018-03-19 13:18:27 +01:00
|
|
|
|
2019-10-01 17:49:33 +02:00
|
|
|
RunConfiguration *rc = factory->create(target);
|
2013-03-26 16:39:41 +01:00
|
|
|
if (!rc)
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
2013-03-26 16:39:41 +01:00
|
|
|
|
2018-04-09 12:33:10 +02:00
|
|
|
rc->m_buildKey = buildKey;
|
2019-12-17 10:28:20 +01:00
|
|
|
rc->update();
|
2019-01-31 18:23:10 +01:00
|
|
|
rc->setDisplayName(displayName);
|
2023-06-27 16:26:56 +02:00
|
|
|
rc->setPristineState();
|
2018-03-06 16:48:51 +01:00
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
return rc;
|
2017-11-20 11:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-06 17:14:43 +01:00
|
|
|
RunConfiguration *RunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
2018-02-27 09:08:01 +01:00
|
|
|
{
|
2022-10-07 14:46:06 +02:00
|
|
|
for (RunConfigurationFactory *factory : std::as_const(g_runConfigurationFactories)) {
|
2018-02-27 09:08:01 +01:00
|
|
|
if (factory->canHandle(parent)) {
|
2020-06-26 13:59:38 +02:00
|
|
|
const Utils::Id id = idFromMap(map);
|
2020-06-12 07:50:52 +02:00
|
|
|
if (id.name().startsWith(factory->m_runConfigurationId.name())) {
|
2019-10-01 17:49:33 +02:00
|
|
|
RunConfiguration *rc = factory->create(parent);
|
2023-07-21 18:23:50 +02:00
|
|
|
rc->fromMap(map);
|
|
|
|
|
if (!rc->hasError()) {
|
2020-02-18 15:55:19 +01:00
|
|
|
rc->update();
|
2023-06-27 16:26:56 +02:00
|
|
|
rc->setPristineState();
|
2018-02-27 09:08:01 +01:00
|
|
|
return rc;
|
2020-02-18 15:55:19 +01:00
|
|
|
}
|
2018-02-27 09:08:01 +01:00
|
|
|
delete rc;
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-28 14:53:12 +01:00
|
|
|
}
|
2018-02-27 09:08:01 +01:00
|
|
|
return nullptr;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-06 17:14:43 +01:00
|
|
|
RunConfiguration *RunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
2012-09-20 14:42:57 +02:00
|
|
|
{
|
2023-07-21 17:44:01 +02:00
|
|
|
QVariantMap map;
|
|
|
|
|
source->toMap(map);
|
|
|
|
|
return restore(parent, map);
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-08 12:39:03 +01:00
|
|
|
const QList<RunConfigurationCreationInfo> RunConfigurationFactory::creatorsForTarget(Target *parent)
|
|
|
|
|
{
|
|
|
|
|
QList<RunConfigurationCreationInfo> items;
|
2022-10-07 14:46:06 +02:00
|
|
|
for (RunConfigurationFactory *factory : std::as_const(g_runConfigurationFactories)) {
|
2018-03-08 12:39:03 +01:00
|
|
|
if (factory->canHandle(parent))
|
|
|
|
|
items.append(factory->availableCreators(parent));
|
|
|
|
|
}
|
2019-01-31 18:23:10 +01:00
|
|
|
QHash<QString, QList<RunConfigurationCreationInfo *>> itemsPerDisplayName;
|
|
|
|
|
for (RunConfigurationCreationInfo &item : items)
|
|
|
|
|
itemsPerDisplayName[item.displayName] << &item;
|
|
|
|
|
for (auto it = itemsPerDisplayName.cbegin(); it != itemsPerDisplayName.cend(); ++it) {
|
|
|
|
|
if (it.value().size() == 1)
|
|
|
|
|
continue;
|
|
|
|
|
for (RunConfigurationCreationInfo * const rci : it.value())
|
|
|
|
|
rci->displayName += rci->displayNameUniquifier;
|
|
|
|
|
}
|
2018-03-08 12:39:03 +01:00
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-19 15:02:02 +01:00
|
|
|
FixedRunConfigurationFactory::FixedRunConfigurationFactory(const QString &displayName,
|
2018-03-06 17:14:43 +01:00
|
|
|
bool addDeviceName) :
|
2018-02-14 10:25:47 +01:00
|
|
|
m_fixedBuildTarget(displayName),
|
|
|
|
|
m_decorateTargetName(addDeviceName)
|
2018-01-19 15:02:02 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QList<RunConfigurationCreationInfo>
|
2018-02-08 15:07:10 +01:00
|
|
|
FixedRunConfigurationFactory::availableCreators(Target *parent) const
|
2018-01-19 15:02:02 +01:00
|
|
|
{
|
2018-02-14 10:25:47 +01:00
|
|
|
QString displayName = m_decorateTargetName ? decoratedTargetName(m_fixedBuildTarget, parent)
|
|
|
|
|
: m_fixedBuildTarget;
|
2018-05-03 17:22:13 +02:00
|
|
|
RunConfigurationCreationInfo rci;
|
|
|
|
|
rci.factory = this;
|
|
|
|
|
rci.displayName = displayName;
|
|
|
|
|
return {rci};
|
2018-01-19 15:02:02 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
} // namespace ProjectExplorer
|