2009-03-20 14:57:12 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
#include "toolchain.h"
|
2011-03-24 13:27:26 +01:00
|
|
|
|
|
|
|
|
#include "toolchainmanager.h"
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <utils/environment.h>
|
2009-03-16 18:13:45 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QUuid>
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char ID_KEY[] = "ProjectExplorer.ToolChain.Id";
|
|
|
|
|
static const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ToolChain.DisplayName";
|
2011-12-19 12:06:44 +01:00
|
|
|
static const char AUTODETECT_KEY[] = "ProjectExplorer.ToolChain.Autodetect";
|
2012-02-07 17:22:05 +01:00
|
|
|
static const char MKSPEC_KEY[] = "ProjectExplorer.ToolChain.MkSpecOverride";
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QString mkspecListToString(const QList<Utils::FileName> &specList)
|
|
|
|
|
{
|
|
|
|
|
QStringList result;
|
|
|
|
|
foreach (const Utils::FileName &spec, specList)
|
|
|
|
|
result.append(spec.toString());
|
|
|
|
|
return result.join(QChar::fromLatin1(';'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<Utils::FileName> mkspecListFromString(const QString &string)
|
|
|
|
|
{
|
|
|
|
|
QList<Utils::FileName> result;
|
|
|
|
|
QStringList partList;
|
|
|
|
|
if (!string.isEmpty())
|
|
|
|
|
partList = string.split(QLatin1Char(';'));
|
|
|
|
|
foreach (const QString &part, partList)
|
|
|
|
|
result.append(Utils::FileName::fromString(part));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// ToolChainPrivate
|
|
|
|
|
// --------------------------------------------------------------------------
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
class ToolChainPrivate
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
public:
|
|
|
|
|
ToolChainPrivate(const QString &id, bool autodetect) :
|
|
|
|
|
m_autodetect(autodetect)
|
2011-12-19 12:06:44 +01:00
|
|
|
{
|
|
|
|
|
m_id = createId(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString createId(const QString &id)
|
|
|
|
|
{
|
2012-02-21 12:03:14 +01:00
|
|
|
QString newId = id.left(id.indexOf(':'));
|
|
|
|
|
newId.append(QLatin1Char(':') + QUuid::createUuid().toString());
|
2011-12-19 12:06:44 +01:00
|
|
|
return newId;
|
|
|
|
|
}
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString m_id;
|
|
|
|
|
bool m_autodetect;
|
|
|
|
|
mutable QString m_displayName;
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> m_mkspecList;
|
2011-02-01 18:36:00 +01:00
|
|
|
};
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace Internal
|
2009-03-16 18:13:45 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::ToolChain
|
|
|
|
|
\brief Representation of a ToolChain.
|
|
|
|
|
\sa ProjectExplorer::ToolChainManager
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain::ToolChain(const QString &id, bool autodetect) :
|
2011-09-07 14:26:11 +02:00
|
|
|
d(new Internal::ToolChainPrivate(id, autodetect))
|
2011-02-01 18:36:00 +01:00
|
|
|
{ }
|
2010-04-09 18:43:05 +02:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain::ToolChain(const ToolChain &other) :
|
2012-02-21 12:03:14 +01:00
|
|
|
d(new Internal::ToolChainPrivate(other.d->m_id, false))
|
2010-04-09 18:43:05 +02:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
// leave the autodetection bit at false.
|
2011-09-07 14:26:11 +02:00
|
|
|
d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
2011-03-03 16:46:51 +01:00
|
|
|
.arg(other.displayName());
|
2010-04-09 18:43:05 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain::~ToolChain()
|
2010-04-09 18:43:05 +02:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
delete d;
|
2010-04-09 18:43:05 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString ToolChain::displayName() const
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->m_displayName.isEmpty())
|
2012-01-30 11:55:21 +01:00
|
|
|
return typeDisplayName();
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->m_displayName;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 13:27:26 +01:00
|
|
|
void ToolChain::setDisplayName(const QString &name)
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->m_displayName == name)
|
2011-03-24 13:27:26 +01:00
|
|
|
return;
|
|
|
|
|
|
2011-09-07 14:26:11 +02:00
|
|
|
d->m_displayName = name;
|
2011-03-24 13:27:26 +01:00
|
|
|
toolChainUpdated();
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChain::isAutoDetected() const
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->m_autodetect;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString ToolChain::id() const
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
return d->m_id;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\brief Returns a list of target ids that this tool chain is restricted to.
|
|
|
|
|
|
|
|
|
|
An empty list is shows that the toolchain is compatible with all targets.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> ToolChain::restrictedToTargets() const
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>();
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> ToolChain::mkspecList() const
|
2012-02-07 17:22:05 +01:00
|
|
|
{
|
2012-02-07 18:05:09 +01:00
|
|
|
if (d->m_mkspecList.isEmpty())
|
|
|
|
|
return suggestedMkspecList();
|
|
|
|
|
return d->m_mkspecList;
|
2012-02-07 17:22:05 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
void ToolChain::setMkspecList(const QList<Utils::FileName> &specList)
|
2012-02-07 17:22:05 +01:00
|
|
|
{
|
2012-02-07 18:05:09 +01:00
|
|
|
QList<Utils::FileName> oldSpecList = mkspecList();
|
|
|
|
|
d->m_mkspecList = specList;
|
2012-02-07 17:22:05 +01:00
|
|
|
|
2012-02-07 18:05:09 +01:00
|
|
|
if (oldSpecList != mkspecList())
|
2012-02-07 17:22:05 +01:00
|
|
|
toolChainUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChain::canClone() const
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return true;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString ToolChain::defaultMakeTarget() const
|
2010-04-21 17:24:37 +02:00
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChain::operator == (const ToolChain &tc) const
|
2010-04-21 17:24:37 +02:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
if (this == &tc)
|
|
|
|
|
return true;
|
2010-09-08 15:22:58 +02:00
|
|
|
|
2011-12-19 12:06:44 +01:00
|
|
|
const QString thisId = id().left(id().indexOf(QLatin1Char(':')));
|
|
|
|
|
const QString tcId = tc.id().left(tc.id().indexOf(QLatin1Char(':')));
|
|
|
|
|
|
|
|
|
|
// We ignore displayname
|
|
|
|
|
return thisId == tcId && isAutoDetected() == tc.isAutoDetected();
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\brief Used by the toolchainmanager to save user-generated tool chains.
|
|
|
|
|
|
|
|
|
|
Make sure to call this method when deriving!
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QVariantMap ToolChain::toMap() const
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
QVariantMap result;
|
|
|
|
|
result.insert(QLatin1String(ID_KEY), id());
|
|
|
|
|
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
2011-12-19 12:06:44 +01:00
|
|
|
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
2012-02-07 18:05:09 +01:00
|
|
|
result.insert(QLatin1String(MKSPEC_KEY), mkspecListToString(d->m_mkspecList));
|
2010-03-04 15:23:02 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
return result;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-24 13:27:26 +01:00
|
|
|
void ToolChain::toolChainUpdated()
|
|
|
|
|
{
|
|
|
|
|
ToolChainManager::instance()->notifyAboutUpdate(this);
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-01 16:34:02 +01:00
|
|
|
void ToolChain::setAutoDetected(bool autodetect)
|
|
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
if (d->m_autodetect == autodetect)
|
2011-03-24 13:27:26 +01:00
|
|
|
return;
|
2011-09-07 14:26:11 +02:00
|
|
|
d->m_autodetect = autodetect;
|
2011-03-24 13:27:26 +01:00
|
|
|
toolChainUpdated();
|
2011-03-01 16:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\brief Used by the toolchainmanager to load user-generated tool chains.
|
|
|
|
|
|
|
|
|
|
Make sure to call this method when deriving!
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChain::fromMap(const QVariantMap &data)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-09-07 14:26:11 +02:00
|
|
|
d->m_displayName = data.value(QLatin1String(DISPLAY_NAME_KEY)).toString();
|
2011-12-19 12:06:44 +01:00
|
|
|
// make sure we have new style ids:
|
2012-02-21 12:03:14 +01:00
|
|
|
d->m_id = data.value(QLatin1String(ID_KEY)).toString();
|
2011-12-19 12:06:44 +01:00
|
|
|
d->m_autodetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool();
|
2012-02-07 18:05:09 +01:00
|
|
|
d->m_mkspecList = mkspecListFromString(data.value(QLatin1String(MKSPEC_KEY)).toString());
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
return true;
|
2009-12-09 13:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::ToolChainFactory
|
|
|
|
|
\brief Creates toolchains from settings or autodetects them.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QString ProjectExplorer::ToolChainFactory::displayName() const = 0
|
|
|
|
|
\brief Name used to display the name of the tool chain that will be created.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn bool ProjectExplorer::ToolChainFactory::canRestore(const QVariantMap &data)
|
|
|
|
|
\brief Used by the ToolChainManager to restore user-generated tool chains.
|
|
|
|
|
*/
|
2009-03-16 18:13:45 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QList<ToolChain *> ToolChainFactory::autoDetect()
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return QList<ToolChain *>();
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChainFactory::canCreate()
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return false;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain *ToolChainFactory::create()
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return 0;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
bool ToolChainFactory::canRestore(const QVariantMap &)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return false;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ToolChain *ToolChainFactory::restore(const QVariantMap &)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return 0;
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
QString ToolChainFactory::idFromMap(const QVariantMap &data)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2011-02-01 18:36:00 +01:00
|
|
|
return data.value(QLatin1String(ID_KEY)).toString();
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace ProjectExplorer
|