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"
|
2016-12-16 00:43:14 +01:00
|
|
|
#include "projectexplorerconstants.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";
|
2016-12-16 00:43:14 +01:00
|
|
|
static const char LANGUAGE_KEY_V1[] = "ProjectExplorer.ToolChain.Language"; // For QtCreator <= 4.2
|
|
|
|
|
static const char LANGUAGE_KEY_V2[] = "ProjectExplorer.ToolChain.LanguageV2"; // For QtCreator > 4.2
|
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:
|
2018-07-12 22:17:17 +02:00
|
|
|
using Detection = ToolChain::Detection;
|
2013-09-03 10:58:59 +02:00
|
|
|
|
2015-07-09 11:34:37 +02:00
|
|
|
explicit ToolChainPrivate(Core::Id typeId, Detection d) :
|
|
|
|
|
m_id(QUuid::createUuid().toByteArray()),
|
|
|
|
|
m_typeId(typeId),
|
2019-05-09 11:24:54 +02:00
|
|
|
m_detection(d),
|
|
|
|
|
m_predefinedMacrosCache(new ToolChain::MacrosCache::element_type()),
|
|
|
|
|
m_headerPathsCache(new ToolChain::HeaderPathsCache::element_type())
|
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;
|
2016-12-16 00:43:14 +01:00
|
|
|
QSet<Core::Id> m_supportedLanguages;
|
2016-04-13 15:52:14 +02:00
|
|
|
mutable QString m_displayName;
|
2015-07-09 11:34:37 +02:00
|
|
|
Core::Id m_typeId;
|
2016-12-16 00:43:14 +01:00
|
|
|
Core::Id m_language;
|
2013-09-03 10:58:59 +02:00
|
|
|
Detection m_detection;
|
2019-05-09 11:24:54 +02:00
|
|
|
|
|
|
|
|
ToolChain::MacrosCache m_predefinedMacrosCache;
|
|
|
|
|
ToolChain::HeaderPathsCache m_headerPathsCache;
|
2011-02-01 18:36:00 +01:00
|
|
|
};
|
2009-02-10 15:34:25 +01:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
|
|
|
|
|
// Deprecated used from QtCreator <= 4.2
|
|
|
|
|
|
|
|
|
|
Core::Id fromLanguageV1(int language)
|
|
|
|
|
{
|
|
|
|
|
switch (language)
|
|
|
|
|
{
|
|
|
|
|
case Deprecated::Toolchain::C :
|
|
|
|
|
return Core::Id(Constants::C_LANGUAGE_ID);
|
|
|
|
|
case Deprecated::Toolchain::Cxx:
|
|
|
|
|
return Core::Id(Constants::CXX_LANGUAGE_ID);
|
|
|
|
|
case Deprecated::Toolchain::None:
|
|
|
|
|
default:
|
|
|
|
|
return Core::Id();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace Internal
|
2009-03-16 18:13:45 +01:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
namespace Deprecated {
|
|
|
|
|
namespace Toolchain {
|
|
|
|
|
QString languageId(Language l)
|
|
|
|
|
{
|
|
|
|
|
switch (l) {
|
|
|
|
|
case Language::None:
|
|
|
|
|
return QStringLiteral("None");
|
|
|
|
|
case Language::C:
|
|
|
|
|
return QStringLiteral("C");
|
|
|
|
|
case Language::Cxx:
|
|
|
|
|
return QStringLiteral("Cxx");
|
|
|
|
|
};
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
} // namespace Toolchain
|
|
|
|
|
} // namespace Deprecated
|
|
|
|
|
|
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) :
|
2018-07-16 13:59:39 +02:00
|
|
|
d(std::make_unique<Internal::ToolChainPrivate>(typeId, d))
|
2016-07-12 10:22:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
2010-04-09 18:43:05 +02:00
|
|
|
|
2018-07-16 13:59:39 +02:00
|
|
|
ToolChain::ToolChain(const ToolChain &other) : ToolChain(other.d->m_typeId, ManualDetection)
|
2010-04-09 18:43:05 +02:00
|
|
|
{
|
2016-07-12 10:22:09 +02:00
|
|
|
d->m_language = other.d->m_language;
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
void ToolChain::setLanguage(Core::Id language)
|
2016-07-12 10:22:09 +02:00
|
|
|
{
|
2017-05-26 16:53:09 +03:00
|
|
|
QTC_ASSERT(!d->m_language.isValid() || isAutoDetected(), return);
|
2016-12-16 00:43:14 +01:00
|
|
|
QTC_ASSERT(language.isValid(), return);
|
|
|
|
|
QTC_ASSERT(ToolChainManager::isLanguageSupported(language), return);
|
2016-07-12 10:22:09 +02:00
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
d->m_language = language;
|
2016-07-12 10:22:09 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-16 13:59:39 +02:00
|
|
|
ToolChain::~ToolChain() = default;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-20 15:59:56 +02:00
|
|
|
QList<Abi> ToolChain::supportedAbis() const
|
|
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
return {targetAbi()};
|
2016-09-20 15:59:56 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
Core::Id ToolChain::language() const
|
2016-07-12 10:22:09 +02:00
|
|
|
{
|
|
|
|
|
return d->m_language;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2016-10-30 12:01:38 +02:00
|
|
|
return typeId() == tc.typeId()
|
|
|
|
|
&& isAutoDetected() == tc.isAutoDetected()
|
|
|
|
|
&& language() == tc.language();
|
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());
|
2017-03-14 12:27:57 +01:00
|
|
|
// <Compatibility with QtC 4.2>
|
|
|
|
|
int oldLanguageId = -1;
|
|
|
|
|
if (language() == ProjectExplorer::Constants::C_LANGUAGE_ID)
|
|
|
|
|
oldLanguageId = 1;
|
|
|
|
|
else if (language() == ProjectExplorer::Constants::CXX_LANGUAGE_ID)
|
|
|
|
|
oldLanguageId = 2;
|
|
|
|
|
if (oldLanguageId >= 0)
|
|
|
|
|
result.insert(LANGUAGE_KEY_V1, oldLanguageId);
|
|
|
|
|
// </Compatibility>
|
2016-12-16 00:43:14 +01:00
|
|
|
result.insert(QLatin1String(LANGUAGE_KEY_V2), language().toSetting());
|
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()
|
|
|
|
|
{
|
2019-05-09 11:24:54 +02:00
|
|
|
d->m_predefinedMacrosCache->invalidate();
|
|
|
|
|
d->m_headerPathsCache->invalidate();
|
|
|
|
|
|
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
|
|
|
|
2017-01-23 16:30:06 +01:00
|
|
|
if (data.contains(LANGUAGE_KEY_V2)) {
|
|
|
|
|
// remove hack to trim language id in 4.4: This is to fix up broken language
|
|
|
|
|
// ids that happened in 4.3 master branch
|
|
|
|
|
const QString langId = data.value(QLatin1String(LANGUAGE_KEY_V2)).toString();
|
|
|
|
|
const int pos = langId.lastIndexOf('.');
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
d->m_language = Core::Id::fromString(langId.mid(pos + 1));
|
|
|
|
|
else
|
|
|
|
|
d->m_language = Core::Id::fromString(langId);
|
|
|
|
|
} else if (data.contains(LANGUAGE_KEY_V1)) { // Import from old settings
|
2016-12-16 00:43:14 +01:00
|
|
|
d->m_language = Internal::fromLanguageV1(data.value(QLatin1String(LANGUAGE_KEY_V1)).toInt());
|
2017-01-23 16:30:06 +01:00
|
|
|
}
|
2016-12-16 00:43:14 +01:00
|
|
|
|
|
|
|
|
if (!d->m_language.isValid())
|
|
|
|
|
d->m_language = Core::Id(Constants::CXX_LANGUAGE_ID);
|
2016-07-12 10:22:09 +02:00
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
return true;
|
2009-12-09 13:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-09 11:24:54 +02:00
|
|
|
const ToolChain::HeaderPathsCache &ToolChain::headerPathsCache() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_headerPathsCache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ToolChain::MacrosCache &ToolChain::predefinedMacrosCache() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_predefinedMacrosCache;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-27 10:18:44 +02:00
|
|
|
static long toLanguageVersionAsLong(QByteArray dateAsByteArray)
|
|
|
|
|
{
|
|
|
|
|
dateAsByteArray.chop(1); // Strip 'L'.
|
2018-11-26 12:22:57 +01:00
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
const int result = dateAsByteArray.toLong(&success);
|
|
|
|
|
QTC_CHECK(success);
|
|
|
|
|
|
|
|
|
|
return result;
|
2018-09-27 10:18:44 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-09 18:31:20 +01:00
|
|
|
Utils::LanguageVersion ToolChain::cxxLanguageVersion(const QByteArray &cplusplusMacroValue)
|
2018-09-27 10:18:44 +02:00
|
|
|
{
|
2019-01-09 18:31:20 +01:00
|
|
|
using Utils::LanguageVersion;
|
2018-09-27 10:18:44 +02:00
|
|
|
const long version = toLanguageVersionAsLong(cplusplusMacroValue);
|
|
|
|
|
|
|
|
|
|
if (version > 201703L)
|
2018-10-08 09:49:02 +02:00
|
|
|
return LanguageVersion::LatestCxx;
|
2018-10-09 09:16:26 +02:00
|
|
|
if (version > 201402L)
|
|
|
|
|
return LanguageVersion::CXX17;
|
|
|
|
|
if (version > 201103L)
|
|
|
|
|
return LanguageVersion::CXX14;
|
|
|
|
|
if (version == 201103L)
|
|
|
|
|
return LanguageVersion::CXX11;
|
|
|
|
|
|
|
|
|
|
return LanguageVersion::CXX03;
|
2018-09-27 10:18:44 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-09 18:31:20 +01:00
|
|
|
Utils::LanguageVersion ToolChain::languageVersion(const Core::Id &language, const Macros ¯os)
|
2018-09-27 10:18:44 +02:00
|
|
|
{
|
2019-01-09 18:31:20 +01:00
|
|
|
using Utils::LanguageVersion;
|
|
|
|
|
|
2018-09-27 10:18:44 +02:00
|
|
|
if (language == Constants::CXX_LANGUAGE_ID) {
|
|
|
|
|
for (const ProjectExplorer::Macro ¯o : macros) {
|
|
|
|
|
if (macro.key == "__cplusplus") // Check for the C++ identifying macro
|
|
|
|
|
return cxxLanguageVersion(macro.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTC_CHECK(false && "__cplusplus is not predefined, assuming latest C++ we support.");
|
2018-10-08 09:49:02 +02:00
|
|
|
return LanguageVersion::LatestCxx;
|
2018-09-27 10:18:44 +02:00
|
|
|
} else if (language == Constants::C_LANGUAGE_ID) {
|
|
|
|
|
for (const ProjectExplorer::Macro ¯o : macros) {
|
|
|
|
|
if (macro.key == "__STDC_VERSION__") {
|
|
|
|
|
const long version = toLanguageVersionAsLong(macro.value);
|
|
|
|
|
|
|
|
|
|
if (version > 201710L)
|
2018-10-08 09:49:02 +02:00
|
|
|
return LanguageVersion::LatestC;
|
2018-10-09 09:16:26 +02:00
|
|
|
if (version > 201112L)
|
|
|
|
|
return LanguageVersion::C18;
|
|
|
|
|
if (version > 199901L)
|
|
|
|
|
return LanguageVersion::C11;
|
|
|
|
|
if (version > 199409L)
|
|
|
|
|
return LanguageVersion::C99;
|
|
|
|
|
|
|
|
|
|
return LanguageVersion::C89;
|
2018-09-27 10:18:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The __STDC_VERSION__ macro was introduced after C89.
|
|
|
|
|
// We haven't seen it, so it must be C89.
|
|
|
|
|
return LanguageVersion::C89;
|
|
|
|
|
} else {
|
|
|
|
|
QTC_CHECK(false && "Unexpected toolchain language, assuming latest C++ we support.");
|
2018-10-08 09:49:02 +02:00
|
|
|
return LanguageVersion::LatestCxx;
|
2018-09-27 10:18:44 +02: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>();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-07 12:15:40 +01:00
|
|
|
QString ToolChain::sysRoot() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2017-12-08 17:20:48 +01:00
|
|
|
static QList<ToolChainFactory *> g_toolChainFactories;
|
|
|
|
|
|
|
|
|
|
ToolChainFactory::ToolChainFactory()
|
|
|
|
|
{
|
|
|
|
|
g_toolChainFactories.append(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolChainFactory::~ToolChainFactory()
|
|
|
|
|
{
|
|
|
|
|
g_toolChainFactories.removeOne(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QList<ToolChainFactory *> ToolChainFactory::allToolChainFactories()
|
|
|
|
|
{
|
|
|
|
|
return g_toolChainFactories;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2017-02-07 13:13:06 +01:00
|
|
|
QList<ToolChain *> ToolChainFactory::autoDetect(const Utils::FileName &compilerPath, const Core::Id &language)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(compilerPath);
|
|
|
|
|
Q_UNUSED(language);
|
|
|
|
|
return QList<ToolChain *>();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *ToolChainFactory::create(Core::Id l)
|
2009-02-10 15:34:25 +01:00
|
|
|
{
|
2016-07-12 15:08:53 +02:00
|
|
|
Q_UNUSED(l);
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
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
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
return nullptr;
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 15:36:57 +02:00
|
|
|
QSet<Core::Id> ToolChainFactory::supportedLanguages() const
|
|
|
|
|
{
|
|
|
|
|
return m_supportsAllLanguages ? ToolChainManager::allLanguages() : m_supportedLanguages;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 14:56:26 +02:00
|
|
|
Core::Id ToolChainFactory::supportedToolChainType() const
|
|
|
|
|
{
|
|
|
|
|
return m_supportedToolChainType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolChainFactory::setSupportedToolChainType(const Core::Id &supportedToolChain)
|
|
|
|
|
{
|
|
|
|
|
m_supportedToolChainType = supportedToolChain;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 15:36:57 +02:00
|
|
|
void ToolChainFactory::setSupportedLanguages(const QSet<Core::Id> &supportedLanguages)
|
|
|
|
|
{
|
|
|
|
|
m_supportedLanguages = supportedLanguages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ToolChainFactory::setSupportsAllLanguages(bool supportsAllLanguages)
|
|
|
|
|
{
|
|
|
|
|
m_supportsAllLanguages = supportsAllLanguages;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
} // namespace ProjectExplorer
|