Commit a4a1c67a authored by Friedemann Kleint's avatar Friedemann Kleint Committed by Tobias Hunger

MSVC toolchains: Make it possible to clone and save it.

In order to switch debuggers.

Change-Id: I1e8ceaf5b145715ab1ea803e7bb188a3cff5f1c6
Reviewed-on: http://codereview.qt.nokia.com/1536Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 2ebb5137
......@@ -55,7 +55,11 @@
#include <QtGui/QFormLayout>
#include <QtGui/QDesktopServices>
static const char debuggerCommandKeyC[] = "ProjectExplorer.MsvcToolChain.Debugger";
#define KEY_ROOT "ProjectExplorer.MsvcToolChain."
static const char debuggerCommandKeyC[] = KEY_ROOT"Debugger";
static const char varsBatKeyC[] = KEY_ROOT"VarsBat";
static const char varsBatArgKeyC[] = KEY_ROOT"VarsBatArg";
static const char supportedAbiKeyC[] = KEY_ROOT"SupportedAbi";
enum { debug = 0 };
......@@ -352,12 +356,38 @@ MsvcToolChain::MsvcToolChain(const QString &name, const Abi &abi,
Q_ASSERT(abi.binaryFormat() == Abi::PEFormat);
Q_ASSERT(abi.osFlavor() != Abi::WindowsMSysFlavor);
setId(QString::fromLatin1("%1:%2.%3.%4").arg(Constants::MSVC_TOOLCHAIN_ID).arg(m_varsBat)
.arg(m_varsBatArg).arg(m_debuggerCommand));
updateId();
setDisplayName(name);
}
MsvcToolChain::MsvcToolChain() :
ToolChain(QLatin1String(Constants::MSVC_TOOLCHAIN_ID), false),
m_lastEnvironment(Utils::Environment::systemEnvironment())
{
}
MsvcToolChain *MsvcToolChain::readFromMap(const QVariantMap &data)
{
MsvcToolChain *tc = new MsvcToolChain;
if (tc->fromMap(data))
return tc;
delete tc;
return 0;
}
void MsvcToolChain::updateId()
{
const QChar colon = QLatin1Char(':');
QString id = QLatin1String(Constants::MSVC_TOOLCHAIN_ID);
id += colon;
id += m_varsBat;
id += colon;
id += m_varsBatArg;
id += colon;
id += m_debuggerCommand;
setId(id);
}
QString MsvcToolChain::typeName() const
{
return MsvcToolChainFactory::tr("MSVC");
......@@ -438,6 +468,7 @@ void MsvcToolChain::setDebuggerCommand(const QString &d)
if (m_debuggerCommand == d)
return;
m_debuggerCommand = d;
updateId();
toolChainUpdated();
}
......@@ -449,7 +480,12 @@ QString MsvcToolChain::debuggerCommand() const
QVariantMap MsvcToolChain::toMap() const
{
QVariantMap data = ToolChain::toMap();
data.insert(QLatin1String(debuggerCommandKeyC), m_debuggerCommand);
if (!m_debuggerCommand.isEmpty())
data.insert(QLatin1String(debuggerCommandKeyC), m_debuggerCommand);
data.insert(QLatin1String(varsBatKeyC), m_varsBat);
if (!m_varsBatArg.isEmpty())
data.insert(QLatin1String(varsBatArgKeyC), m_varsBatArg);
data.insert(QLatin1String(supportedAbiKeyC), m_abi.toString());
return data;
}
......@@ -457,9 +493,13 @@ bool MsvcToolChain::fromMap(const QVariantMap &data)
{
if (!ToolChain::fromMap(data))
return false;
m_debuggerCommand= data.value(QLatin1String(debuggerCommandKeyC)).toString();
return true;
m_varsBat = data.value(QLatin1String(varsBatKeyC)).toString();
m_varsBatArg = data.value(QLatin1String(varsBatArgKeyC)).toString();
m_debuggerCommand = data.value(QLatin1String(debuggerCommandKeyC)).toString();
const QString abiString = data.value(QLatin1String(supportedAbiKeyC)).toString();
m_abi = Abi(abiString);
updateId();
return !m_varsBat.isEmpty() && m_abi.isValid();
}
IOutputParser *MsvcToolChain::outputParser() const
......@@ -758,5 +798,10 @@ QString MsvcToolChain::autoDetectCdbDebugger(QStringList *checkedDirectories /*
return QString();
}
bool MsvcToolChainFactory::canRestore(const QVariantMap &data)
{
return idFromMap(data).startsWith(QLatin1String(Constants::MSVC_TOOLCHAIN_ID) + QLatin1Char(':'));
}
} // namespace Internal
} // namespace ProjectExplorer
......@@ -57,6 +57,8 @@ public:
MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg, bool autodetect = false);
static MsvcToolChain *readFromMap(const QVariantMap &data);
QString typeName() const;
Abi targetAbi() const;
......@@ -82,6 +84,9 @@ public:
static QString autoDetectCdbDebugger(QStringList *checkedDirectories = 0);
private:
MsvcToolChain();
void updateId();
QString m_varsBat; // Script to setup environment
QString m_varsBatArg; // Argument
QString m_debuggerCommand;
......@@ -106,6 +111,10 @@ public:
QList<ToolChain *> autoDetect();
virtual bool canRestore(const QVariantMap &data);
virtual ToolChain *restore(const QVariantMap &data)
{ return MsvcToolChain::readFromMap(data); }
ToolChainConfigWidget *configurationWidget(ToolChain *);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment