ToolChain: Refactor toolchain support

Refactor ToolChains in Qt Creator:

 * Allow for several toolchains of the same type
 * Be smarter wrt. guessing what kind of output a toolchain
   produces. This allows us to eventually handle e.g. embedded
   linux setups way better than before.
 * Be smarter wrt. guessing what kind of environment a Qt version
   needs.
 * Improve auto-detection of toolchains a bit
 * Decide on which debugger to use based on the kind of output
   produced by the compiler.
 * Add options page to configure toolchains
 * Remove toolchain related options from the Qt version dialog

Reviewed-by: dt
This commit is contained in:
Tobias Hunger
2011-02-01 18:36:00 +01:00
parent be31c80b02
commit 8d0c477245
112 changed files with 6498 additions and 3687 deletions

View File

@@ -43,6 +43,8 @@
#include "qt-s60/s60projectchecker.h"
#include "qt-s60/abldparser.h"
#include "qt-s60/sbsv2parser.h"
#include "qt-s60/gccetoolchain.h"
#include "qt-s60/winscwtoolchain.h"
#include "qmlobservertool.h"
#include "qmldumptool.h"
@@ -52,7 +54,10 @@
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/cesdkhandler.h>
#include <projectexplorer/gcctoolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <utils/synchronousprocess.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
@@ -85,6 +90,24 @@ static const char *PATH_AUTODETECTION_SOURCE = "PATH";
enum { debug = 0 };
template<class T>
static T *createToolChain(const QString &id)
{
QList<ProjectExplorer::ToolChainFactory *> factories =
ExtensionSystem::PluginManager::instance()->getObjects<ProjectExplorer::ToolChainFactory>();
foreach (ProjectExplorer::ToolChainFactory *f, factories) {
if (f->id() == id) {
Q_ASSERT(f->canCreate());
return static_cast<T *>(f->create());
}
}
return 0;
}
// --------------------------------------------------------------------------
// QtVersionManager
// --------------------------------------------------------------------------
QtVersionManager *QtVersionManager::m_self = 0;
QtVersionManager::QtVersionManager()
@@ -136,12 +159,40 @@ QtVersionManager::QtVersionManager()
id,
isAutodetected,
autodetectionSource);
version->setMingwDirectory(s->value("MingwDirectory").toString());
version->setMsvcVersion(s->value("msvcVersion").toString());
version->setMwcDirectory(s->value("MwcDirectory").toString());
version->setS60SDKDirectory(s->value("S60SDKDirectory").toString());
version->setGcceDirectory(s->value("GcceDirectory").toString());
version->setSbsV2Directory(s->value(QLatin1String("SBSv2Directory")).toString());
// Update from 2.1 or earlier:
QString mingwDir = s->value(QLatin1String("MingwDirectory")).toString();
if (!mingwDir.isEmpty()) {
ProjectExplorer::MingwToolChain *tc = createToolChain<ProjectExplorer::MingwToolChain>(ProjectExplorer::Constants::MINGW_TOOLCHAIN_ID);
if (tc) {
tc->setCompilerPath(QDir::fromNativeSeparators(mingwDir) + QLatin1String("/bin/gcc.exe"));
tc->setDisplayName(tr("Mingw from %1").arg(version->displayName()));
ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
}
}
QString mwcDir = s->value(QLatin1String("MwcDirectory")).toString();
if (!mwcDir.isEmpty()) {
WinscwToolChain *tc = createToolChain<WinscwToolChain>(Constants::WINSCW_TOOLCHAIN_ID);
if (tc) {
tc->setCompilerPath(QDir::fromNativeSeparators(mwcDir)
+ QLatin1String("/x86Build/Symbian_Tools/Command_Line_Tools/mwwinrc.exe"));
tc->setDisplayName(tr("WINSCW from %1").arg(version->displayName()));
ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
}
}
QString gcceDir = s->value(QLatin1String("GcceDirectory")).toString();
if (!gcceDir.isEmpty()) {
GcceToolChain *tc = createToolChain<GcceToolChain>(Constants::GCCE_TOOLCHAIN_ID);
if (tc) {
tc->setCompilerPath(QDir::fromNativeSeparators(gcceDir)
+ QLatin1String("/bin/arm-none-symbianelf-g++.exe"));
tc->setDisplayName(tr("GCCE from %1").arg(version->displayName()));
ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
}
}
m_versions.append(version);
}
s->endArray();
@@ -309,14 +360,10 @@ void QtVersionManager::writeVersionsIntoSettings()
s->setValue("Path", version->versionInfo().value("QT_INSTALL_DATA"));
s->setValue("QMakePath", version->qmakeCommand());
s->setValue("Id", version->uniqueId());
s->setValue("MingwDirectory", version->mingwDirectory());
s->setValue("msvcVersion", version->msvcVersion());
s->setValue("isAutodetected", version->isAutodetected());
if (version->isAutodetected())
s->setValue("autodetectionSource", version->autodetectionSource());
s->setValue("MwcDirectory", version->mwcDirectory());
s->setValue("S60SDKDirectory", version->s60SDKDirectory());
s->setValue("GcceDirectory", version->gcceDirectory());
s->setValue(QLatin1String("SBSv2Directory"), version->sbsV2Directory());
}
s->endArray();
@@ -352,13 +399,14 @@ QtVersion *QtVersionManager::version(int id) const
return m_emptyVersion;
}
// FIXME: Rework this!
void QtVersionManager::addNewVersionsFromInstaller()
{
// Add new versions which may have been installed by the WB installer in the form:
// NewQtVersions="qt 4.3.2=c:\\qt\\qt432\bin\qmake.exe;qt embedded=c:\\qtembedded;"
// or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe=c:\\qtcreator\\mingw\\=MSVCName;
// or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe;
// i.e.
// NewQtVersions="versionname=pathtoversion=mingw=s60sdk=gcce=carbide;"
// NewQtVersions="versionname=pathtoversion=s60sdk;"
// Duplicate entries are not added, the first new version is set as default.
QSettings *settings = Core::ICore::instance()->settings();
QSettings *globalSettings = Core::ICore::instance()->settings(QSettings::SystemScope);
@@ -388,17 +436,9 @@ void QtVersionManager::addNewVersionsFromInstaller()
if (QFile::exists(newVersionData[1])) {
QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ );
if (newVersionData.count() >= 3)
version->setMingwDirectory(newVersionData[2]);
version->setS60SDKDirectory(QDir::fromNativeSeparators(newVersionData[2]));
if (newVersionData.count() >= 4)
version->setS60SDKDirectory(QDir::fromNativeSeparators(newVersionData[3]));
if (newVersionData.count() >= 5)
version->setGcceDirectory(QDir::fromNativeSeparators(newVersionData[4]));
if (newVersionData.count() >= 6)
version->setMwcDirectory(QDir::fromNativeSeparators(newVersionData[5]));
if (newVersionData.count() >= 7)
version->setMsvcVersion(newVersionData[6]);
if (newVersionData.count() >= 8)
version->setSbsV2Directory(QDir::fromNativeSeparators(newVersionData[7]));
version->setSbsV2Directory(QDir::fromNativeSeparators(newVersionData[3]));
bool versionWasAlreadyInList = false;
foreach(const QtVersion * const it, m_versions) {
@@ -467,10 +507,6 @@ bool QtVersionManager::equals(QtVersion *a, QtVersion *b)
return false;
if (a->m_id != b->m_id)
return false;
if (a->m_mingwDirectory != b->m_mingwDirectory
|| a->m_msvcVersion != b->m_msvcVersion
|| a->m_mwcDirectory != b->m_mwcDirectory)
return false;
if (a->m_displayName != b->displayName())
return false;
return true;
@@ -538,9 +574,9 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions)
emit qtVersionsChanged(changedVersions);
}
///
/// QtVersion
///
// --------------------------------------------------------------------------
// QtVersion
// --------------------------------------------------------------------------
QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id,
bool isAutodetected, const QString &autodetectionSource)
@@ -551,15 +587,14 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id,
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
m_toolChainUpToDate(false),
m_abiUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false),
m_isBuildUsingSbsV2(false)
m_hasDocumentation(false)
{
if (id == -1)
m_id = getUniqueId();
@@ -577,15 +612,14 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand,
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
m_toolChainUpToDate(false),
m_abiUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false),
m_isBuildUsingSbsV2(false)
m_hasDocumentation(false)
{
m_id = getUniqueId();
setQMakeCommand(qmakeCommand);
@@ -599,15 +633,14 @@ QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QSt
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
m_toolChainUpToDate(false),
m_abiUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false),
m_isBuildUsingSbsV2(false)
m_hasDocumentation(false)
{
m_id = getUniqueId();
setQMakeCommand(qmakeCommand);
@@ -621,20 +654,18 @@ QtVersion::QtVersion()
m_hasQmlDump(false),
m_hasQmlDebuggingLibrary(false),
m_hasQmlObserver(false),
m_toolChainUpToDate(false),
m_abiUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false),
m_isBuildUsingSbsV2(false)
m_hasDocumentation(false)
{
setQMakeCommand(QString());
}
QtVersion::~QtVersion()
{
}
@@ -646,30 +677,39 @@ QString QtVersion::toHtml() const
str << "<html><body><table>";
str << "<tr><td><b>" << QtVersionManager::tr("Name:")
<< "</b></td><td>" << displayName() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("Source:")
<< "</b></td><td>" << sourcePath() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("mkspec:")
<< "</b></td><td>" << mkspec() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("qmake:")
<< "</b></td><td>" << m_qmakeCommand << "</td></tr>";
updateToolChainAndMkspec();
if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) {
str << "<tr><td><b>" << QtVersionManager::tr("Default:") << "</b></td><td>"
<< (m_defaultConfigIsDebug ? "debug" : "release");
if (m_defaultConfigIsDebugAndRelease)
str << " debug_and_release";
str << "</td></tr>";
} // default config.
str << "<tr><td><b>" << QtVersionManager::tr("Version:")
<< "</b></td><td>" << qtVersionString() << "</td></tr>";
if (hasDebuggingHelper())
str << "<tr><td><b>" << QtVersionManager::tr("Debugging helper:")
<< "</b></td><td>" << debuggingHelperLibrary() << "</td></tr>";
const QHash<QString,QString> vInfo = versionInfo();
if (!vInfo.isEmpty()) {
const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd();
for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it)
str << "<tr><td><pre>" << it.key() << "</pre></td><td>" << it.value() << "</td></tr>";
if (!isValid()) {
str << "<tr><td colspan=2><b>" + QtVersionManager::tr("Invalid Qt version") +"</b></td></tr>";
} else {
QString prefix = QLatin1String("<tr><td><b>") + QtVersionManager::tr("ABI:") + QLatin1String("</b></td>");
foreach (const ProjectExplorer::Abi &abi, qtAbis()) {
str << prefix << "<td>" << abi.toString() << "</td></tr>";
prefix = QLatin1String("<tr><td></td>");
}
str << "<tr><td><b>" << QtVersionManager::tr("Source:")
<< "</b></td><td>" << sourcePath() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("mkspec:")
<< "</b></td><td>" << mkspec() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("qmake:")
<< "</b></td><td>" << m_qmakeCommand << "</td></tr>";
updateAbiAndMkspec();
if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) {
str << "<tr><td><b>" << QtVersionManager::tr("Default:") << "</b></td><td>"
<< (m_defaultConfigIsDebug ? "debug" : "release");
if (m_defaultConfigIsDebugAndRelease)
str << " debug_and_release";
str << "</td></tr>";
} // default config.
str << "<tr><td><b>" << QtVersionManager::tr("Version:")
<< "</b></td><td>" << qtVersionString() << "</td></tr>";
if (hasDebuggingHelper())
str << "<tr><td><b>" << QtVersionManager::tr("Debugging helper:")
<< "</b></td><td>" << debuggingHelperLibrary() << "</td></tr>";
const QHash<QString,QString> vInfo = versionInfo();
if (!vInfo.isEmpty()) {
const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd();
for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it)
str << "<tr><td><pre>" << it.key() << "</pre></td><td>" << it.value() << "</td></tr>";
}
}
str << "</table></body></html>";
return rc;
@@ -768,19 +808,19 @@ QString QtVersion::sourcePath() const
QString QtVersion::mkspec() const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
return m_mkspec;
}
QString QtVersion::mkspecPath() const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
return m_mkspecFullPath;
}
bool QtVersion::isBuildWithSymbianSbsV2() const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
return m_isBuildUsingSbsV2;
}
@@ -840,7 +880,7 @@ void QtVersion::setQMakeCommand(const QString& qmakeCommand)
m_linguistCommand.clear();
m_qmlviewerCommand.clear();
m_uicCommand.clear();
m_toolChainUpToDate = false;
m_abiUpToDate = false;
// TODO do i need to optimize this?
m_versionInfoUpToDate = false;
m_qtVersionString = QString();
@@ -1306,15 +1346,50 @@ QString QtVersion::qmlviewerCommand() const
return m_qmlviewerCommand;
}
QString QtVersion::systemRoot() const
{
if (m_systemRoot.isNull()) {
if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID)
|| supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) {
S60Devices::Device device = S60Manager::instance()->deviceForQtVersion(this);
m_systemRoot = device.epocRoot;
if (!m_systemRoot.endsWith(QLatin1Char('/')))
m_systemRoot.append(QLatin1Char('/'));
} else if (supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) ||
supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID)) {
QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(this))
+ QLatin1String("/information"));
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream stream(&file);
while (!stream.atEnd()) {
const QString &line = stream.readLine().trimmed();
const QStringList &list = line.split(QLatin1Char(' '));
if (list.count() <= 1)
continue;
if (list.at(0) == QLatin1String("sysroot")) {
m_systemRoot = MaemoGlobal::maddeRoot(this)
+ QLatin1String("/sysroots/") + list.at(1);
}
}
}
}
if (m_systemRoot.isNull())
m_systemRoot = QLatin1String("");
}
return m_systemRoot;
}
bool QtVersion::supportsTargetId(const QString &id) const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
return m_targetIds.contains(id);
}
QSet<QString> QtVersion::supportedTargetIds() const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
return m_targetIds;
}
@@ -1328,42 +1403,20 @@ bool QtVersion::supportsMobileTarget() const
supportsTargetId(Constants::QT_SIMULATOR_TARGET_ID);
}
QList<QSharedPointer<ProjectExplorer::ToolChain> > QtVersion::toolChains() const
QList<ProjectExplorer::Abi> QtVersion::qtAbis() const
{
updateToolChainAndMkspec();
return m_toolChains;
}
ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChainType type) const
{
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tcptr, toolChains())
if (tcptr->type() == type)
return tcptr.data();
return 0;
}
QList<ProjectExplorer::ToolChainType> QtVersion::possibleToolChainTypes() const
{
QList<ProjectExplorer::ToolChainType> types;
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tc, toolChains())
types << tc->type();
return types;
updateAbiAndMkspec();
return m_abis;
}
// if none, then it's INVALID everywhere this function is called
void QtVersion::updateToolChainAndMkspec() const
void QtVersion::updateAbiAndMkspec() const
{
typedef QSharedPointer<ProjectExplorer::ToolChain> ToolChainPtr;
if (m_toolChainUpToDate)
if (m_id == -1 || m_abiUpToDate)
return;
m_toolChains.clear();
m_targetIds.clear();
if (!isValid()) {
m_targetIds.insert(Constants::DESKTOP_TARGET_ID);
return;
}
m_abis.clear();
// qDebug()<<"Finding mkspec for"<<qmakeCommand();
@@ -1446,11 +1499,8 @@ void QtVersion::updateToolChainAndMkspec() const
}
m_mkspec = mkspec;
m_isBuildUsingSbsV2 = false;
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
ProFileOption option;
option.properties = versionInfo();
ProMessageHandler msgHandler(true);
@@ -1467,74 +1517,62 @@ void QtVersion::updateToolChainAndMkspec() const
QString makefileGenerator = evaluator.value("MAKEFILE_GENERATOR");
QString ce_sdk = evaluator.values("CE_SDK").join(QLatin1String(" "));
QString ce_arch = evaluator.value("CE_ARCH");
QString qt_arch = evaluator.value("QT_ARCH");
// Evaluate all the information we have:
if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) {
QString wincePlatformName = ce_sdk + " (" + ce_arch + QLatin1Char(')');
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createWinCEToolChain(msvcVersion(), wincePlatformName));
// Treat windows CE as desktop.
m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ARM, ProjectExplorer::Abi::Windows,
ProjectExplorer::Abi::Windows_ce, ProjectExplorer::Abi::Format_PE, false));
m_targetIds.insert(Constants::DESKTOP_TARGET_ID);
} else if (makefileGenerator == QLatin1String("SYMBIAN_ABLD") ||
makefileGenerator == QLatin1String("SYMBIAN_SBSV2") ||
makefileGenerator == QLatin1String("SYMBIAN_UNIX")) {
m_isBuildUsingSbsV2 = (makefileGenerator == QLatin1String("SYMBIAN_SBSV2"));
if (S60Manager *s60mgr = S60Manager::instance()) {
# ifdef Q_OS_WIN
if (S60Manager::instance()) {
m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ARM, ProjectExplorer::Abi::Symbian,
ProjectExplorer::Abi::UNKNOWN_OSFLAVOUR,
ProjectExplorer::Abi::Format_ELF,
32));
m_targetIds.insert(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
m_toolChains << ToolChainPtr(s60mgr->createGCCEToolChain(this));
if (S60Manager::hasRvct2Compiler())
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain_RVCT2_ARMV5))
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain_RVCT2_ARMV6));
if (S60Manager::hasRvct4Compiler())
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain_RVCT4_ARMV5))
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain_RVCT4_ARMV6));
if (!mwcDirectory().isEmpty()) {
m_toolChains << ToolChainPtr(s60mgr->createWINSCWToolChain(this));
m_targetIds.insert(QLatin1String(Constants::S60_EMULATOR_TARGET_ID));
}
# else
if (S60Manager::hasRvct2Compiler())
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain_RVCT_ARMV5_GNUPOC));
m_toolChains << ToolChainPtr(s60mgr->createGCCE_GnuPocToolChain(this));
m_targetIds.insert(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
# endif
m_targetIds.insert(QLatin1String(Constants::S60_EMULATOR_TARGET_ID));
}
} else if (MaemoGlobal::isValidMaemo5QtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().maemo5ToolChain(this));
m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ARM, ProjectExplorer::Abi::Linux,
ProjectExplorer::Abi::Linux_maemo, ProjectExplorer::Abi::Format_ELF,
32));
m_targetIds.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID));
} else if (MaemoGlobal::isValidHarmattanQtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().harmattanToolChain(this));
m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ARM, ProjectExplorer::Abi::Linux,
ProjectExplorer::Abi::Linux_harmattan,
ProjectExplorer::Abi::Format_ELF,
32));
m_targetIds.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID));
} else if (MaemoGlobal::isValidMeegoQtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().meegoToolChain(this));
m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ARM, ProjectExplorer::Abi::Linux,
ProjectExplorer::Abi::Linux_meego,
ProjectExplorer::Abi::Format_ELF, 32));
m_targetIds.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID));
} else if (qmakeCXX == "cl" || qmakeCXX == "icl") {
// TODO proper support for intel cl. Detect matching VC version unless set.
if (m_msvcVersion.isEmpty())
m_msvcVersion = ProjectExplorer::MSVCToolChain::findInstallationByMkSpec(isQt64Bit(), mkspec).name;
m_toolChains << ToolChainPtr(
ProjectExplorer::ToolChain::createMSVCToolChain(m_msvcVersion, isQt64Bit()));
m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID));
} else if (qmakeCXX == "g++" && makefileGenerator == "MINGW") {
Utils::Environment env = Utils::Environment::systemEnvironment();
//addToEnvironment(env);
env.prependOrSetPath(mingwDirectory() + "/bin");
qmakeCXX = env.searchInPath(qmakeCXX);
m_toolChains << ToolChainPtr(
ProjectExplorer::ToolChain::createMinGWToolChain(qmakeCXX, mingwDirectory()));
m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID));
} else if (qmakeCXX.contains("g++")) { // All g++ variants are treated as desktop g++
// we should try to do a better job, but for now that's good enough
Utils::Environment env = Utils::Environment::systemEnvironment();
//addToEnvironment(env);
qmakeCXX = env.searchInPath(qmakeCXX);
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createGccToolChain(qmakeCXX));
m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID));
} else if (qmakeCXX == QLatin1String("icpc")) {
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createLinuxIccToolChain());
} else if (qmakeCXX.contains("g++")
|| qmakeCXX == "cl" || qmakeCXX == "icl" // intel cl
|| qmakeCXX == QLatin1String("icpc")) {
m_abis = ProjectExplorer::Abi::abisOfBinary(qtCorePath());
#if defined (Q_OS_WIN)
if (makefileGenerator == "MINGW") {
QList<ProjectExplorer::Abi> tmp = m_abis;
m_abis.clear();
foreach (const ProjectExplorer::Abi &abi, tmp)
m_abis.append(ProjectExplorer::Abi(abi.architecture(), abi.os(), ProjectExplorer::Abi::Windows_msys,
abi.binaryFormat(), abi.wordWidth()));
}
#endif
m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID));
}
if (m_toolChains.isEmpty()) {
qDebug()<<"Could not create ToolChain for"<<m_mkspecFullPath<<qmakeCXX;
qDebug()<<"Qt Creator doesn't know about the system includes, nor the systems defines.";
if (m_abis.isEmpty()) {
qDebug() << "Could not find ABI for" << m_mkspecFullPath << qmakeCXX;
qDebug() << "Qt Creator doesn't know about the system includes, "
"nor the systems defines.";
}
QStringList configValues = evaluator.values("CONFIG");
@@ -1554,7 +1592,7 @@ void QtVersion::updateToolChainAndMkspec() const
}
ProFileCacheManager::instance()->decRefCount();
m_toolChainUpToDate = true;
m_abiUpToDate = true;
}
QString QtVersion::resolveLink(const QString &path) const
@@ -1568,16 +1606,26 @@ QString QtVersion::resolveLink(const QString &path) const
return f.filePath();
}
QString QtVersion::mwcDirectory() const
QString QtVersion::qtCorePath() const
{
return m_mwcDirectory;
QString path = libraryInstallPath();
QStringList toTest;
toTest << path + QLatin1String("/libQtCore.so.") + qtVersionString();
toTest << path + QLatin1String("/libQtCore.so");
toTest << path + QLatin1String("/QtCore.dll");
toTest << path + QLatin1String("/QtCored.dll");
toTest << path + QLatin1String("/QtCore4.dll");
toTest << path + QLatin1String("/QtCored4.dll");
toTest << path + QLatin1String("/QtCore.framework/QtCore");
foreach (const QString &path, toTest) {
if (QFileInfo(path).exists())
return path;
}
return QString();
}
void QtVersion::setMwcDirectory(const QString &directory)
{
m_mwcDirectory = directory;
m_toolChainUpToDate = false;
}
QString QtVersion::s60SDKDirectory() const
{
return m_s60SDKDirectory;
@@ -1586,18 +1634,7 @@ QString QtVersion::s60SDKDirectory() const
void QtVersion::setS60SDKDirectory(const QString &directory)
{
m_s60SDKDirectory = directory;
m_toolChainUpToDate = false;
}
QString QtVersion::gcceDirectory() const
{
return m_gcceDirectory;
}
void QtVersion::setGcceDirectory(const QString &directory)
{
m_gcceDirectory = directory;
m_toolChainUpToDate = false;
m_abiUpToDate = false;
}
QString QtVersion::sbsV2Directory() const
@@ -1610,41 +1647,80 @@ void QtVersion::setSbsV2Directory(const QString &directory)
m_sbsV2Directory = directory;
}
QString QtVersion::mingwDirectory() const
{
return m_mingwDirectory;
}
void QtVersion::setMingwDirectory(const QString &directory)
{
m_mingwDirectory = directory;
m_toolChainUpToDate = false;
}
QString QtVersion::msvcVersion() const
{
return m_msvcVersion;
}
void QtVersion::setMsvcVersion(const QString &version)
{
m_msvcVersion = version;
m_toolChainUpToDate = false;
}
void QtVersion::addToEnvironment(Utils::Environment &env) const
{
// Generic:
env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA")));
if (isBuildWithSymbianSbsV2()) {
QString sbsHome(env.value(QLatin1String("SBS_HOME")));
if (!m_sbsV2Directory.isEmpty()) {
env.prependOrSetPath(m_sbsV2Directory);
env.unset(QLatin1String("SBS_HOME")); // unset SBS_HOME to prevent SBS from picking it up
} else if (!sbsHome.isEmpty()) {
env.prependOrSetPath(sbsHome + QLatin1Char('/') + QLatin1String("bin"));
env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
// Symbian specific:
if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID)
|| supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) {
// Generic Symbian environment:
QString epocRootPath(systemRoot());
QDir epocDir(epocRootPath);
if (!epocRootPath.endsWith(QLatin1Char('/')))
epocRootPath.append(QLatin1Char('/'));
env.set(QLatin1String("EPOCROOT"), QDir::toNativeSeparators(S60Devices::cleanedRootPath(epocRootPath)));
env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/tools"))); // e.g. make.exe
// Windows only:
if (ProjectExplorer::Abi::hostAbi().os() == ProjectExplorer::Abi::Windows) {
QString winDir = QLatin1String(qgetenv("WINDIR"));
if (!winDir.isEmpty())
env.prependOrSetPath(QDir(winDir).filePath(QLatin1String("system32")));
if (epocDir.exists(QLatin1String("epoc32/gcc/bin")))
env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/gcc/bin"))); // e.g. cpp.exe, *NOT* gcc.exe
// Find perl in the special Symbian flavour:
if (epocDir.exists(QLatin1String("../../tools/perl/bin"))) {
epocDir.cd(QLatin1String("../../tools/perl/bin"));
env.prependOrSetPath(epocDir.absolutePath());
} else {
env.prependOrSetPath(epocDir.filePath(QLatin1String("perl/bin")));
}
}
// SBSv2:
if (isBuildWithSymbianSbsV2()) {
QString sbsHome(env.value(QLatin1String("SBS_HOME")));
if (!m_sbsV2Directory.isEmpty()) {
env.prependOrSetPath(m_sbsV2Directory + QLatin1String("/bin"));
env.unset(QLatin1String("SBS_HOME")); // unset SBS_HOME to prevent SBS from picking it up
} else if (!sbsHome.isEmpty()) {
env.prependOrSetPath(sbsHome + QLatin1Char('/') + QLatin1String("bin"));
}
}
}
env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
}
static const char *S60_EPOC_HEADERS[] = {
"include", "mkspecs/common/symbian", "epoc32/include",
"epoc32/include/osextensions/stdapis", "epoc32/include/osextensions/stdapis/sys",
"epoc32/include/stdapis", "epoc32/include/stdapis/sys",
"epoc32/include/osextensions/stdapis/stlport", "epoc32/include/stdapis/stlport",
"epoc32/include/oem", "epoc32/include/middleware", "epoc32/include/domain/middleware",
"epoc32/include/osextensions", "epoc32/include/domain/osextensions",
"epoc32/include/domain/osextensions/loc", "epoc32/include/domain/middleware/loc",
"epoc32/include/domain/osextensions/loc/sc", "epoc32/include/domain/middleware/loc/sc"
};
QList<ProjectExplorer::HeaderPath> QtVersion::systemHeaderPathes() const
{
QList<ProjectExplorer::HeaderPath> result;
if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID)
|| supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) {
QString root = systemRoot() + QLatin1Char('/');
const int count = sizeof(S60_EPOC_HEADERS) / sizeof(const char *);
for (int i = 0; i < count; ++i) {
const QDir dir(root + QLatin1String(S60_EPOC_HEADERS[i]));
if (dir.exists())
result.append(ProjectExplorer::HeaderPath(dir.absolutePath(),
ProjectExplorer::HeaderPath::GlobalHeaderPath));
}
}
return result;
}
int QtVersion::uniqueId() const
@@ -1660,12 +1736,15 @@ int QtVersion::getUniqueId()
bool QtVersion::isValid() const
{
updateVersionInfo();
updateAbiAndMkspec();
return m_id != -1
&& !qmakeCommand().isEmpty()
&& !displayName().isEmpty()
&& !m_notInstalled
&& m_versionInfo.contains("QT_INSTALL_BINS")
&& (!m_mkspecFullPath.isEmpty() || !m_toolChainUpToDate);
&& (!m_mkspecFullPath.isEmpty() || !m_abiUpToDate)
&& !m_abis.isEmpty();
}
QString QtVersion::invalidReason() const
@@ -1681,7 +1760,7 @@ QString QtVersion::invalidReason() const
if (!m_versionInfo.contains("QT_INSTALL_BINS"))
return QCoreApplication::translate("QtVersion",
"Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?");
if (m_toolChainUpToDate && m_mkspecFullPath.isEmpty())
if (m_abiUpToDate && m_mkspecFullPath.isEmpty())
return QCoreApplication::translate("QtVersion", "The default mkspec symlink is broken.");
return QString();
}
@@ -1690,8 +1769,6 @@ QString QtVersion::description() const
{
if (!isValid())
return invalidReason();
if (possibleToolChainTypes().isEmpty())
return QCoreApplication::translate("QtVersion", "This Qt Version has a unknown toolchain.");
QSet<QString> targets = supportedTargetIds();
QString envs;
if (targets.contains(Constants::DESKTOP_TARGET_ID))
@@ -1715,7 +1792,7 @@ QString QtVersion::description() const
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
{
updateToolChainAndMkspec();
updateAbiAndMkspec();
QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0);
if (m_defaultConfigIsDebugAndRelease)
@@ -1752,13 +1829,15 @@ bool QtVersion::hasQmlObserver() const
Utils::Environment QtVersion::qmlToolsEnvironment() const
{
// FIXME: This seems broken!
Utils::Environment environment = Utils::Environment::systemEnvironment();
addToEnvironment(environment);
// add preferred toolchain, as that is how the tools are built, compare QtVersion::buildDebuggingHelperLibrary
QList<QSharedPointer<ProjectExplorer::ToolChain> > alltc = toolChains();
QList<ProjectExplorer::ToolChain *> alltc =
ProjectExplorer::ToolChainManager::instance()->findToolChains(qtAbis().at(0));
if (!alltc.isEmpty())
alltc.first().data()->addToEnvironment(environment);
alltc.first()->addToEnvironment(environment);
return environment;
}
@@ -1805,31 +1884,9 @@ QStringList QtVersion::debuggingHelperLibraryLocations() const
bool QtVersion::supportsBinaryDebuggingHelper() const
{
foreach (ProjectExplorer::ToolChainType type, possibleToolChainTypes())
switch (type) {
case ProjectExplorer::ToolChain_GCC:
case ProjectExplorer::ToolChain_LINUX_ICC:
case ProjectExplorer::ToolChain_MinGW:
case ProjectExplorer::ToolChain_MSVC:
case ProjectExplorer::ToolChain_WINCE:
case ProjectExplorer::ToolChain_GCC_MAEMO5:
case ProjectExplorer::ToolChain_GCC_HARMATTAN:
case ProjectExplorer::ToolChain_GCC_MEEGO:
case ProjectExplorer::ToolChain_OTHER:
case ProjectExplorer::ToolChain_UNKNOWN:
return true;
case ProjectExplorer::ToolChain_WINSCW:
case ProjectExplorer::ToolChain_GCCE :
case ProjectExplorer::ToolChain_RVCT2_ARMV5:
case ProjectExplorer::ToolChain_RVCT2_ARMV6:
case ProjectExplorer::ToolChain_RVCT4_ARMV5:
case ProjectExplorer::ToolChain_RVCT4_ARMV6:
case ProjectExplorer::ToolChain_GCCE_GNUPOC:
case ProjectExplorer::ToolChain_RVCT_ARMV5_GNUPOC:
case ProjectExplorer::ToolChain_INVALID:
break;
}
return false;
if (!isValid())
return false;
return qtAbis().at(0).os() != ProjectExplorer::Abi::Symbian;
}
bool QtVersion::hasDocumentation() const
@@ -1872,6 +1929,12 @@ QString QtVersion::frameworkInstallPath() const
#endif
}
QString QtVersion::libraryInstallPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_LIBS"];
}
bool QtVersion::hasExamples() const
{
updateVersionInfo();
@@ -1884,16 +1947,6 @@ QString QtVersion::examplesPath() const
return m_versionInfo["QT_INSTALL_EXAMPLES"];
}
bool QtVersion::isQt64Bit() const
{
#ifdef Q_OS_WIN
const QString qmake = qmakeCommand();
return qmake.isEmpty() ? false : Utils::winIs64BitBinary(qmake);
#else
return false;
#endif
}
void QtVersion::invalidateCache()
{
m_versionInfoUpToDate = false;