forked from qt-creator/qt-creator
ToolChain: Introduce typeId() and shorten id()
Split up the toolchain id() into a part that is unique per type of toolchain and call that typeId(). Leave the part that is unique per toolchain in id(). Add some mapping code for compatibility old settings. Change-Id: I770881b3274ac5224edc8165b484fec6b0d4d2c6 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -47,11 +47,11 @@ namespace ProjectExplorer {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
|
||||||
AbstractMsvcToolChain::AbstractMsvcToolChain(const QByteArray &id,
|
AbstractMsvcToolChain::AbstractMsvcToolChain(Core::Id typeId,
|
||||||
Detection d,
|
Detection d,
|
||||||
const Abi &abi,
|
const Abi &abi,
|
||||||
const QString& vcvarsBat) :
|
const QString& vcvarsBat) :
|
||||||
ToolChain(id, d),
|
ToolChain(typeId, d),
|
||||||
m_lastEnvironment(Utils::Environment::systemEnvironment()),
|
m_lastEnvironment(Utils::Environment::systemEnvironment()),
|
||||||
m_abi(abi),
|
m_abi(abi),
|
||||||
m_vcvarsBat(vcvarsBat)
|
m_vcvarsBat(vcvarsBat)
|
||||||
@@ -62,8 +62,8 @@ AbstractMsvcToolChain::AbstractMsvcToolChain(const QByteArray &id,
|
|||||||
Q_ASSERT(!m_vcvarsBat.isEmpty());
|
Q_ASSERT(!m_vcvarsBat.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractMsvcToolChain::AbstractMsvcToolChain(const QByteArray &id, Detection d) :
|
AbstractMsvcToolChain::AbstractMsvcToolChain(Core::Id typeId, Detection d) :
|
||||||
ToolChain(id, d),
|
ToolChain(typeId, d),
|
||||||
m_lastEnvironment(Utils::Environment::systemEnvironment())
|
m_lastEnvironment(Utils::Environment::systemEnvironment())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@@ -44,8 +44,8 @@ namespace Internal {
|
|||||||
class PROJECTEXPLORER_EXPORT AbstractMsvcToolChain : public ToolChain
|
class PROJECTEXPLORER_EXPORT AbstractMsvcToolChain : public ToolChain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AbstractMsvcToolChain(const QByteArray &id, Detection d, const Abi &abi, const QString& vcvarsBat);
|
explicit AbstractMsvcToolChain(Core::Id typeId, Detection d, const Abi &abi, const QString& vcvarsBat);
|
||||||
explicit AbstractMsvcToolChain(const QByteArray &id, Detection d);
|
explicit AbstractMsvcToolChain(Core::Id typeId, Detection d);
|
||||||
|
|
||||||
Abi targetAbi() const override;
|
Abi targetAbi() const override;
|
||||||
|
|
||||||
|
@@ -248,8 +248,8 @@ GccToolChain::GccToolChain(Detection d) :
|
|||||||
ToolChain(Constants::GCC_TOOLCHAIN_ID, d)
|
ToolChain(Constants::GCC_TOOLCHAIN_ID, d)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
GccToolChain::GccToolChain(const QByteArray &id, Detection d) :
|
GccToolChain::GccToolChain(Core::Id typeId, Detection d) :
|
||||||
ToolChain(id, d)
|
ToolChain(typeId, d)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void GccToolChain::setCompilerCommand(const FileName &path)
|
void GccToolChain::setCompilerCommand(const FileName &path)
|
||||||
|
@@ -57,7 +57,7 @@ class LinuxIccToolChainFactory;
|
|||||||
class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
|
class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GccToolChain(const QByteArray &id, Detection d);
|
GccToolChain(Core::Id typeId, Detection d);
|
||||||
QString type() const override;
|
QString type() const override;
|
||||||
QString typeDisplayName() const override;
|
QString typeDisplayName() const override;
|
||||||
Abi targetAbi() const override;
|
Abi targetAbi() const override;
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@@ -56,20 +57,14 @@ class ToolChainPrivate
|
|||||||
public:
|
public:
|
||||||
typedef ToolChain::Detection Detection;
|
typedef ToolChain::Detection Detection;
|
||||||
|
|
||||||
explicit ToolChainPrivate(const QByteArray &id, Detection d) :
|
explicit ToolChainPrivate(Core::Id typeId, Detection d) :
|
||||||
|
m_id(QUuid::createUuid().toByteArray()),
|
||||||
|
m_typeId(typeId),
|
||||||
m_detection(d)
|
m_detection(d)
|
||||||
{
|
{ }
|
||||||
m_id = createId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QByteArray createId(const QByteArray &id)
|
|
||||||
{
|
|
||||||
QByteArray newId = id.left(id.indexOf(':'));
|
|
||||||
newId.append(':' + QUuid::createUuid().toByteArray());
|
|
||||||
return newId;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray m_id;
|
QByteArray m_id;
|
||||||
|
Core::Id m_typeId;
|
||||||
Detection m_detection;
|
Detection m_detection;
|
||||||
mutable QString m_displayName;
|
mutable QString m_displayName;
|
||||||
};
|
};
|
||||||
@@ -84,12 +79,12 @@ public:
|
|||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
ToolChain::ToolChain(const QByteArray &id, Detection d) :
|
ToolChain::ToolChain(Core::Id typeId, Detection d) :
|
||||||
d(new Internal::ToolChainPrivate(id, d))
|
d(new Internal::ToolChainPrivate(typeId, d))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ToolChain::ToolChain(const ToolChain &other) :
|
ToolChain::ToolChain(const ToolChain &other) :
|
||||||
d(new Internal::ToolChainPrivate(other.d->m_id, ManualDetection))
|
d(new Internal::ToolChainPrivate(other.d->m_typeId, ManualDetection))
|
||||||
{
|
{
|
||||||
// leave the autodetection bit at false.
|
// leave the autodetection bit at false.
|
||||||
d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
||||||
@@ -137,6 +132,11 @@ Utils::FileName ToolChain::suggestedDebugger() const
|
|||||||
return ToolChainManager::defaultDebugger(targetAbi());
|
return ToolChainManager::defaultDebugger(targetAbi());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core::Id ToolChain::typeId() const
|
||||||
|
{
|
||||||
|
return d->m_typeId;
|
||||||
|
}
|
||||||
|
|
||||||
bool ToolChain::canClone() const
|
bool ToolChain::canClone() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -147,11 +147,8 @@ bool ToolChain::operator == (const ToolChain &tc) const
|
|||||||
if (this == &tc)
|
if (this == &tc)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QByteArray thisId = id().left(id().indexOf(':'));
|
|
||||||
const QByteArray tcId = tc.id().left(tc.id().indexOf(':'));
|
|
||||||
|
|
||||||
// We ignore displayname
|
// We ignore displayname
|
||||||
return thisId == tcId && isAutoDetected() == tc.isAutoDetected();
|
return typeId() == tc.typeId() && isAutoDetected() == tc.isAutoDetected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -163,7 +160,8 @@ bool ToolChain::operator == (const ToolChain &tc) const
|
|||||||
QVariantMap ToolChain::toMap() const
|
QVariantMap ToolChain::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
result.insert(QLatin1String(ID_KEY), QString::fromUtf8(id()));
|
QString idToSave = d->m_typeId.toString() + QLatin1Char(':') + QString::fromUtf8(id());
|
||||||
|
result.insert(QLatin1String(ID_KEY), idToSave);
|
||||||
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
||||||
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
||||||
|
|
||||||
@@ -192,8 +190,14 @@ void ToolChain::setDetection(ToolChain::Detection de)
|
|||||||
bool ToolChain::fromMap(const QVariantMap &data)
|
bool ToolChain::fromMap(const QVariantMap &data)
|
||||||
{
|
{
|
||||||
d->m_displayName = data.value(QLatin1String(DISPLAY_NAME_KEY)).toString();
|
d->m_displayName = data.value(QLatin1String(DISPLAY_NAME_KEY)).toString();
|
||||||
|
|
||||||
// make sure we have new style ids:
|
// make sure we have new style ids:
|
||||||
d->m_id = data.value(QLatin1String(ID_KEY)).toByteArray();
|
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));
|
||||||
|
d->m_id = id.mid(pos).toUtf8();
|
||||||
|
|
||||||
const bool autoDetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool();
|
const bool autoDetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool();
|
||||||
d->m_detection = autoDetect ? AutoDetectionFromSettings : ManualDetection;
|
d->m_detection = autoDetect ? AutoDetectionFromSettings : ManualDetection;
|
||||||
|
|
||||||
@@ -262,11 +266,6 @@ QByteArray ToolChainFactory::idFromMap(const QVariantMap &data)
|
|||||||
return data.value(QLatin1String(ID_KEY)).toByteArray();
|
return data.value(QLatin1String(ID_KEY)).toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChainFactory::idToMap(QVariantMap &data, const QString id)
|
|
||||||
{
|
|
||||||
data.insert(QLatin1String(ID_KEY), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected)
|
void ToolChainFactory::autoDetectionToMap(QVariantMap &data, bool detected)
|
||||||
{
|
{
|
||||||
data.insert(QLatin1String(AUTODETECT_KEY), detected);
|
data.insert(QLatin1String(AUTODETECT_KEY), detected);
|
||||||
|
@@ -83,6 +83,7 @@ public:
|
|||||||
virtual Utils::FileName suggestedDebugger() const;
|
virtual Utils::FileName suggestedDebugger() const;
|
||||||
|
|
||||||
virtual QString type() const = 0;
|
virtual QString type() const = 0;
|
||||||
|
Core::Id typeId() const;
|
||||||
virtual QString typeDisplayName() const = 0;
|
virtual QString typeDisplayName() const = 0;
|
||||||
virtual Abi targetAbi() const = 0;
|
virtual Abi targetAbi() const = 0;
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ public:
|
|||||||
virtual QVariantMap toMap() const;
|
virtual QVariantMap toMap() const;
|
||||||
virtual QList<Task> validateKit(const Kit *k) const;
|
virtual QList<Task> validateKit(const Kit *k) const;
|
||||||
protected:
|
protected:
|
||||||
explicit ToolChain(const QByteArray &id, Detection d);
|
explicit ToolChain(Core::Id typeId, Detection d);
|
||||||
explicit ToolChain(const ToolChain &);
|
explicit ToolChain(const ToolChain &);
|
||||||
|
|
||||||
void toolChainUpdated();
|
void toolChainUpdated();
|
||||||
@@ -191,7 +192,6 @@ public:
|
|||||||
virtual ToolChain *restore(const QVariantMap &data);
|
virtual ToolChain *restore(const QVariantMap &data);
|
||||||
|
|
||||||
static QByteArray idFromMap(const QVariantMap &data);
|
static QByteArray idFromMap(const QVariantMap &data);
|
||||||
static void idToMap(QVariantMap &data, const QString id);
|
|
||||||
static void autoDetectionToMap(QVariantMap &data, bool detected);
|
static void autoDetectionToMap(QVariantMap &data, bool detected);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -299,7 +299,19 @@ ToolChain *ToolChainManager::findToolChain(const QByteArray &id)
|
|||||||
if (id.isEmpty())
|
if (id.isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return Utils::findOrDefault(d->m_toolChains, Utils::equal(&ToolChain::id, id));
|
ToolChain *tc = Utils::findOrDefault(d->m_toolChains, Utils::equal(&ToolChain::id, id));
|
||||||
|
|
||||||
|
// Compatibility with versions 3.5 and earlier:
|
||||||
|
if (!tc) {
|
||||||
|
const int pos = id.indexOf(':');
|
||||||
|
if (pos < 0)
|
||||||
|
return tc;
|
||||||
|
|
||||||
|
const QByteArray shortId = id.mid(pos + 1);
|
||||||
|
|
||||||
|
tc = Utils::findOrDefault(d->m_toolChains, Utils::equal(&ToolChain::id, shortId));
|
||||||
|
}
|
||||||
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileName ToolChainManager::defaultDebugger(const Abi &abi)
|
FileName ToolChainManager::defaultDebugger(const Abi &abi)
|
||||||
|
Reference in New Issue
Block a user