2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01: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 "buildmanager.h"
|
|
|
|
|
#include "buildsteplist.h"
|
|
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
|
2010-03-11 17:47:09 +01:00
|
|
|
#include <QtCore/QProcess>
|
|
|
|
|
|
2009-09-21 15:50:27 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
namespace {
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
const char * const BUILD_STEP_LIST_COUNT("ProjectExplorer.BuildConfiguration.BuildStepListCount");
|
|
|
|
|
const char * const BUILD_STEP_LIST_PREFIX("ProjectExplorer.BuildConfiguration.BuildStepList.");
|
2010-03-11 17:47:09 +01:00
|
|
|
const char * const CLEAR_SYSTEM_ENVIRONMENT_KEY("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment");
|
|
|
|
|
const char * const USER_ENVIRONMENT_CHANGES_KEY("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges");
|
2010-01-18 12:11:04 +01:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration::BuildConfiguration(Target *target, const QString &id) :
|
2010-07-16 14:00:41 +02:00
|
|
|
ProjectConfiguration(target, id),
|
2010-03-11 17:47:09 +01:00
|
|
|
m_clearSystemEnvironment(false)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
|
|
|
|
BuildStepList *bsl = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_BUILD));
|
|
|
|
|
//: Display name of the build build step list. Used as part of the labels in the project window.
|
|
|
|
|
bsl->setDisplayName(tr("Build"));
|
|
|
|
|
m_stepLists.append(bsl);
|
|
|
|
|
bsl = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_CLEAN));
|
|
|
|
|
//: Display name of the clean build step list. Used as part of the labels in the project window.
|
|
|
|
|
bsl->setDisplayName(tr("Clean"));
|
|
|
|
|
m_stepLists.append(bsl);
|
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),
|
|
|
|
|
m_userEnvironmentChanges(source->m_userEnvironmentChanges)
|
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!
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration::~BuildConfiguration()
|
2010-07-16 14:00:41 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
QStringList BuildConfiguration::knownStepLists() const
|
2009-10-27 14:16:28 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
QStringList result;
|
|
|
|
|
foreach (BuildStepList *list, m_stepLists)
|
|
|
|
|
result.append(list->id());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepList *BuildConfiguration::stepList(const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
foreach (BuildStepList *list, m_stepLists)
|
|
|
|
|
if (id == list->id())
|
|
|
|
|
return list;
|
|
|
|
|
return 0;
|
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);
|
|
|
|
|
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
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)
|
|
|
|
|
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-02-08 15:50:06 +01:00
|
|
|
if (!ProjectConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-03-11 17:47:09 +01:00
|
|
|
m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool();
|
|
|
|
|
m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
|
|
|
|
|
|
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) {
|
|
|
|
|
QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) % QString::number(i)).toMap();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
m_stepLists.append(list);
|
|
|
|
|
}
|
2010-04-13 15:04:21 +02:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
// TODO: We currently assume there to be at least a clean, build and deploy list!
|
|
|
|
|
Q_ASSERT(knownStepLists().contains(QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_BUILD)));
|
|
|
|
|
Q_ASSERT(knownStepLists().contains(QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_CLEAN)));
|
2010-04-13 15:04:21 +02:00
|
|
|
|
|
|
|
|
return true;
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
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-03-11 17:47:09 +01:00
|
|
|
Environment BuildConfiguration::baseEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
if (useSystemEnvironment())
|
|
|
|
|
return Environment(QProcess::systemEnvironment());
|
|
|
|
|
return Environment();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BuildConfiguration::baseEnvironmentText() const
|
|
|
|
|
{
|
|
|
|
|
if (useSystemEnvironment())
|
|
|
|
|
return tr("System Environment");
|
|
|
|
|
else
|
|
|
|
|
return tr("Clean Environment");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Environment BuildConfiguration::environment() const
|
|
|
|
|
{
|
|
|
|
|
Environment env = baseEnvironment();
|
|
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfiguration::setUseSystemEnvironment(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (useSystemEnvironment() == b)
|
|
|
|
|
return;
|
|
|
|
|
m_clearSystemEnvironment = !b;
|
|
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BuildConfiguration::useSystemEnvironment() const
|
|
|
|
|
{
|
|
|
|
|
return !m_clearSystemEnvironment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<EnvironmentItem> BuildConfiguration::userEnvironmentChanges() const
|
|
|
|
|
{
|
|
|
|
|
return m_userEnvironmentChanges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
|
|
|
|
|
{
|
|
|
|
|
if (m_userEnvironmentChanges == diff)
|
|
|
|
|
return;
|
|
|
|
|
m_userEnvironmentChanges = diff;
|
|
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildConfiguration::cloneSteps(BuildConfiguration *source)
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_stepLists);
|
|
|
|
|
m_stepLists.clear();
|
|
|
|
|
foreach (BuildStepList *bsl, source->m_stepLists) {
|
|
|
|
|
BuildStepList *newBsl = new BuildStepList(this, bsl);
|
|
|
|
|
m_stepLists.append(newBsl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{ }
|