Commit b4942447 authored by Tobias Hunger's avatar Tobias Hunger

Toolchain: Allow overriding of detected mkspec

Change-Id: I258a5a9dce400b256b7243fe9c5f3038822f1692
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 73c32586
......@@ -84,11 +84,6 @@ QString MaemoToolChain::typeDisplayName() const
return MaemoToolChainFactory::tr("Maemo GCC");
}
Utils::FileName MaemoToolChain::mkspec() const
{
return Utils::FileName(); // always use default
}
bool MaemoToolChain::isValid() const
{
return GccToolChain::isValid() && m_qtVersionId >= 0 && targetAbi().isValid();
......
......@@ -50,7 +50,6 @@ public:
QString type() const;
QString typeDisplayName() const;
Utils::FileName mkspec() const;
bool isValid() const;
bool canClone() const;
......
......@@ -406,7 +406,7 @@ Utils::FileName GccToolChain::debuggerCommand() const
return m_debuggerCommand;
}
Utils::FileName GccToolChain::mkspec() const
Utils::FileName GccToolChain::suggestedMkspec() const
{
Abi abi = targetAbi();
Abi host = Abi::hostAbi();
......@@ -681,6 +681,7 @@ Internal::GccToolChainConfigWidget::GccToolChainConfigWidget(GccToolChain *tc) :
m_abiWidget->setEnabled(false);
addDebuggerCommandControls(layout, gnuVersionArgs);
addMkspecControls(layout);
addErrorLabel(layout);
setFromToolchain();
......@@ -701,6 +702,7 @@ void Internal::GccToolChainConfigWidget::apply()
tc->setTargetAbi(m_abiWidget->currentAbi());
tc->setDisplayName(displayName); // reset display name
tc->setDebuggerCommand(debuggerCommand());
tc->setMkspec(mkspec());
m_autoDebuggerCommand = Utils::FileName::fromString(QLatin1String("<manually set>"));
}
......@@ -714,6 +716,7 @@ void Internal::GccToolChainConfigWidget::setFromToolchain()
if (!m_isReadOnly && !m_compilerCommand->path().isEmpty())
m_abiWidget->setEnabled(true);
setDebuggerCommand(tc->debuggerCommand());
setMkspec(tc->mkspec());
blockSignals(blocked);
}
......@@ -723,7 +726,8 @@ bool Internal::GccToolChainConfigWidget::isDirty() const
Q_ASSERT(tc);
return m_compilerCommand->fileName() != tc->compilerCommand()
|| m_abiWidget->currentAbi() != tc->targetAbi()
|| debuggerCommand() != tc->debuggerCommand();
|| debuggerCommand() != tc->debuggerCommand()
|| mkspec() != tc->mkspec();
}
void Internal::GccToolChainConfigWidget::makeReadOnly()
......@@ -788,7 +792,7 @@ QString ClangToolChain::makeCommand() const
#endif
}
Utils::FileName ClangToolChain::mkspec() const
Utils::FileName ClangToolChain::suggestedMkspec() const
{
Abi abi = targetAbi();
if (abi.os() == Abi::MacOS)
......@@ -876,7 +880,7 @@ QString MingwToolChain::typeDisplayName() const
return Internal::MingwToolChainFactory::tr("MinGW");
}
Utils::FileName MingwToolChain::mkspec() const
Utils::FileName MingwToolChain::suggestedMkspec() const
{
#if defined(Q_OS_WIN)
return Utils::FileName::fromString(QLatin1String("win32-g++"));
......@@ -988,7 +992,7 @@ IOutputParser *LinuxIccToolChain::outputParser() const
return new LinuxIccParser;
}
Utils::FileName LinuxIccToolChain::mkspec() const
Utils::FileName LinuxIccToolChain::suggestedMkspec() const
{
return Utils::FileName::fromString(QLatin1String("linux-icc-") + QString::number(targetAbi().wordWidth()));
}
......
......@@ -68,10 +68,10 @@ public:
QByteArray predefinedMacros() const;
QList<HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
Utils::FileName mkspec() const;
QString makeCommand() const;
void setDebuggerCommand(const Utils::FileName &);
Utils::FileName debuggerCommand() const;
Utils::FileName suggestedMkspec() const;
IOutputParser *outputParser() const;
QVariantMap toMap() const;
......@@ -124,12 +124,13 @@ public:
QString type() const;
QString typeDisplayName() const;
QString makeCommand() const;
Utils::FileName mkspec() const;
IOutputParser *outputParser() const;
ToolChain *clone() const;
Utils::FileName suggestedMkspec() const;
private:
ClangToolChain(bool autodetect);
......@@ -146,11 +147,12 @@ class PROJECTEXPLORER_EXPORT MingwToolChain : public GccToolChain
public:
QString type() const;
QString typeDisplayName() const;
Utils::FileName mkspec() const;
QString makeCommand() const;
ToolChain *clone() const;
Utils::FileName suggestedMkspec() const;
private:
MingwToolChain(bool autodetect);
......@@ -170,10 +172,10 @@ public:
IOutputParser *outputParser() const;
Utils::FileName mkspec() const;
ToolChain *clone() const;
Utils::FileName suggestedMkspec() const;
private:
LinuxIccToolChain(bool autodetect);
......
......@@ -328,7 +328,7 @@ QString MsvcToolChain::typeDisplayName() const
return MsvcToolChainFactory::tr("MSVC");
}
Utils::FileName MsvcToolChain::mkspec() const
Utils::FileName MsvcToolChain::suggestedMkspec() const
{
if (m_abi.osFlavor() == Abi::WindowsMsvc2005Flavor)
return Utils::FileName::fromString(QLatin1String("win32-msvc2005"));
......@@ -426,6 +426,7 @@ MsvcToolChainConfigWidget::MsvcToolChainConfigWidget(ToolChain *tc) :
formLayout->addRow(new MsvcDebuggerConfigLabel);
addDebuggerCommandControls(formLayout, QStringList(QLatin1String("-version")));
addDebuggerAutoDetection(this, SLOT(autoDetectDebugger()));
addMkspecControls(formLayout);
addErrorLabel(formLayout);
setFromToolChain();
}
......@@ -435,6 +436,7 @@ void MsvcToolChainConfigWidget::apply()
MsvcToolChain *tc = static_cast<MsvcToolChain *>(toolChain());
QTC_ASSERT(tc, return; );
tc->setDebuggerCommand(debuggerCommand());
tc->setMkspec(mkspec());
}
void MsvcToolChainConfigWidget::setFromToolChain()
......@@ -448,13 +450,15 @@ void MsvcToolChainConfigWidget::setFromToolChain()
}
m_varsBatDisplayLabel->setText(varsBatDisplay);
setDebuggerCommand(tc->debuggerCommand());
setMkspec(tc->mkspec());
}
bool MsvcToolChainConfigWidget::isDirty() const
{
MsvcToolChain *tc = static_cast<MsvcToolChain *>(toolChain());
QTC_ASSERT(tc, return false);
return debuggerCommand() != tc->debuggerCommand();
return debuggerCommand() != tc->debuggerCommand()
|| mkspec() != tc->mkspec();
}
void MsvcToolChainConfigWidget::autoDetectDebugger()
......
......@@ -57,12 +57,12 @@ public:
MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg, bool autodetect = false);
QString legacyId() const;
Utils::FileName suggestedMkspec() const;
static MsvcToolChain *readFromMap(const QVariantMap &data);
QString type() const;
QString typeDisplayName() const;
Utils::FileName mkspec() const;
QVariantMap toMap() const;
bool fromMap(const QVariantMap &data);
......
......@@ -43,6 +43,7 @@
static const char ID_KEY[] = "ProjectExplorer.ToolChain.Id";
static const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ToolChain.DisplayName";
static const char AUTODETECT_KEY[] = "ProjectExplorer.ToolChain.Autodetect";
static const char MKSPEC_KEY[] = "ProjectExplorer.ToolChain.MkSpecOverride";
namespace ProjectExplorer {
namespace Internal {
......@@ -75,6 +76,7 @@ public:
QString m_id;
bool m_autodetect;
mutable QString m_displayName;
Utils::FileName m_mkspec;
};
} // namespace Internal
......@@ -141,6 +143,22 @@ QStringList ToolChain::restrictedToTargets() const
return QStringList();
}
Utils::FileName ToolChain::mkspec() const
{
if (d->m_mkspec.isEmpty())
return suggestedMkspec();
return d->m_mkspec;
}
void ToolChain::setMkspec(const Utils::FileName &spec)
{
Utils::FileName oldSpecs = mkspec();
d->m_mkspec = spec;
if (oldSpecs != mkspec())
toolChainUpdated();
}
bool ToolChain::canClone() const
{
return true;
......@@ -175,6 +193,7 @@ QVariantMap ToolChain::toMap() const
result.insert(QLatin1String(ID_KEY), id());
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
result.insert(QLatin1String(MKSPEC_KEY), d->m_mkspec.toString());
return result;
}
......@@ -204,6 +223,7 @@ bool ToolChain::fromMap(const QVariantMap &data)
// make sure we have new style ids:
d->m_id = Internal::ToolChainPrivate::createId(data.value(QLatin1String(ID_KEY)).toString());
d->m_autodetect = data.value(QLatin1String(AUTODETECT_KEY), false).toBool();
d->m_mkspec = Utils::FileName::fromString(data.value(QLatin1String(MKSPEC_KEY)).toString());
return true;
}
......
......@@ -88,7 +88,9 @@ public:
virtual void addToEnvironment(Utils::Environment &env) const = 0;
virtual QString makeCommand() const = 0;
virtual Utils::FileName mkspec() const = 0;
Utils::FileName mkspec() const;
void setMkspec(const Utils::FileName &mkspec);
virtual Utils::FileName suggestedMkspec() const { return Utils::FileName(); }
virtual Utils::FileName compilerCommand() const = 0;
virtual Utils::FileName debuggerCommand() const = 0;
......
......@@ -36,9 +36,34 @@
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <QtCore/QString>
#include <QtGui/QFormLayout>
#include <QtGui/QGridLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
namespace {
const char DEFAULT_MKSPEC[] = "default";
Utils::FileName mkspecFromString(const QString &spec)
{
if (spec == QLatin1String(DEFAULT_MKSPEC))
return Utils::FileName();
else
return Utils::FileName::fromUserInput(spec);
}
QString mkspecToString(const Utils::FileName spec)
{
if (spec.isEmpty())
return QLatin1String(DEFAULT_MKSPEC);
else
return spec.toUserOutput();
}
} // namespace
namespace ProjectExplorer {
namespace Internal {
......@@ -51,14 +76,21 @@ class ToolChainConfigWidgetPrivate
{
public:
ToolChainConfigWidgetPrivate(ToolChain *tc) :
m_toolChain(tc), m_debuggerPathChooser(0), m_errorLabel(0)
m_toolChain(tc), m_debuggerPathChooser(0),
m_mkspecLayout(0), m_mkspecEdit(0), m_mkspecResetButton(0), m_mkspecEdited(false),
m_errorLabel(0)
{
Q_ASSERT(tc);
QTC_CHECK(tc);
}
ToolChain *m_toolChain;
Utils::PathChooser *m_debuggerPathChooser;
QHBoxLayout *m_mkspecLayout;
QLineEdit *m_mkspecEdit;
QPushButton *m_mkspecResetButton;
bool m_mkspecEdited;
QLabel *m_errorLabel;
Utils::FileName m_suggestedMkspec;
};
} // namespace Internal
......@@ -86,13 +118,29 @@ void ToolChainConfigWidget::makeReadOnly()
{
if (d->m_debuggerPathChooser)
d->m_debuggerPathChooser->setEnabled(false);
if (d->m_mkspecEdit)
d->m_mkspecEdit->setEnabled(false);
if (d->m_mkspecResetButton)
d->m_mkspecResetButton->setEnabled(false);
}
void ToolChainConfigWidget::emitDirty()
{
if (d->m_mkspecEdit)
d->m_mkspecEdited = (mkspecFromString(d->m_mkspecEdit->text()) != d->m_suggestedMkspec);
if (d->m_mkspecResetButton)
d->m_mkspecResetButton->setEnabled(d->m_mkspecEdited);
emit dirty(toolChain());
}
void ToolChainConfigWidget::resetMkspec()
{
if (!d->m_mkspecEdit || !d->m_mkspecEdited)
return;
d->m_mkspecEdit->setText(mkspecToString(d->m_suggestedMkspec));
d->m_mkspecEdited = false;
}
void ToolChainConfigWidget::addDebuggerCommandControls(QFormLayout *lt,
const QStringList &versionArguments)
{
......@@ -140,6 +188,61 @@ void ToolChainConfigWidget::setDebuggerCommand(const Utils::FileName &debugger)
d->m_debuggerPathChooser->setFileName(debugger);
}
void ToolChainConfigWidget::addMkspecControls(QFormLayout *lt)
{
ensureMkspecEdit();
lt->addRow(tr("mkspec:"), d->m_mkspecLayout);
}
void ToolChainConfigWidget::addMkspecControls(QGridLayout *lt, int row, int column)
{
ensureMkspecEdit();
QLabel *label = new QLabel(tr("mkspec:"));
label->setBuddy(d->m_mkspecEdit);
lt->addWidget(label, row, column);
lt->addLayout(d->m_mkspecLayout, row, column + 1);
}
void ToolChainConfigWidget::ensureMkspecEdit()
{
if (d->m_mkspecEdit)
return;
QTC_CHECK(!d->m_mkspecLayout);
QTC_CHECK(!d->m_mkspecResetButton);
d->m_suggestedMkspec = d->m_toolChain->suggestedMkspec();
d->m_mkspecLayout = new QHBoxLayout;
d->m_mkspecLayout->setMargin(0);
d->m_mkspecEdit = new QLineEdit;
d->m_mkspecResetButton = new QPushButton(tr("Reset"));
d->m_mkspecResetButton->setEnabled(d->m_mkspecEdited);
d->m_mkspecLayout->addWidget(d->m_mkspecEdit);
d->m_mkspecLayout->addWidget(d->m_mkspecResetButton);
connect(d->m_mkspecEdit, SIGNAL(textChanged(QString)), this, SLOT(emitDirty()));
connect(d->m_mkspecResetButton, SIGNAL(clicked()), this, SLOT(resetMkspec()));
}
Utils::FileName ToolChainConfigWidget::mkspec() const
{
QTC_ASSERT(d->m_mkspecEdit, return Utils::FileName());
return mkspecFromString(d->m_mkspecEdit->text());
}
void ToolChainConfigWidget::setMkspec(const Utils::FileName &spec)
{
QTC_ASSERT(d->m_mkspecEdit, return);
QString text = mkspecToString(spec);
d->m_mkspecEdit->setText(text);
emitDirty();
}
void ToolChainConfigWidget::addErrorLabel(QFormLayout *lt)
{
if (!d->m_errorLabel) {
......
......@@ -75,6 +75,7 @@ signals:
protected slots:
void emitDirty();
void resetMkspec();
void setErrorMessage(const QString &);
void clearErrorMessage();
......@@ -85,14 +86,20 @@ protected:
int row = 0, int column = 0,
const QStringList &versionArguments = QStringList());
void addDebuggerAutoDetection(QObject *receiver, const char *autoDetectSlot);
void addMkspecControls(QFormLayout *lt);
void addMkspecControls(QGridLayout *lt, int row = 0, int column = 0);
void addErrorLabel(QFormLayout *lt);
void addErrorLabel(QGridLayout *lt, int row = 0, int column = 0, int colSpan = 1);
Utils::FileName debuggerCommand() const;
void setDebuggerCommand(const Utils::FileName &debugger);
Utils::FileName mkspec() const;
void setMkspec(const Utils::FileName &spec);
private:
void ensureDebuggerPathChooser(const QStringList &versionArguments);
void ensureMkspecEdit();
Internal::ToolChainConfigWidgetPrivate *d;
};
......
......@@ -305,7 +305,7 @@ QString WinCEToolChain::typeDisplayName() const
return WinCEToolChainFactory::tr("WinCE");
}
Utils::FileName WinCEToolChain::mkspec() const
Utils::FileName WinCEToolChain::suggestedMkspec() const
{
const QChar specSeperator(QLatin1Char('-'));
......
......@@ -58,6 +58,7 @@ public:
bool autodetect = false);
QString legacyId() const;
Utils::FileName suggestedMkspec() const;
static WinCEToolChain *readFromMap(const QVariantMap &data);
......
......@@ -133,11 +133,6 @@ QString GcceToolChain::makeCommand() const
#endif
}
Utils::FileName GcceToolChain::mkspec() const
{
return Utils::FileName(); // always use default from Qt version
}
QString GcceToolChain::defaultMakeTarget() const
{
return QLatin1String("gcce");
......
......@@ -51,7 +51,6 @@ public:
QByteArray predefinedMacros() const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
Utils::FileName mkspec() const;
QString defaultMakeTarget() const;
void setCompilerCommand(const Utils::FileName &);
......
......@@ -216,11 +216,6 @@ void RvctToolChain::addToEnvironment(Utils::Environment &env) const
env.set(QLatin1String("LANG"), QString(QLatin1Char('C')));
}
Utils::FileName RvctToolChain::mkspec() const
{
return Utils::FileName(); // Always use default from Qt version
}
QString RvctToolChain::makeCommand() const
{
#if defined(Q_OS_WIN)
......@@ -398,6 +393,8 @@ RvctToolChainConfigWidget::RvctToolChainConfigWidget(RvctToolChain *tc) :
m_ui->versionComboBox->setCurrentIndex(static_cast<int>(tc->armVersion()));
connect(m_ui->versionComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(emitDirty()));
addMkspecControls(m_ui->formLayout);
setFromToolChain();
}
......@@ -416,6 +413,7 @@ void RvctToolChainConfigWidget::apply()
tc->setArmVersion(static_cast<RvctToolChain::ArmVersion>(m_ui->versionComboBox->currentIndex()));
tc->setEnvironmentChanges(changes);
tc->setDebuggerCommand(debuggerCommand());
tc->setMkspec(mkspec());
m_model->setUserChanges(changes);
}
......@@ -430,6 +428,7 @@ void RvctToolChainConfigWidget::setFromToolChain()
m_ui->compilerPath->setFileName(tc->compilerCommand());
m_ui->versionComboBox->setCurrentIndex(static_cast<int>(tc->armVersion()));
setDebuggerCommand(tc->debuggerCommand());
setMkspec(tc->mkspec());
}
bool RvctToolChainConfigWidget::isDirty() const
......@@ -440,7 +439,8 @@ bool RvctToolChainConfigWidget::isDirty() const
return tc->compilerCommand() != m_ui->compilerPath->fileName()
|| tc->armVersion() != static_cast<RvctToolChain::ArmVersion>(m_ui->versionComboBox->currentIndex())
|| tc->environmentChanges() != environmentChanges()
|| tc->debuggerCommand() != debuggerCommand();
|| tc->debuggerCommand() != debuggerCommand()
|| tc->mkspec() != mkspec();
}
void RvctToolChainConfigWidget::makeReadOnly()
......
......@@ -92,7 +92,6 @@ public:
QByteArray predefinedMacros() const;
QList<ProjectExplorer::HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
Utils::FileName mkspec() const;
QString makeCommand() const;
QString defaultMakeTarget() const;
ProjectExplorer::IOutputParser *outputParser() const;
......
......@@ -191,12 +191,6 @@ void WinscwToolChain::addToEnvironment(Utils::Environment &env) const
env.prependOrSetPath(m_compilerPath.toString());
}
Utils::FileName WinscwToolChain::mkspec() const
{
return Utils::FileName(); // Always use default from Qt version
}
QString WinscwToolChain::makeCommand() const
{
#if defined Q_OS_WIN
......
......@@ -62,7 +62,6 @@ public:
QByteArray predefinedMacros() const;
QList<ProjectExplorer::HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
Utils::FileName mkspec() const;
QString makeCommand() const;
Utils::FileName compilerCommand() const;
Utils::FileName debuggerCommand() const;
......
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