2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-20 14:57:12 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-20 14:57:12 +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.
|
2009-03-20 14:57:12 +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
|
|
|
****************************************************************************/
|
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
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "abi.h"
|
2013-03-25 17:13:18 +01:00
|
|
|
#include "headerpath.h"
|
2011-03-24 13:27:26 +01:00
|
|
|
#include "toolchainmanager.h"
|
2013-03-21 12:27:18 +01:00
|
|
|
#include "task.h"
|
2011-03-24 13:27:26 +01:00
|
|
|
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <utils/fileutils.h>
|
2015-07-09 11:34:37 +02:00
|
|
|
#include <utils/qtcassert.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 18:05:09 +01:00
|
|
|
|
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:
|
2013-09-03 10:58:59 +02:00
|
|
|
typedef ToolChain::Detection Detection;
|
|
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
explicit ToolChainPrivate(Core::Id typeId, Detection d) :
|
|
|
|
|
m_id(QUuid::createUuid().toByteArray()),
|
|
|
|
|
m_typeId(typeId),
|
2013-09-03 10:58:59 +02:00
|
|
|
m_detection(d)
|
2015-07-07 15:37:50 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_typeId.isValid(), return);
|
|
|
|
|
QTC_ASSERT(!m_typeId.toString().contains(QLatin1Char(':')), return);
|
|
|
|
|
}
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2015-07-07 12:01:22 +02:00
|
|
|
QByteArray m_id;
|
2015-07-09 11:34:37 +02:00
|
|
|
Core::Id m_typeId;
|
2013-09-03 10:58:59 +02:00
|
|
|
Detection m_detection;
|
2011-02-01 18:36:00 +01:00
|
|
|
mutable QString m_displayName;
|
|
|
|
|
};
|
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
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The ToolChain class represents a tool chain.
|
2011-04-14 12:58:14 +02:00
|
|
|
\sa ProjectExplorer::ToolChainManager
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
ToolChain::ToolChain(Core::Id typeId, Detection d) :
|
|
|
|
|
d(new Internal::ToolChainPrivate(typeId, d))
|
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) :
|
2015-07-09 11:34:37 +02:00
|
|
|
d(new Internal::ToolChainPrivate(other.d->m_typeId, ManualDetection))
|
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
|
|
|
}
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
ToolChain::Detection ToolChain::detection() const
|
2010-03-04 15:23:02 +01:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
return d->m_detection;
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2015-07-07 12:01:22 +02:00
|
|
|
QByteArray 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
|
|
|
}
|
|
|
|
|
|
2015-11-03 14:01:25 +01:00
|
|
|
Utils::FileNameList ToolChain::suggestedMkspecList() const
|
2013-03-25 17:13:18 +01:00
|
|
|
{
|
2015-11-03 14:01:25 +01:00
|
|
|
return Utils::FileNameList();
|
2013-03-25 17:13:18 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-05 09:21:15 +02:00
|
|
|
Utils::FileName ToolChain::suggestedDebugger() const
|
2012-02-07 17:22:05 +01:00
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
return ToolChainManager::defaultDebugger(targetAbi());
|
2012-02-07 17:22:05 +01:00
|
|
|
}
|
|
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
Core::Id ToolChain::typeId() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_typeId;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
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
|
|
|
// We ignore displayname
|
2015-07-09 11:34:37 +02:00
|
|
|
return typeId() == tc.typeId() && isAutoDetected() == tc.isAutoDetected();
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Used by the tool chain manager to save user-generated tool chains.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-10-07 13:34:40 +02:00
|
|
|
Make sure to call this function when deriving.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
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;
|
2015-07-09 11:34:37 +02:00
|
|
|
QString idToSave = d->m_typeId.toString() + QLatin1Char(':') + QString::fromUtf8(id());
|
|
|
|
|
result.insert(QLatin1String(ID_KEY), idToSave);
|
2011-02-01 18:36:00 +01:00
|
|
|
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
2011-12-19 12:06:44 +01:00
|
|
|
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
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()
|
|
|
|
|
{
|
2013-08-29 13:14:19 +02:00
|
|
|
ToolChainManager::notifyAboutUpdate(this);
|
2010-03-04 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
void ToolChain::setDetection(ToolChain::Detection de)
|
2011-03-01 16:34:02 +01:00
|
|
|
{
|
2013-09-03 10:58:59 +02:00
|
|
|
if (d->m_detection == de)
|
2011-03-24 13:27:26 +01:00
|
|
|
return;
|
2013-09-03 10:58:59 +02:00
|
|
|
d->m_detection = de;
|
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
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Used by the tool chain manager to load user-generated tool chains.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-10-07 13:34:40 +02:00
|
|
|
Make sure to call this function when deriving.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
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();
|
2015-07-09 11:34:37 +02:00
|
|
|
|
2011-12-19 12:06:44 +01:00
|
|
|
// make sure we have new style ids:
|
2015-07-09 11:34:37 +02:00
|
|
|
const QString id = data.value(QLatin1String(ID_KEY)).toString();
|
|
|
|
|
int pos = id.indexOf(QLatin1Char(':'));
|
|
|
|
|
QTC_ASSERT(pos > 0, return false);
|
|
|
|
|
d->m_typeId = Core::Id::fromString(id.left(pos));
|
2015-07-14 11:12:14 +02:00
|
|
|
d->m_id = id.mid(pos + 1).toUtf8();
|
2015-07-09 11:34:37 +02:00
|
|
|
|
2013-09-03 10:58:59 +02:00
|
|
|
const bool autoDetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool();
|
|
|
|
|
d->m_detection = autoDetect ? AutoDetectionFromSettings : ManualDetection;
|
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
|
|
|
}
|
|
|
|
|
|
2013-03-21 12:27:18 +01:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Used by the tool chain kit information to validate the kit.
|
2013-03-21 12:27:18 +01:00
|
|
|
*/
|
|
|
|
|
|
2013-03-25 14:55:32 +02:00
|
|
|
QList<Task> ToolChain::validateKit(const Kit *) const
|
2013-03-21 12:27:18 +01:00
|
|
|
{
|
|
|
|
|
return QList<Task>();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::ToolChainFactory
|
2013-09-10 17:16:10 +02:00
|
|
|
\brief The ToolChainFactory class creates tool chains from settings or
|
|
|
|
|
autodetects them.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QString ProjectExplorer::ToolChainFactory::displayName() const = 0
|
2013-09-10 17:16:10 +02:00
|
|
|
Contains the name used to display the name of the tool chain that will be
|
|
|
|
|
created.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2013-03-03 21:53:38 +04:00
|
|
|
/*!
|
|
|
|
|
\fn QStringList ProjectExplorer::ToolChain::clangParserFlags(const QStringList &cxxflags) const = 0
|
2013-09-10 17:16:10 +02:00
|
|
|
Converts tool chain specific flags to list flags that tune the libclang
|
|
|
|
|
parser.
|
2013-03-03 21:53:38 +04:00
|
|
|
*/
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\fn bool ProjectExplorer::ToolChainFactory::canRestore(const QVariantMap &data)
|
2013-09-10 17:16:10 +02:00
|
|
|
Used by the tool chain manager to restore user-generated tool chains.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
2009-03-16 18:13:45 +01:00
|
|
|
|
2015-07-19 10:59:06 +03:00
|
|
|
QList<ToolChain *> ToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2015-07-19 10:59:06 +03:00
|
|
|
Q_UNUSED(alreadyKnown);
|
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
|
|
|
}
|
|
|
|
|
|
2015-07-07 14:20:12 +02:00
|
|
|
static QPair<QString, QString> rawIdData(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
const QString raw = data.value(QLatin1String(ID_KEY)).toString();
|
|
|
|
|
const int pos = raw.indexOf(QLatin1Char(':'));
|
|
|
|
|
QTC_ASSERT(pos > 0, return qMakePair(QString::fromLatin1("unknown"), QString::fromLatin1("unknown")));
|
|
|
|
|
return qMakePair(raw.mid(0, pos), raw.mid(pos + 1));
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 12:01:22 +02:00
|
|
|
QByteArray ToolChainFactory::idFromMap(const QVariantMap &data)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2015-07-07 14:20:12 +02:00
|
|
|
return rawIdData(data).second.toUtf8();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id ToolChainFactory::typeIdFromMap(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
return Core::Id::fromString(rawIdData(data).first);
|
2009-02-10 15:34:25 +01:00
|
|
|
}
|
|
|
|
|
|
2012-06-20 15:45:37 +02:00
|
|
|
void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected)
|
|
|
|
|
{
|
|
|
|
|
data.insert(QLatin1String(AUTODETECT_KEY), detected);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace ProjectExplorer
|