Commit df7aa6b5 authored by Tobias Hunger's avatar Tobias Hunger

ToolChain: Add support for mkspecs

Make the toolchains report their mkspec files and use the mkspec of the
toolchain if it does provide one. Fall back to the Qt version's mkspec
otherwise.

Task-number: QTCREATORBUG-4396
parent 5cf0e625
......@@ -376,6 +376,16 @@ QString GccToolChain::debuggerCommand() const
return m_debuggerCommand;
}
QString GccToolChain::mkspec() const
{
Abi abi = targetAbi();
if (abi.os() == Abi::MacOS)
return QLatin1String("macx-g++");
if (abi.os() == Abi::LinuxOS)
return QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth());
return QString();
}
QString GccToolChain::makeCommand() const
{
return QLatin1String("make");
......@@ -692,6 +702,11 @@ QString MingwToolChain::typeName() const
return Internal::MingwToolChainFactory::tr("MinGW");
}
QString MingwToolChain::mkspec() const
{
return QLatin1String("win32-g++");
}
QString MingwToolChain::makeCommand() const
{
return QLatin1String("mingw32-make.exe");
......@@ -781,6 +796,11 @@ IOutputParser *LinuxIccToolChain::outputParser() const
return new LinuxIccParser;
}
QString LinuxIccToolChain::mkspec() const
{
return QLatin1String("linux-icc-") + QString::number(targetAbi().wordWidth());
}
ToolChain *LinuxIccToolChain::clone() const
{
return new LinuxIccToolChain(*this);
......
......@@ -63,6 +63,7 @@ public:
QByteArray predefinedMacros() const;
QList<HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
QString mkspec() const;
QString makeCommand() const;
void setDebuggerCommand(const QString &);
QString debuggerCommand() const;
......@@ -114,6 +115,7 @@ class PROJECTEXPLORER_EXPORT MingwToolChain : public GccToolChain
{
public:
QString typeName() const;
QString mkspec() const;
QString makeCommand() const;
ToolChain *clone() const;
......@@ -137,6 +139,8 @@ public:
IOutputParser *outputParser() const;
QString mkspec() const;
ToolChain *clone() const;
private:
......
......@@ -406,6 +406,17 @@ void MsvcToolChain::addToEnvironment(Utils::Environment &env) const
env = m_resultEnvironment;
}
QString MsvcToolChain::mkspec() const
{
if (m_abi.osFlavor() == Abi::WindowsMsvc2005Flavor)
return QLatin1String("win32-msvc2005");
if (m_abi.osFlavor() == Abi::WindowsMsvc2008Flavor)
return QLatin1String("win32-msvc2008");
if (m_abi.osFlavor() == Abi::WindowsMsvc2010Flavor)
return QLatin1String("win32-msvc2010");
return QString();
}
QString MsvcToolChain::makeCommand() const
{
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().useJom) {
......
......@@ -65,6 +65,7 @@ public:
QByteArray predefinedMacros() const;
QList<HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
QString mkspec() const;
QString makeCommand() const;
void setDebuggerCommand(const QString &d);
virtual QString debuggerCommand() const;
......
......@@ -83,6 +83,8 @@ public:
virtual void addToEnvironment(Utils::Environment &env) const = 0;
virtual QString makeCommand() const = 0;
virtual QString mkspec() const = 0;
virtual QString debuggerCommand() const = 0;
virtual QString defaultMakeTarget() const;
virtual IOutputParser *outputParser() const = 0;
......
......@@ -597,6 +597,17 @@ QString BaseQtVersion::mkspecPath() const
return m_mkspecFullPath;
}
bool BaseQtVersion::hasMkspec(const QString &spec) const
{
updateVersionInfo();
QFileInfo fi;
fi.setFile(QDir::fromNativeSeparators(m_versionInfo.value("QMAKE_MKSPECS")) + '/' + spec);
if (fi.isDir())
return true;
fi.setFile(sourcePath() + QLatin1String("/mkspecs/") + spec);
return fi.isDir();
}
BaseQtVersion::QmakeBuildConfigs BaseQtVersion::defaultBuildConfig() const
{
ensureMkSpecParsed();
......
......@@ -147,6 +147,8 @@ public:
/// specifally not the directory the symlink/ORIGINAL_QMAKESPEC points to
QString mkspecPath() const;
bool hasMkspec(const QString &) const;
enum QmakeBuildConfig
{
NoBuild = 1,
......
......@@ -130,12 +130,18 @@ QString QMakeStep::allArguments(bool shorted)
arguments << QDir::toNativeSeparators(buildConfiguration()->target()->project()->file()->fileName());
arguments << "-r";
bool haveSpec = false;
for (Utils::QtcProcess::ArgIterator ait(&additonalArguments); ait.next(); )
if (ait.value() == QLatin1String("-spec"))
goto haveSpec;
if (bc->qtVersion())
arguments << "-spec" << bc->qtVersion()->mkspec();
haveSpec:
haveSpec = true;
if (!haveSpec) {
const QString tcSpec = bc->toolChain() ? bc->toolChain()->mkspec() : QString();
if (!tcSpec.isEmpty() && bc->qtVersion()->hasMkspec(tcSpec))
arguments << "-spec" << tcSpec;
else
arguments << "-spec" << bc->qtVersion()->mkspec();
}
// Find out what flags we pass on to qmake
arguments << bc->configCommandLineArguments();
......
......@@ -82,6 +82,11 @@ ProjectExplorer::Abi MaemoToolChain::targetAbi() const
return m_targetAbi;
}
QString MaemoToolChain::mkspec() const
{
return QString(); // always use default
}
bool MaemoToolChain::isValid() const
{
return GccToolChain::isValid() && m_qtVersionId >= 0 && m_targetAbi.isValid();
......
......@@ -51,6 +51,7 @@ public:
QString typeName() const;
ProjectExplorer::Abi targetAbi() const;
QString mkspec() const;
bool isValid() const;
bool canClone() const;
......
......@@ -128,6 +128,11 @@ QString GcceToolChain::makeCommand() const
#endif
}
QString GcceToolChain::mkspec() const
{
return QString(); // always use default from Qt version
}
QString GcceToolChain::defaultMakeTarget() const
{
return QLatin1String("gcce");
......
......@@ -50,6 +50,7 @@ public:
QByteArray predefinedMacros() const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
QString mkspec() const;
QString defaultMakeTarget() const;
void setCompilerPath(const QString &);
......
......@@ -225,6 +225,11 @@ void RvctToolChain::addToEnvironment(Utils::Environment &env) const
env.set(QLatin1String("LANG"), QString(QLatin1Char('C')));
}
QString RvctToolChain::mkspec() const
{
return QString(); // Always use default from Qt version
}
QString RvctToolChain::makeCommand() const
{
#if defined(Q_OS_WIN)
......
......@@ -89,6 +89,7 @@ public:
QByteArray predefinedMacros() const;
QList<ProjectExplorer::HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
QString mkspec() const;
QString makeCommand() const;
QString defaultMakeTarget() const;
ProjectExplorer::IOutputParser *outputParser() const;
......
......@@ -182,6 +182,12 @@ void WinscwToolChain::addToEnvironment(Utils::Environment &env) const
env.prependOrSetPath(QFileInfo(m_compilerPath).absolutePath());
}
QString WinscwToolChain::mkspec() const
{
return QString(); // Always use default from Qt version
}
QString WinscwToolChain::makeCommand() const
{
#if defined Q_OS_WIN
......
......@@ -60,6 +60,7 @@ public:
QByteArray predefinedMacros() const;
QList<ProjectExplorer::HeaderPath> systemHeaderPaths() const;
void addToEnvironment(Utils::Environment &env) const;
QString mkspec() const;
QString makeCommand() const;
virtual QString debuggerCommand() const;
QString defaultMakeTarget() 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