2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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 "buildconfiguration.h"
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "buildsteplist.h"
|
|
|
|
|
#include "projectexplorer.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitmanager.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "target.h"
|
2010-09-22 15:14:07 +02:00
|
|
|
#include "project.h"
|
2012-10-16 16:19:40 +02:00
|
|
|
#include "kit.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2012-11-08 16:13:31 +01:00
|
|
|
#include <projectexplorer/buildenvironmentwidget.h>
|
2014-10-22 09:16:55 +02:00
|
|
|
#include <projectexplorer/projectmacroexpander.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2014-10-06 13:15:40 +02:00
|
|
|
#include <coreplugin/idocument.h>
|
2010-11-12 17:23:55 +01:00
|
|
|
|
2011-12-19 12:06:44 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2014-10-15 14:45:31 +02:00
|
|
|
#include <utils/macroexpander.h>
|
2014-06-06 13:12:47 +02:00
|
|
|
#include <utils/algorithm.h>
|
2011-08-18 13:46:52 +02:00
|
|
|
|
2013-08-01 10:52:55 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
static const char BUILD_STEP_LIST_COUNT[] = "ProjectExplorer.BuildConfiguration.BuildStepListCount";
|
|
|
|
|
static const char BUILD_STEP_LIST_PREFIX[] = "ProjectExplorer.BuildConfiguration.BuildStepList.";
|
|
|
|
|
static const char CLEAR_SYSTEM_ENVIRONMENT_KEY[] = "ProjectExplorer.BuildConfiguration.ClearSystemEnvironment";
|
|
|
|
|
static const char USER_ENVIRONMENT_CHANGES_KEY[] = "ProjectExplorer.BuildConfiguration.UserEnvironmentChanges";
|
2013-08-16 17:45:16 +02:00
|
|
|
static const char BUILDDIRECTORY_KEY[] = "ProjectExplorer.BuildConfiguration.BuildDirectory";
|
2009-09-21 15:50:27 +02:00
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
namespace ProjectExplorer {
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
BuildConfiguration::BuildConfiguration(Target *target, Core::Id id) :
|
2010-07-16 14:00:41 +02:00
|
|
|
ProjectConfiguration(target, id),
|
2014-10-22 18:16:51 +02:00
|
|
|
m_clearSystemEnvironment(false)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *bsl = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_BUILD));
|
2010-07-16 14:00:41 +02:00
|
|
|
//: Display name of the build build step list. Used as part of the labels in the project window.
|
2010-08-19 12:26:21 +02:00
|
|
|
bsl->setDefaultDisplayName(tr("Build"));
|
2010-07-16 14:00:41 +02:00
|
|
|
m_stepLists.append(bsl);
|
2012-03-15 17:17:40 +01:00
|
|
|
bsl = new BuildStepList(this, Core::Id(Constants::BUILDSTEPS_CLEAN));
|
2010-07-16 14:00:41 +02:00
|
|
|
//: Display name of the clean build step list. Used as part of the labels in the project window.
|
2010-08-19 12:26:21 +02:00
|
|
|
bsl->setDefaultDisplayName(tr("Clean"));
|
2010-07-16 14:00:41 +02:00
|
|
|
m_stepLists.append(bsl);
|
2011-03-24 11:58:40 +01:00
|
|
|
|
2013-04-19 13:19:46 +02:00
|
|
|
emitEnvironmentChanged();
|
|
|
|
|
|
2012-10-17 15:43:18 +02:00
|
|
|
connect(target, SIGNAL(kitChanged()),
|
|
|
|
|
this, SLOT(handleKitUpdate()));
|
2013-08-16 17:45:16 +02:00
|
|
|
connect(this, SIGNAL(environmentChanged()), this, SLOT(emitBuildDirectoryChanged()));
|
2014-11-05 14:01:26 +01:00
|
|
|
|
2014-11-05 15:45:56 +01:00
|
|
|
ctor();
|
2009-12-08 12:21:11 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) :
|
2010-07-16 14:00:41 +02:00
|
|
|
ProjectConfiguration(target, source),
|
2010-03-11 17:47:09 +01:00
|
|
|
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
|
2010-11-12 17:23:55 +01:00
|
|
|
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
|
2013-08-16 17:45:16 +02:00
|
|
|
m_buildDirectory(source->m_buildDirectory)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
|
|
|
|
// Do not clone stepLists here, do that in the derived constructor instead
|
|
|
|
|
// otherwise BuildStepFactories might reject to set up a BuildStep for us
|
|
|
|
|
// since we are not yet the derived class!
|
2011-03-24 11:58:40 +01:00
|
|
|
|
2013-04-19 13:19:46 +02:00
|
|
|
emitEnvironmentChanged();
|
|
|
|
|
|
2012-10-17 15:43:18 +02:00
|
|
|
connect(target, SIGNAL(kitChanged()),
|
|
|
|
|
this, SLOT(handleKitUpdate()));
|
2014-10-22 18:16:51 +02:00
|
|
|
|
2014-11-05 15:45:56 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfiguration::ctor()
|
|
|
|
|
{
|
|
|
|
|
Utils::MacroExpander *expander = macroExpander();
|
|
|
|
|
expander->setDisplayName(tr("Build Settings"));
|
|
|
|
|
expander->setAccumulating(true);
|
|
|
|
|
expander->registerSubProvider([this] { return target()->macroExpander(); });
|
|
|
|
|
|
|
|
|
|
expander->registerVariable("buildDir", tr("Build directory"),
|
|
|
|
|
[this] { return buildDirectory().toUserOutput(); });
|
|
|
|
|
|
|
|
|
|
expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer", "Name of current build"),
|
|
|
|
|
[this] { return displayName(); }, false);
|
2014-10-22 18:16:51 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
BuildConfiguration::~BuildConfiguration()
|
2011-08-18 13:46:52 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-16 17:45:16 +02:00
|
|
|
Utils::FileName BuildConfiguration::buildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
QString path = QDir::cleanPath(environment().expandVariables(m_buildDirectory.toString()));
|
2014-05-02 12:53:36 +02:00
|
|
|
return Utils::FileName::fromString(QDir::cleanPath(QDir(target()->project()->projectDirectory().toString()).absoluteFilePath(path)));
|
2013-08-16 17:45:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::FileName BuildConfiguration::rawBuildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfiguration::setBuildDirectory(const Utils::FileName &dir)
|
|
|
|
|
{
|
|
|
|
|
m_buildDirectory = dir;
|
|
|
|
|
emitBuildDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-08 18:02:50 +01:00
|
|
|
QList<NamedWidget *> BuildConfiguration::createSubConfigWidgets()
|
2012-11-08 16:10:34 +01:00
|
|
|
{
|
2014-10-13 22:37:28 +03:00
|
|
|
return QList<NamedWidget *>() << new BuildEnvironmentWidget(this);
|
2012-11-08 16:10:34 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> BuildConfiguration::knownStepLists() const
|
2009-10-27 14:16:28 +01:00
|
|
|
{
|
2014-07-07 19:02:26 +02:00
|
|
|
return Utils::transform(m_stepLists, &BuildStepList::id);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStepList *BuildConfiguration::stepList(Core::Id id) const
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
2014-07-10 12:57:06 +02:00
|
|
|
return Utils::findOrDefault(m_stepLists, Utils::equal(&BuildStepList::id, id));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap BuildConfiguration::toMap() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap map(ProjectConfiguration::toMap());
|
2010-03-11 17:47:09 +01:00
|
|
|
map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), m_clearSystemEnvironment);
|
2010-09-23 10:35:23 +02:00
|
|
|
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), Utils::EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
2013-08-16 17:45:16 +02:00
|
|
|
map.insert(QLatin1String(BUILDDIRECTORY_KEY), m_buildDirectory.toString());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), m_stepLists.count());
|
|
|
|
|
for (int i = 0; i < m_stepLists.count(); ++i)
|
2010-08-02 14:29:32 +02:00
|
|
|
map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) + QString::number(i), m_stepLists.at(i)->toMap());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
return map;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-18 12:11:04 +01:00
|
|
|
|
|
|
|
|
bool BuildConfiguration::fromMap(const QVariantMap &map)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-11 17:47:09 +01:00
|
|
|
m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool();
|
2010-09-23 10:35:23 +02:00
|
|
|
m_userEnvironmentChanges = Utils::EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
|
2013-08-16 17:45:16 +02:00
|
|
|
m_buildDirectory = Utils::FileName::fromString(map.value(QLatin1String(BUILDDIRECTORY_KEY)).toString());
|
2010-03-11 17:47:09 +01:00
|
|
|
|
2013-04-19 13:19:46 +02:00
|
|
|
emitEnvironmentChanged();
|
2012-10-17 15:55:20 +02:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
qDeleteAll(m_stepLists);
|
|
|
|
|
m_stepLists.clear();
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
int maxI = map.value(QLatin1String(BUILD_STEP_LIST_COUNT), 0).toInt();
|
|
|
|
|
for (int i = 0; i < maxI; ++i) {
|
2010-08-02 14:29:32 +02:00
|
|
|
QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) + QString::number(i)).toMap();
|
2010-07-16 14:00:41 +02:00
|
|
|
if (data.isEmpty()) {
|
|
|
|
|
qWarning() << "No data for build step list" << i << "found!";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
BuildStepList *list = new BuildStepList(this, data);
|
|
|
|
|
if (list->isNull()) {
|
|
|
|
|
qWarning() << "Failed to restore build step list" << i;
|
|
|
|
|
delete list;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-08-03 15:24:33 +02:00
|
|
|
if (list->id() == Constants::BUILDSTEPS_BUILD)
|
2011-11-22 09:57:27 +01:00
|
|
|
list->setDefaultDisplayName(tr("Build"));
|
2012-08-03 15:24:33 +02:00
|
|
|
else if (list->id() == Constants::BUILDSTEPS_CLEAN)
|
2011-11-22 09:57:27 +01:00
|
|
|
list->setDefaultDisplayName(tr("Clean"));
|
2010-07-16 14:00:41 +02:00
|
|
|
m_stepLists.append(list);
|
|
|
|
|
}
|
2010-04-13 15:04:21 +02:00
|
|
|
|
2012-05-03 17:05:38 +02:00
|
|
|
// We currently assume there to be at least a clean and build list!
|
2014-10-13 22:37:28 +03:00
|
|
|
QTC_CHECK(knownStepLists().contains(Core::Id(Constants::BUILDSTEPS_BUILD)));
|
|
|
|
|
QTC_CHECK(knownStepLists().contains(Core::Id(Constants::BUILDSTEPS_CLEAN)));
|
2010-04-13 15:04:21 +02:00
|
|
|
|
2010-08-19 12:26:21 +02:00
|
|
|
return ProjectConfiguration::fromMap(map);
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 15:55:20 +02:00
|
|
|
void BuildConfiguration::emitEnvironmentChanged()
|
|
|
|
|
{
|
2013-04-19 13:19:46 +02:00
|
|
|
Utils::Environment env = baseEnvironment();
|
|
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
if (env == m_cachedEnvironment)
|
|
|
|
|
return;
|
|
|
|
|
m_cachedEnvironment = env;
|
2013-08-16 17:45:16 +02:00
|
|
|
emit environmentChanged(); // might trigger buildDirectoryChanged signal!
|
2012-10-17 15:55:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-17 15:43:18 +02:00
|
|
|
void BuildConfiguration::handleKitUpdate()
|
2011-03-24 14:35:03 +01:00
|
|
|
{
|
2012-10-17 15:55:20 +02:00
|
|
|
emitEnvironmentChanged();
|
2011-03-24 14:35:03 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-16 17:45:16 +02:00
|
|
|
void BuildConfiguration::emitBuildDirectoryChanged()
|
|
|
|
|
{
|
|
|
|
|
if (buildDirectory() != m_lastEmmitedBuildDirectory) {
|
|
|
|
|
m_lastEmmitedBuildDirectory = buildDirectory();
|
|
|
|
|
emit buildDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *BuildConfiguration::target() const
|
2009-11-23 13:29:45 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Target *>(parent());
|
2009-11-23 13:29:45 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment BuildConfiguration::baseEnvironment() const
|
2010-03-11 17:47:09 +01:00
|
|
|
{
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment result;
|
2013-11-29 16:29:13 +01:00
|
|
|
if (useSystemEnvironment())
|
2012-04-30 19:01:26 +02:00
|
|
|
result = Utils::Environment::systemEnvironment();
|
2012-10-16 16:19:40 +02:00
|
|
|
target()->kit()->addToEnvironment(result);
|
2015-01-27 18:46:40 +01:00
|
|
|
addToEnvironment(result);
|
2010-09-22 15:14:07 +02:00
|
|
|
return result;
|
2010-03-11 17:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BuildConfiguration::baseEnvironmentText() const
|
|
|
|
|
{
|
|
|
|
|
if (useSystemEnvironment())
|
|
|
|
|
return tr("System Environment");
|
|
|
|
|
else
|
|
|
|
|
return tr("Clean Environment");
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment BuildConfiguration::environment() const
|
2010-03-11 17:47:09 +01:00
|
|
|
{
|
2013-04-19 13:19:46 +02:00
|
|
|
return m_cachedEnvironment;
|
2010-03-11 17:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfiguration::setUseSystemEnvironment(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (useSystemEnvironment() == b)
|
|
|
|
|
return;
|
|
|
|
|
m_clearSystemEnvironment = !b;
|
2012-10-17 15:55:20 +02:00
|
|
|
emitEnvironmentChanged();
|
2010-03-11 17:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-27 18:46:40 +01:00
|
|
|
void BuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(env);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-11 17:47:09 +01:00
|
|
|
bool BuildConfiguration::useSystemEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
return !m_clearSystemEnvironment;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
QList<Utils::EnvironmentItem> BuildConfiguration::userEnvironmentChanges() const
|
2010-03-11 17:47:09 +01:00
|
|
|
{
|
|
|
|
|
return m_userEnvironmentChanges;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
void BuildConfiguration::setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff)
|
2010-03-11 17:47:09 +01:00
|
|
|
{
|
|
|
|
|
if (m_userEnvironmentChanges == diff)
|
|
|
|
|
return;
|
|
|
|
|
m_userEnvironmentChanges = diff;
|
2012-10-17 15:55:20 +02:00
|
|
|
emitEnvironmentChanged();
|
2010-03-11 17:47:09 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildConfiguration::cloneSteps(BuildConfiguration *source)
|
|
|
|
|
{
|
2012-09-12 17:28:05 +02:00
|
|
|
if (source == this)
|
|
|
|
|
return;
|
2010-07-16 14:00:41 +02:00
|
|
|
qDeleteAll(m_stepLists);
|
|
|
|
|
m_stepLists.clear();
|
|
|
|
|
foreach (BuildStepList *bsl, source->m_stepLists) {
|
|
|
|
|
BuildStepList *newBsl = new BuildStepList(this, bsl);
|
2010-08-30 12:25:27 +02:00
|
|
|
newBsl->cloneSteps(bsl);
|
2010-07-16 14:00:41 +02:00
|
|
|
m_stepLists.append(newBsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
bool BuildConfiguration::isEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-26 15:56:36 +02:00
|
|
|
QString BuildConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
///
|
|
|
|
|
// IBuildConfigurationFactory
|
|
|
|
|
///
|
2009-09-24 16:02:02 +02:00
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
IBuildConfigurationFactory::IBuildConfigurationFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|
2009-09-24 16:02:02 +02:00
|
|
|
|
|
|
|
|
IBuildConfigurationFactory::~IBuildConfigurationFactory()
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|
2011-08-18 13:46:52 +02:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
// restore
|
2012-04-24 15:49:09 +02:00
|
|
|
IBuildConfigurationFactory *IBuildConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
2015-01-27 18:46:40 +01:00
|
|
|
QList<IBuildConfigurationFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>(
|
|
|
|
|
[&parent, map](IBuildConfigurationFactory *factory) {
|
|
|
|
|
return factory->canRestore(parent, map);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
IBuildConfigurationFactory *factory = 0;
|
|
|
|
|
int priority = -1;
|
|
|
|
|
foreach (IBuildConfigurationFactory *i, factories) {
|
|
|
|
|
int iPriority = i->priority(parent);
|
|
|
|
|
if (iPriority > priority) {
|
|
|
|
|
factory = i;
|
|
|
|
|
priority = iPriority;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return factory;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-13 10:52:57 +02:00
|
|
|
// setup
|
|
|
|
|
IBuildConfigurationFactory *IBuildConfigurationFactory::find(Kit *k, const QString &projectPath)
|
|
|
|
|
{
|
|
|
|
|
QList<IBuildConfigurationFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::instance()->getObjects<IBuildConfigurationFactory>();
|
2014-06-19 14:05:40 +02:00
|
|
|
IBuildConfigurationFactory *factory = 0;
|
|
|
|
|
int priority = -1;
|
|
|
|
|
foreach (IBuildConfigurationFactory *i, factories) {
|
|
|
|
|
int iPriority = i->priority(k, projectPath);
|
|
|
|
|
if (iPriority > priority) {
|
|
|
|
|
factory = i;
|
|
|
|
|
priority = iPriority;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return factory;
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
// create
|
2012-04-24 15:49:09 +02:00
|
|
|
IBuildConfigurationFactory * IBuildConfigurationFactory::find(Target *parent)
|
|
|
|
|
{
|
|
|
|
|
QList<IBuildConfigurationFactory *> factories
|
2014-06-19 14:05:40 +02:00
|
|
|
= ExtensionSystem::PluginManager::instance()->getObjects<IBuildConfigurationFactory>();
|
|
|
|
|
IBuildConfigurationFactory *factory = 0;
|
|
|
|
|
int priority = -1;
|
|
|
|
|
foreach (IBuildConfigurationFactory *i, factories) {
|
|
|
|
|
int iPriority = i->priority(parent);
|
|
|
|
|
if (iPriority > priority) {
|
|
|
|
|
factory = i;
|
|
|
|
|
priority = iPriority;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return factory;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
// clone
|
|
|
|
|
IBuildConfigurationFactory *IBuildConfigurationFactory::find(Target *parent, BuildConfiguration *bc)
|
|
|
|
|
{
|
2015-01-27 18:46:40 +01:00
|
|
|
QList<IBuildConfigurationFactory *> factories
|
|
|
|
|
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>(
|
|
|
|
|
[&parent, &bc](IBuildConfigurationFactory *factory) {
|
|
|
|
|
return factory->canClone(parent, bc);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
IBuildConfigurationFactory *factory = 0;
|
|
|
|
|
int priority = -1;
|
|
|
|
|
foreach (IBuildConfigurationFactory *i, factories) {
|
|
|
|
|
int iPriority = i->priority(parent);
|
|
|
|
|
if (iPriority > priority) {
|
|
|
|
|
factory = i;
|
|
|
|
|
priority = iPriority;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return factory;
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
2011-08-18 13:46:52 +02:00
|
|
|
} // namespace ProjectExplorer
|