Commit 365560c9 authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Identify tool chains via ToolChain::ToolChainType enum instead of by string

Reviewed-by: dt
parent d796f75e
......@@ -325,7 +325,7 @@ void GenericProject::setIncludePaths(const QStringList &includePaths)
QByteArray GenericProject::defines() const
{ return m_defines; }
void GenericProject::setToolChainId(const QString &toolChainId)
void GenericProject::setToolChainId(ProjectExplorer::ToolChain::ToolChainType toolChainId)
{
using namespace ProjectExplorer;
......@@ -334,21 +334,21 @@ void GenericProject::setToolChainId(const QString &toolChainId)
delete m_toolChain;
m_toolChain = 0;
if (toolChainId == QLatin1String("mingw")) {
if (toolChainId == ToolChain::MinGW) {
const QLatin1String qmake_cxx("g++"); // ### FIXME
const QString mingwDirectory; // ### FIXME
m_toolChain = ToolChain::createMinGWToolChain(qmake_cxx, mingwDirectory);
} else if (toolChainId == QLatin1String("msvc")) {
} else if (toolChainId == ToolChain::MSVC) {
const QString msvcVersion; // ### FIXME
m_toolChain = ToolChain::createMSVCToolChain(msvcVersion, false);
} else if (toolChainId == QLatin1String("wince")) {
} else if (toolChainId == ToolChain::WINCE) {
const QString msvcVersion, wincePlatform; // ### FIXME
m_toolChain = ToolChain::createWinCEToolChain(msvcVersion, wincePlatform);
} else if (toolChainId == QLatin1String("gcc") || toolChainId == QLatin1String("icc")) {
} else if (toolChainId == ToolChain::GCC || toolChainId == ToolChain::GCC) {
const QLatin1String qmake_cxx("g++"); // ### FIXME
m_toolChain = ToolChain::createGccToolChain(qmake_cxx);
}
......@@ -381,7 +381,7 @@ ProjectExplorer::ToolChain *GenericProject::toolChain() const
return m_toolChain;
}
QString GenericProject::toolChainId() const
ProjectExplorer::ToolChain::ToolChainType GenericProject::toolChainId() const
{ return m_toolChainId; }
QString GenericProject::name() const
......@@ -490,11 +490,24 @@ bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
setValue(all, buildDirectory, fileInfo.absolutePath());
}
QString toolChainId = reader.restoreValue(QLatin1String("toolChain")).toString();
if (toolChainId.isEmpty())
toolChainId = QLatin1String("gcc");
using namespace ProjectExplorer;
QString toolChainName = reader.restoreValue(QLatin1String("toolChain")).toString();
bool convertible = false;
ToolChain::ToolChainType toolChainId = ToolChain::GCC;
toolChainId = ToolChain::ToolChainType(toolChainName.toInt(&convertible));
if (!convertible) {
// legacy string values
if (toolChainName == QLatin1String("gcc"))
toolChainId = ToolChain::GCC;
else if (toolChainName == QLatin1String("mingw"))
toolChainId = ToolChain::MinGW;
else if (toolChainName == QLatin1String("msvc"))
toolChainId = ToolChain::MSVC;
else if (toolChainName == QLatin1String("wince"))
toolChainId = ToolChain::WINCE;
}
setToolChainId(toolChainId.toLower()); // ### move
setToolChainId(toolChainId); // ### move
const QStringList userIncludePaths =
reader.restoreValue(QLatin1String("includePaths")).toStringList();
......@@ -533,10 +546,14 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
// tool chain
QComboBox *toolChainChooser = new QComboBox;
toolChainChooser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains());
toolChainChooser->setCurrentIndex(toolChainChooser->findText(m_project->toolChainId()));
fl->addRow(tr("Toolchain:"), toolChainChooser);
connect(toolChainChooser, SIGNAL(activated(QString)), m_project, SLOT(setToolChainId(QString)));
using namespace ProjectExplorer;
foreach (ToolChain::ToolChainType tc, ToolChain::supportedToolChains()) {
toolChainChooser->addItem(ToolChain::toolChainName(tc), tc);
}
toolChainChooser->setCurrentIndex(toolChainChooser->findData(m_project->toolChainId()));
fl->addRow(tr("Tool Chain:"), toolChainChooser);
connect(toolChainChooser, SIGNAL(activated(QString)), m_project, SLOT(setToolChainId(int)));
}
GenericBuildSettingsWidget::~GenericBuildSettingsWidget()
......
......@@ -36,6 +36,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/ifile.h>
QT_BEGIN_NAMESPACE
......@@ -49,10 +50,6 @@ class PathChooser;
}
}
namespace ProjectExplorer {
class ToolChain;
}
namespace GenericProjectManager {
namespace Internal {
......@@ -114,10 +111,10 @@ public:
QStringList projectIncludePaths() const;
QStringList files() const;
QStringList generated() const;
QString toolChainId() const;
ProjectExplorer::ToolChain::ToolChainType toolChainId() const;
public Q_SLOTS:
void setToolChainId(const QString &toolChainId);
void setToolChainId(ProjectExplorer::ToolChain::ToolChainType);
protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
......@@ -143,7 +140,7 @@ private:
GenericProjectNode *m_rootNode;
ProjectExplorer::ToolChain *m_toolChain;
QString m_toolChainId;
ProjectExplorer::ToolChain::ToolChainType m_toolChainId;
};
class GenericProjectFile : public Core::IFile
......
......@@ -95,14 +95,13 @@ QStringList ToolChain::availableMSVCVersions()
return versions;
}
QStringList ToolChain::supportedToolChains()
QList<ToolChain::ToolChainType> ToolChain::supportedToolChains()
{
return QStringList() << QLatin1String("gcc")
<< QLatin1String("mingw")
<< QLatin1String("msvc")
<< QLatin1String("wince")
<< QLatin1String("winscw")
<< QLatin1String("gcce");
QList<ToolChain::ToolChainType> toolChains;
for (int i = 0; i < LAST_VALID; ++i) {
toolChains.append(ToolChainType(i));
}
return toolChains;
}
QString ToolChain::toolChainName(ToolChainType tc)
......@@ -118,6 +117,18 @@ QString ToolChain::toolChainName(ToolChainType tc)
return QCoreApplication::translate("ToolChain", "Microsoft Visual C++");
case WINCE:
return QCoreApplication::translate("ToolChain", "Windows CE");
#ifdef QTCREATOR_WITH_S60
case WINSCW:
return QCoreApplication::translate("ToolChain", "WINSCW");
case GCCE:
return QCoreApplication::translate("ToolChain", "GCCE");
case RVCT_ARMV5:
return QCoreApplication::translate("ToolChain", "RVCT (ARMV5)");
case RVCT_ARMV6:
return QCoreApplication::translate("ToolChain", "RVCT (ARMV6)");
#endif
case OTHER:
return QCoreApplication::translate("ToolChain", "Other");
case INVALID:
......
......@@ -79,6 +79,9 @@ public:
GCCE = 6,
RVCT_ARMV5 = 7,
RVCT_ARMV6 = 8,
LAST_VALID = 9,
#else
LAST_VALID = 5,
#endif
OTHER = 200,
UNKNOWN = 201,
......@@ -102,7 +105,7 @@ public:
static ToolChain *createMSVCToolChain(const QString &name, bool amd64);
static ToolChain *createWinCEToolChain(const QString &name, const QString &platform);
static QStringList availableMSVCVersions();
static QStringList supportedToolChains();
static QList<ToolChain::ToolChainType> supportedToolChains();
static QString toolChainName(ToolChainType tc);
......
......@@ -356,42 +356,9 @@ void Qt4ProjectConfigWidget::updateToolChainCombo()
{
m_ui->toolChainComboBox->clear();
QList<ProjectExplorer::ToolChain::ToolChainType> toolchains = m_pro->qtVersion(m_buildConfiguration)->possibleToolChainTypes();
foreach (ProjectExplorer::ToolChain::ToolChainType toolchain, toolchains) {
switch (toolchain) {
case ProjectExplorer::ToolChain::GCC:
m_ui->toolChainComboBox->addItem(tr("gcc"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::LinuxICC:
m_ui->toolChainComboBox->addItem(tr("icc"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::MinGW:
m_ui->toolChainComboBox->addItem(tr("mingw"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::MSVC:
m_ui->toolChainComboBox->addItem(tr("msvc"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::WINCE:
m_ui->toolChainComboBox->addItem(tr("wince"), qVariantFromValue(toolchain));
break;
#ifdef QTCREATOR_WITH_S60
case ProjectExplorer::ToolChain::WINSCW:
m_ui->toolChainComboBox->addItem(tr("winscw"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::GCCE:
m_ui->toolChainComboBox->addItem(tr("gcce"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::RVCT_ARMV5:
m_ui->toolChainComboBox->addItem(tr("rvct - armv5"), qVariantFromValue(toolchain));
break;
case ProjectExplorer::ToolChain::RVCT_ARMV6:
m_ui->toolChainComboBox->addItem(tr("rvct - armv6"), qVariantFromValue(toolchain));
break;
#endif
case ProjectExplorer::ToolChain::OTHER:
case ProjectExplorer::ToolChain::INVALID:
case ProjectExplorer::ToolChain::UNKNOWN:
break;
}
using namespace ProjectExplorer;
foreach (ToolChain::ToolChainType toolchain, toolchains) {
m_ui->toolChainComboBox->addItem(ToolChain::toolChainName(toolchain), qVariantFromValue(toolchain));
}
m_ui->toolChainComboBox->setEnabled(toolchains.size() > 1);
setToolChain(toolchains.indexOf(m_pro->toolChainType(m_buildConfiguration)));
......
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