Newer
Older
/**************************************************************************
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** If you are unsure which license is appropriate for your use, please
**************************************************************************/
#include "qt4projectmanagerconstants.h"
#include "profilereader.h"
#include "qt-s60/s60projectchecker.h"
#include <projectexplorer/debugginghelper.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/cesdkhandler.h>
#include <utils/synchronousprocess.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QTextStream>
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
#ifdef Q_OS_WIN32
#include <windows.h>
#endif
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::DebuggingHelperLibrary;
static const char *QtVersionsSectionName = "QtVersions";
static const char *newQtVersionsKey = "NewQtVersions";
static const char *PATH_AUTODETECTION_SOURCE = "PATH";
enum { debug = 0 };
QtVersionManager *QtVersionManager::m_self = 0;
QtVersionManager::QtVersionManager()
: m_emptyVersion(new QtVersion)
{
QSettings *s = Core::ICore::instance()->settings();
m_idcount = 1;
int size = s->beginReadArray(QtVersionsSectionName);
for (int i = 0; i < size; ++i) {
s->setArrayIndex(i);
// Find the right id
// Either something saved or something generated
// Note: This code assumes that either all ids are read from the settings
// or generated on the fly.
int id = s->value("Id", -1).toInt();
if (id == -1)
id = getUniqueId();
QString autodetectionSource;
if (s->contains("isAutodetected")) {
isAutodetected = s->value("isAutodetected", false).toBool();
autodetectionSource = s->value("autodetectionSource", QString()).toString();
} else {// compatibility
isAutodetected = s->value("IsSystemVersion", false).toBool();
if (isAutodetected)
autodetectionSource = QLatin1String(PATH_AUTODETECTION_SOURCE);
}
QString qmakePath = s->value("QMakePath").toString();
if (qmakePath.isEmpty()) {
QString path = s->value("Path").toString();
if (!path.isEmpty()) {
foreach(const QString& command, ProjectExplorer::DebuggingHelperLibrary::possibleQMakeCommands())
{
QFileInfo fi(path + "/bin/" + command);
if (fi.exists())
{
qmakePath = fi.filePath();
break;
}
}
}
}
qmakePath,
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());
m_versions.append(version);
}
s->endArray();
updateUniqueIdToIndexMap();
++m_idcount;
addNewVersionsFromInstaller();
updateSystemVersion();
writeVersionsIntoSettings();
// cannot call from ctor, needs to get connected extenernally first
QTimer::singleShot(0, this, SLOT(updateExamples()));
}
QtVersionManager::~QtVersionManager()
{
qDeleteAll(m_versions);
m_versions.clear();
delete m_emptyVersion;
m_emptyVersion = 0;
}
QtVersionManager *QtVersionManager::instance()
if (m_versions.contains(version))
return;
int uniqueId = version->uniqueId();
m_uniqueIdToIndex.insert(uniqueId, m_versions.count() - 1);
emit qtVersionsChanged(QList<int>() << uniqueId);
writeVersionsIntoSettings();
void QtVersionManager::removeVersion(QtVersion *version)
{
int uniqueId = version->uniqueId();
m_uniqueIdToIndex.remove(uniqueId);
emit qtVersionsChanged(QList<int>() << uniqueId);
writeVersionsIntoSettings();
delete version;
}
bool QtVersionManager::supportsTargetId(const QString &id) const
{
foreach (QtVersion *version, m_versions) {
if (version->supportsTargetId(id))
return true;
}
return false;
}
QList<QtVersion *> QtVersionManager::versionsForTargetId(const QString &id) const
{
QList<QtVersion *> targetVersions;
foreach (QtVersion *version, m_versions) {
if (version->supportsTargetId(id))
targetVersions.append(version);
}
return targetVersions;
}
QSet<QString> QtVersionManager::supportedTargetIds() const
{
QSet<QString> results;
foreach (QtVersion *version, m_versions)
results.unite(version->supportedTargetIds());
return results;
}
Core::HelpManager *helpManager = Core::HelpManager::instance();
const QString docPath = version->documentationPath() + QLatin1String("/qch/");
const QDir versionHelpDir(docPath);
foreach (const QString &helpFile,
versionHelpDir.entryList(QStringList() << QLatin1String("*.qch"), QDir::Files))
files << docPath + helpFile;
void QtVersionManager::updateExamples()
{
QtVersion *version = 0;
QList<QtVersion*> candidates;
// try to find a version which has both, demos and examples
foreach (version, m_versions) {
if (version->hasExamples() && version->hasDemos())
candidates.append(version);
}
// prefer versions with declarative examples
foreach (version, candidates) {
if (QDir(version->examplesPath()+"/declarative").exists()) {
emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath());
if (!candidates.isEmpty()) {
version = candidates.first();
emit updateExamples(version->examplesPath(), version->demosPath(), version->sourcePath());
return;
}
return;
int QtVersionManager::getUniqueId()
{
return m_idcount++;
}
void QtVersionManager::updateUniqueIdToIndexMap()
{
m_uniqueIdToIndex.clear();
m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i);
}
void QtVersionManager::writeVersionsIntoSettings()
{
QSettings *s = Core::ICore::instance()->settings();
s->beginWriteArray(QtVersionsSectionName);
const QtVersion *version = m_versions.at(i);
s->setValue("Name", version->displayName());
// for downwards compat
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());
QList<QtVersion *> QtVersionManager::versions() const
QList<QtVersion *> QtVersionManager::validVersions() const
{
QList<QtVersion *> results;
foreach(QtVersion *v, m_versions) {
if (v->isValid())
results.append(v);
}
return results;
}
bool QtVersionManager::isValidId(int id) const
{
int pos = m_uniqueIdToIndex.value(id, -1);
return (pos != -1);
}
QtVersion *QtVersionManager::version(int id) const
{
int pos = m_uniqueIdToIndex.value(id, -1);
if (pos != -1)
return m_versions.at(pos);
}
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;
// i.e.
// NewQtVersions="versionname=pathtoversion=mingw=s60sdk=gcce=carbide;"
// 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);

Daniel Molkentin
committed
QDateTime lastUpdateFromGlobalSettings = globalSettings->value(
QLatin1String("General/LastQtVersionUpdate")).toDateTime();
const QFileInfo gsFi(globalSettings->fileName());
if ( !lastUpdateFromGlobalSettings.isNull() &&
(!gsFi.exists() || (gsFi.lastModified() > lastUpdateFromGlobalSettings)) )
if (!globalSettings->contains(newQtVersionsKey) &&
!globalSettings->contains(QLatin1String("Installer/")+newQtVersionsKey))
{
return;
}
QString newVersionsValue = settings->value(newQtVersionsKey).toString();

Daniel Molkentin
committed
if (newVersionsValue.isEmpty())
newVersionsValue = settings->value(QLatin1String("Installer/")+newQtVersionsKey).toString();
QStringList newVersionsList = newVersionsValue.split(';', QString::SkipEmptyParts);
foreach (const QString &newVersion, newVersionsList) {
if (newVersionData.count() >= 2) {
if (QFile::exists(newVersionData[1])) {
QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ );
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]);
bool versionWasAlreadyInList = false;
foreach(const QtVersion * const it, m_versions) {
if (QDir(version->qmakeCommand()).canonicalPath() == QDir(it->qmakeCommand()).canonicalPath()) {
versionWasAlreadyInList = true;
break;
}
}
if (!versionWasAlreadyInList) {
m_versions.append(version);
} else {
// clean up
delete version;
}
}
}
}
updateUniqueIdToIndexMap();
settings->setValue(QLatin1String("General/LastQtVersionUpdate"), QDateTime::currentDateTime());
}
void QtVersionManager::updateSystemVersion()
{
bool haveSystemVersion = false;
QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
if (systemQMakePath.isNull())
systemQMakePath = tr("<not found>");
if (version->isAutodetected()
&& version->autodetectionSource() == PATH_AUTODETECTION_SOURCE) {
version->setQMakeCommand(systemQMakePath);
version->setDisplayName(tr("Qt in PATH"));
haveSystemVersion = true;
}
}
if (haveSystemVersion)
return;
QtVersion *version = new QtVersion(tr("Qt in PATH"),
systemQMakePath,
true,
PATH_AUTODETECTION_SOURCE);
m_versions.prepend(version);
updateUniqueIdToIndexMap();
}
QtVersion *QtVersionManager::emptyVersion() const
class SortByUniqueId
{
public:
bool operator()(QtVersion *a, QtVersion *b)
{
return a->uniqueId() < b->uniqueId();
}
};
bool QtVersionManager::equals(QtVersion *a, QtVersion *b)
{
if (a->m_qmakeCommand != b->m_qmakeCommand)
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;
void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions)
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
// We want to preserve the same order as in the settings dialog
// so we sort a copy
QList<QtVersion *> sortedNewVersions = newVersions;
SortByUniqueId sortByUniqueId;
qSort(sortedNewVersions.begin(), sortedNewVersions.end(), sortByUniqueId);
qSort(m_versions.begin(), m_versions.end(), sortByUniqueId);
QList<int> changedVersions;
// So we trying to find the minimal set of changed versions,
// iterate over both sorted list
// newVersions and oldVersions iterator
QList<QtVersion *>::const_iterator nit, nend, oit, oend;
nit = sortedNewVersions.constBegin();
nend = sortedNewVersions.constEnd();
oit = m_versions.constBegin();
oend = m_versions.constEnd();
while (nit != nend && oit != oend) {
int nid = (*nit)->uniqueId();
int oid = (*oit)->uniqueId();
if (nid < oid) {
changedVersions.push_back(nid);
++nit;
} else if (oid < nid) {
changedVersions.push_back(oid);
++oit;
} else {
if (!equals(*oit, *nit))
changedVersions.push_back(oid);
++oit;
++nit;
while (nit != nend) {
changedVersions.push_back((*nit)->uniqueId());
}
while (oit != oend) {
changedVersions.push_back((*oit)->uniqueId());
qDeleteAll(m_versions);
m_versions.clear();
if (!changedVersions.isEmpty())
updateDocumentation();
updateUniqueIdToIndexMap();
updateExamples();
writeVersionsIntoSettings();
if (!changedVersions.isEmpty())
emit qtVersionsChanged(changedVersions);
QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id,
bool isAutodetected, const QString &autodetectionSource)
m_isAutodetected(isAutodetected),
m_autodetectionSource(autodetectionSource),
m_hasDebuggingHelper(false),
m_toolChainUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
setQMakeCommand(qmakeCommand);
QtVersion::QtVersion(const QString &name, const QString &qmakeCommand,
bool isAutodetected, const QString &autodetectionSource)
m_isAutodetected(isAutodetected),
m_autodetectionSource(autodetectionSource),
m_hasDebuggingHelper(false),
m_toolChainUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false)
{
m_id = getUniqueId();
setQMakeCommand(qmakeCommand);
}
QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QString &autodetectionSource)
: m_isAutodetected(isAutodetected),
m_autodetectionSource(autodetectionSource),
m_hasDebuggingHelper(false),
m_toolChainUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false)
setQMakeCommand(qmakeCommand);
m_isAutodetected(false),
m_hasDebuggingHelper(false),
m_toolChainUpToDate(false),
m_versionInfoUpToDate(false),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasExamples(false),
m_hasDemos(false),
m_hasDocumentation(false)
{
QtVersion::~QtVersion()
{
}
QString QtVersion::toHtml() const
{
QString rc;
QTextStream str(&rc);
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>";
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>";
}
return rc;
}
bool QtVersion::supportsShadowBuilds() const
{
QSet<QString> targets = supportedTargetIds();
// Symbian does not support shadow building
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
targets.contains(Constants::S60_EMULATOR_TARGET_ID)) {
// We can not support shadow building with the ABLD system
return false;
}
return true;
}
QList<ProjectExplorer::Task>
QtVersion::reportIssues(const QString &proFile, const QString &buildDir)
{
QList<ProjectExplorer::Task> results;
QString tmpBuildDir = buildDir;
if (!buildDir.endsWith(QChar('/')))
tmpBuildDir.append(QChar('/'));
if (!isValid()) {
//: %1: Reason for being invalid
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason());
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1,
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
QFileInfo qmakeInfo(qmakeCommand());
if (!qmakeInfo.exists() ||
!qmakeInfo.isExecutable()) {
//: %1: Path to qmake executable
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"The qmake command \"%1\" was not found or is not executable.").arg(qmakeCommand());
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1,
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
QString sourcePath = QFileInfo(proFile).absolutePath();
if (!sourcePath.endsWith(QChar('/')))
sourcePath.append(QChar('/'));
if ((tmpBuildDir.startsWith(sourcePath)) && (tmpBuildDir != sourcePath)) {
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"Qmake does not support build directories below the source directory.");
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1,
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
} else if (tmpBuildDir.count(QChar('/')) != sourcePath.count(QChar('/'))) {
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
"The build directory needs to be at the same level as the source directory.");
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1,
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
}
QSet<QString> targets = supportedTargetIds();
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
targets.contains(Constants::S60_EMULATOR_TARGET_ID))
results.append(S60ProjectChecker::reportIssues(proFile, this));
return results;
}
QString QtVersion::displayName() const
QString QtVersion::qmakeCommand() const
return m_qmakeCommand;
}
QString QtVersion::sourcePath() const
{
return m_sourcePath;
}
QString QtVersion::mkspec() const
{
bool QtVersion::isBuildWithSymbianSbsV2() const
{
updateToolChainAndMkspec();
return m_isBuildUsingSbsV2;
}
QString QtVersion::qtVersionString() const
{
if (m_qtVersionString.isNull()) {
QFileInfo qmake(m_qmakeCommand);
if (qmake.exists() && qmake.isExecutable()) {
m_qtVersionString = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath());
} else {
m_qtVersionString = QLatin1String("");
}
}
return m_qtVersionString;
}
QHash<QString,QString> QtVersion::versionInfo() const
{
updateVersionInfo();
return m_versionInfo;
}
void QtVersion::setDisplayName(const QString &name)
void QtVersion::setQMakeCommand(const QString& qmakeCommand)
m_qmakeCommand = QDir::fromNativeSeparators(qmakeCommand);
m_qmakeCommand = m_qmakeCommand.toLower();
m_designerCommand.clear();
m_linguistCommand.clear();

Kai Koehne
committed
m_qmlviewerCommand.clear();
m_toolChainUpToDate = false;
// TODO do i need to optimize this?
m_versionInfoUpToDate = false;
updateSourcePath();
updateVersionInfo();
const QString installData = m_versionInfo["QT_INSTALL_DATA"];
m_sourcePath = installData;
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
if (qmakeCache.exists()) {
qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream stream(&qmakeCache);
while (!stream.atEnd()) {
QString line = stream.readLine().trimmed();
if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
m_sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
if (m_sourcePath.startsWith(QLatin1String("$$quote("))) {
m_sourcePath.remove(0, 8);
m_sourcePath.chop(1);
}
break;
}
}
}
m_sourcePath = QDir::cleanPath(m_sourcePath);
#ifdef Q_OS_WIN
m_sourcePath = m_sourcePath.toLower();
#endif
}
// Returns the version that was used to build the project in that directory
// That is returns the directory
// To find out whether we already have a qtversion for that directory call
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
{
bool debugAdding = false;
QFile makefile(directory + "/Makefile" );
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
QTextStream ts(&makefile);
while (!ts.atEnd()) {
QString line = ts.readLine();
if (r1.exactMatch(line)) {
if (debugAdding)
qDebug()<<"#~~ QMAKE is:"<<r1.cap(1).trimmed();
QFileInfo qmake(r1.cap(1).trimmed());
QString qmakePath = qmake.filePath();
if (!qmakePath.endsWith(QLatin1String(".exe")))
qmakePath.append(QLatin1String(".exe"));
// Is qmake still installed?
QFileInfo fi(qmakePath);
if (fi.exists()) {
qmakePath = fi.absoluteFilePath();
#ifdef Q_OS_WIN
qmakePath = qmakePath.toLower();
#endif
return qmakePath;
QtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath)
if (v->qmakeCommand() == qmakePath) {
return v;
break;
}
}
void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
foreach(const QMakeAssignment &qa, list) {
qDebug()<<qa.variable<<qa.op<<qa.value;
}
}
bool QtVersionManager::makefileIsFor(const QString &directory, const QString &proFile)
{
if (proFile.isEmpty())
return true;
QString line = findQMakeLine(directory, QLatin1String("# Project:")).trimmed();
if (line.isEmpty())
return false;
line = line.mid(line.indexOf(QChar(':')) + 1);
line = line.trimmed();
QFileInfo srcFileInfo(QDir(directory), line);
QFileInfo proFileInfo(proFile);
return srcFileInfo == proFileInfo;
}
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
if (debug)
qDebug()<<"ScanMakeFile, the gory details:";
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
QString line = findQMakeLine(directory, QLatin1String("# Command:"));
if (debug)
qDebug()<<"Found line"<<line;
line = trimLine(line);
QStringList parts = splitLine(line);
QList<QMakeAssignment> assignments;
QList<QMakeAssignment> afterAssignments;
QStringList additionalArguments;
parseParts(parts, &assignments, &afterAssignments, &additionalArguments);
if (debug) {
dumpQMakeAssignments(assignments);
if (!afterAssignments.isEmpty())
qDebug()<<"-after";
dumpQMakeAssignments(afterAssignments);
}
// Search in assignments for CONFIG(+=,-=,=)(debug,release,debug_and_release)
// Also remove them from the list
result = qmakeBuildConfigFromCmdArgs(&assignments, defaultBuildConfig);
result2.append(additionalArguments);
foreach(const QMakeAssignment &qa, assignments)
result2.append(qa.variable + qa.op + qa.value);
if (!afterAssignments.isEmpty()) {
result2.append("-after");
foreach(const QMakeAssignment &qa, afterAssignments)
result2.append(qa.variable + qa.op + qa.value);
}
}
// Dump the gathered information:
if (debug) {
qDebug()<<"\n\nDumping information from scanMakeFile";
qDebug()<<"QMake CONFIG variable parsing";
qDebug()<<" "<< (result & QtVersion::NoBuild ? "No Build" : QString::number(int(result)));
qDebug()<<" "<< (result & QtVersion::DebugBuild ? "debug" : "release");
qDebug()<<" "<< (result & QtVersion::BuildAll ? "debug_and_release" : "no debug_and_release");
qDebug()<<"\nAddtional Arguments";
qDebug()<<result2;
qDebug()<<"\n\n";
}
return qMakePair(result, result2);
}
QString QtVersionManager::findQMakeLine(const QString &directory, const QString &key)
QFile makefile(directory + QLatin1String("/Makefile" ));
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
QTextStream ts(&makefile);
while (!ts.atEnd()) {
if (line.startsWith(key))
return line;
}
}
return QString();
}
/// This function trims the "#Command /path/to/qmake" from the the line
QString QtVersionManager::trimLine(const QString line)
{
// Actually the first space after #Command: /path/to/qmake
const int firstSpace = line.indexOf(QLatin1Char(' '), 11);
return line.mid(firstSpace).trimmed();
}
QStringList QtVersionManager::splitLine(const QString &line)
{
// Split on each " ", except on those which are escaped
// On Unix also remove all escaping
// On Windows also, but different escaping
bool escape = false;
QString currentWord;
QStringList results;
int length = line.length();
for (int i=0; i<length; ++i) {
#ifdef Q_OS_WIN
if (line.at(i) == '"') {
escape = !escape;
} else if (escape || line.at(i) != ' ') {
currentWord += line.at(i);
} else {
results << currentWord;
currentWord.clear();;
}
#else
if (escape) {
currentWord += line.at(i);
escape = false;
} else if (line.at(i) == ' ') {
results << currentWord;
currentWord.clear();
} else if (line.at(i) == '\\') {
escape = true;
} else {
currentWord += line.at(i);
}
}
return results;
}
void QtVersionManager::parseParts(const QStringList &parts, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments, QStringList *additionalArguments)
{
QRegExp regExp("([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)");
bool after = false;
bool ignoreNext = false;
foreach (const QString &part, parts) {
if (ignoreNext) {
// Ignoring
ignoreNext = false;
} else if (part == "-after") {
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
after = true;
} else if(part.contains('=')) {
if (regExp.exactMatch(part)) {
QMakeAssignment qa;
qa.variable = regExp.cap(1);
qa.op = regExp.cap(2);
qa.value = regExp.cap(3).trimmed();
if (after)
afterAssignments->append(qa);
else
assignments->append(qa);
} else {
qDebug()<<"regexp did not match";
}
} else if (part == "-o") {
ignoreNext = true;
} else {
additionalArguments->append(part);
}
}
#if defined(Q_OS_WIN32)
additionalArguments->removeAll("-win32");
#elif defined(Q_OS_MAC)
additionalArguments->removeAll("-macx");
#elif defined(Q_OS_QNX6)
additionalArguments->removeAll("-qnx6");
#else
additionalArguments->removeAll("-unix");
#endif
}
/// This function extracts all the CONFIG+=debug, CONFIG+=release
QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfigs defaultBuildConfig)
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
QList<QMakeAssignment> oldAssignments = *assignments;
assignments->clear();
foreach(const QMakeAssignment &qa, oldAssignments) {
if (qa.variable == "CONFIG") {
QStringList values = qa.value.split(' ');
QStringList newValues;
foreach(const QString &value, values) {
if (value == "debug") {
if (qa.op == "+=")
result = result | QtVersion::DebugBuild;
result = result & ~QtVersion::DebugBuild;
} else if (value == "release") {
if (qa.op == "+=")
result = result & ~QtVersion::DebugBuild;
result = result | QtVersion::DebugBuild;
} else if (value == "debug_and_release") {
if (qa.op == "+=")
result = result | QtVersion::BuildAll;
result = result & ~QtVersion::BuildAll;
} else {
newValues.append(value);
QMakeAssignment newQA = qa;
newQA.value = newValues.join(" ");
if (!newValues.isEmpty())
assignments->append(newQA);
} else {
assignments->append(qa);
static bool queryQMakeVariables(const QString &binary, QHash<QString, QString> *versionInfo)
const int timeOutMS = 30000; // Might be slow on some machines.
QFileInfo qmake(binary);
if (!qmake.exists() || !qmake.isExecutable())
return false;
static const char * const variables[] = {
"QT_INSTALL_DATA",
"QT_INSTALL_LIBS",
"QT_INSTALL_HEADERS",
"QT_INSTALL_DEMOS",
"QT_INSTALL_EXAMPLES",
"QT_INSTALL_CONFIGURATION",
"QT_INSTALL_TRANSLATIONS",
"QT_INSTALL_PLUGINS",
"QT_INSTALL_BINS",
"QT_INSTALL_DOCS",
QStringList args;
for (uint i = 0; i < sizeof variables / sizeof variables[0]; ++i)
args << "-query" << variables[i];
QProcess process;
process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly);
if (!process.waitForStarted()) {
qWarning("Cannot start '%s': %s", qPrintable(binary), qPrintable(process.errorString()));
return false;
}
if (!process.waitForFinished(timeOutMS)) {
Utils::SynchronousProcess::stopProcess(process);
qWarning("Timeout running '%s' (%dms).", qPrintable(binary), timeOutMS);
return false;
}
if (process.exitStatus() != QProcess::NormalExit) {
qWarning("'%s' crashed.", qPrintable(binary));
return false;
}
QByteArray output = process.readAllStandardOutput();
QTextStream stream(&output);
while (!stream.atEnd()) {
const QString line = stream.readLine();
const int index = line.indexOf(QLatin1Char(':'));
if (index != -1) {
const QString value = QDir::fromNativeSeparators(line.mid(index+1));
if (value != "**Unknown**")
versionInfo->insert(line.left(index), value);
}
return true;
}
void QtVersion::updateVersionInfo() const
{
if (m_versionInfoUpToDate)
return;
// extract data from qmake executable
m_versionInfo.clear();
m_notInstalled = false;
m_hasExamples = false;
m_hasDocumentation = false;
m_hasDebuggingHelper = false;
if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo))
return;
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
if (m_versionInfo.contains("QT_INSTALL_DATA")) {
QString qtInstallData = m_versionInfo.value("QT_INSTALL_DATA");
m_versionInfo.insert("QMAKE_MKSPECS", QDir::cleanPath(qtInstallData+"/mkspecs"));
if (!qtInstallData.isEmpty())
m_hasDebuggingHelper = !DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty();
}
// Now check for a qt that is configured with a prefix but not installed
if (m_versionInfo.contains("QT_INSTALL_BINS")) {
QFileInfo fi(m_versionInfo.value("QT_INSTALL_BINS"));
if (!fi.exists())
m_notInstalled = true;
}
if (m_versionInfo.contains("QT_INSTALL_HEADERS")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_HEADERS"));
if (!fi.exists())
m_notInstalled = true;
}
if (m_versionInfo.contains("QT_INSTALL_DOCS")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_DOCS"));
if (fi.exists())
m_hasDocumentation = true;
}
if (m_versionInfo.contains("QT_INSTALL_EXAMPLES")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_EXAMPLES"));
if (fi.exists())
m_hasExamples = true;
}
if (m_versionInfo.contains("QT_INSTALL_DEMOS")){
QFileInfo fi(m_versionInfo.value("QT_INSTALL_DEMOS"));
if (fi.exists())
m_hasDemos = true;
QString QtVersion::findQtBinary(const QStringList &possibleCommands) const
{
const QString qtdirbin = versionInfo().value(QLatin1String("QT_INSTALL_BINS")) + QLatin1Char('/');
foreach (const QString &possibleCommand, possibleCommands) {
const QString fullPath = qtdirbin + possibleCommand;
if (QFileInfo(fullPath).isFile())
return QDir::cleanPath(fullPath);
}
QString QtVersion::uicCommand() const
{
if (!isValid())
if (!m_uicCommand.isNull())
return m_uicCommand;
#ifdef Q_OS_WIN
const QStringList possibleCommands(QLatin1String("uic.exe"));
#else
possibleCommands << QLatin1String("uic-qt4") << QLatin1String("uic4") << QLatin1String("uic");
#endif
m_uicCommand = findQtBinary(possibleCommands);
return m_uicCommand;
}
// Return a list of GUI binary names
// 'foo', 'foo.exe', 'Foo.app/Contents/MacOS/Foo'
static inline QStringList possibleGuiBinaries(const QString &name)
{
return QStringList(name + QLatin1String(".exe"));
#elif defined(Q_OS_MAC) // 'Foo.app/Contents/MacOS/Foo'
QString upCaseName = name;
upCaseName[0] = upCaseName.at(0).toUpper();
QString macBinary = upCaseName;
macBinary += QLatin1String(".app/Contents/MacOS/");
macBinary += upCaseName;
return QStringList(macBinary);
return QStringList(name);
}
QString QtVersion::designerCommand() const
{
if (!isValid())
if (m_designerCommand.isNull())
m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer")));
return m_designerCommand;
}
QString QtVersion::linguistCommand() const
{
if (!isValid())
if (m_linguistCommand.isNull())
m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist")));
return m_linguistCommand;

Kai Koehne
committed
QString QtVersion::qmlviewerCommand() const
{
if (!isValid())
return QString();
if (m_qmlviewerCommand.isNull()) {
#ifdef Q_OS_MAC
const QString qmlViewerName = QLatin1String("QMLViewer");
#else
const QString qmlViewerName = QLatin1String("qmlviewer");
#endif
m_qmlviewerCommand = findQtBinary(possibleGuiBinaries(qmlViewerName));
}
return m_qmlviewerCommand;
}
bool QtVersion::supportsTargetId(const QString &id) const
{
updateToolChainAndMkspec();
return m_targetIds.contains(id);
}
QSet<QString> QtVersion::supportedTargetIds() const
{
updateToolChainAndMkspec();
return m_targetIds;
bool QtVersion::supportsMobileTarget() const
{
return supportsTargetId(Constants::S60_DEVICE_TARGET_ID) ||
supportsTargetId(Constants::S60_EMULATOR_TARGET_ID) ||
supportsTargetId(Constants::MAEMO_DEVICE_TARGET_ID) ||
supportsTargetId(Constants::QT_SIMULATOR_TARGET_ID);
QList<QSharedPointer<ProjectExplorer::ToolChain> > QtVersion::toolChains() const
return m_toolChains;
}
ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChain::ToolChainType type) const
{
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tcptr, toolChains())
if (tcptr->type() == type)
return tcptr.data();
return 0;
}
QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
QList<ProjectExplorer::ToolChain::ToolChainType> types;
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tc, toolChains())
types << tc->type();
return types;
}
// if none, then it's INVALID everywhere this function is called
typedef QSharedPointer<ProjectExplorer::ToolChain> ToolChainPtr;
if (m_toolChainUpToDate)
return;
if (!isValid()) {
m_targetIds.insert(Constants::DESKTOP_TARGET_ID);
// no .qmake.cache so look at the default mkspec
QString baseMkspecDir = versionInfo().value("QMAKE_MKSPECS");
if (baseMkspecDir.isEmpty())
baseMkspecDir = versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
#ifdef Q_OS_WIN
baseMkspecDir = baseMkspecDir.toLower();
#endif
QString mkspecFullPath = baseMkspecDir + "/default";
// qDebug() << "default mkspec is located at" << mkspecFullPath;
#ifdef Q_OS_WIN
QFile f2(mkspecFullPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
while (!f2.atEnd()) {
QByteArray line = f2.readLine();
if (line.startsWith("QMAKESPEC_ORIGINAL")) {
const QList<QByteArray> &temp = line.split('=');
if (temp.size() == 2) {
QString possibleFullPath = temp.at(1).trimmed();
// We sometimes get a mix of different slash styles here...
possibleFullPath = possibleFullPath.replace('\\', '/');
if (QFileInfo(possibleFullPath).exists()) // Only if the path exists
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
}
break;
}
}
f2.close();
}
#elif defined(Q_OS_MAC)
QFile f2(mkspecFullPath + "/qmake.conf");
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
while (!f2.atEnd()) {
QByteArray line = f2.readLine();
if (line.startsWith("MAKEFILE_GENERATOR")) {
const QList<QByteArray> &temp = line.split('=');
if (temp.size() == 2) {
const QByteArray &value = temp.at(1);
if (value.contains("XCODE")) {
// we don't want to generate xcode projects...
// qDebug() << "default mkspec is xcode, falling back to g++";
mkspecFullPath = baseMkspecDir + "/macx-g++";
}
//resolve mkspec link
QFileInfo f3(mkspecFullPath);
while (f3.isSymLink()) {
mkspecFullPath = f3.symLinkTarget();
f3.setFile(mkspecFullPath);
}
}
break;
}
}
f2.close();
}
#else
QFileInfo f2(mkspecFullPath);
while (f2.isSymLink()) {
mkspecFullPath = f2.symLinkTarget();
f2.setFile(mkspecFullPath);
}
#endif
#ifdef Q_OS_WIN
#endif
m_mkspecFullPath = mkspecFullPath;
QString mkspec = m_mkspecFullPath;
if (mkspec.startsWith(baseMkspecDir)) {
mkspec = mkspec.mid(baseMkspecDir.length() + 1);
} else {
QString sourceMkSpecPath = sourcePath() + "/mkspecs";
if (mkspec.startsWith(sourceMkSpecPath)) {
mkspec = mkspec.mid(sourceMkSpecPath.length() + 1);
} else {
// Do nothing
}
}
m_mkspec = mkspec;
m_isBuildUsingSbsV2 = false;
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
ProFileOption option;
option.properties = versionInfo();
ProMessageHandler msgHandler(true);
ProFileCacheManager::instance()->incRefCount();
ProFileParser parser(ProFileCacheManager::instance()->cache(), &msgHandler);
ProFileEvaluator evaluator(&option, &parser, &msgHandler);
if (ProFile *pro = parser.parsedProFile(m_mkspecFullPath + "/qmake.conf")) {
evaluator.setCumulative(false);
evaluator.accept(pro, ProFileEvaluator::LoadProOnly);
pro->deref();
}
QString qmakeCXX = evaluator.values("QMAKE_CXX").join(" ");
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");
if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) {
QString wincePlatformName = ce_sdk + " (" + ce_arch + QLatin1Char(')');
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createWinCEToolChain(msvcVersion(), wincePlatformName));
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()) {
m_targetIds.insert(QLatin1String(Constants::S60_DEVICE_TARGET_ID));
m_toolChains << ToolChainPtr(s60mgr->createGCCEToolChain(this));
if (S60Manager::hasRvctCompiler())
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV5))
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV6));
if (!mwcDirectory().isEmpty()) {
m_toolChains << ToolChainPtr(s60mgr->createWINSCWToolChain(this));
m_targetIds.insert(QLatin1String(Constants::S60_EMULATOR_TARGET_ID));
if (S60Manager::hasRvctCompiler())
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));
} else if (qt_arch.startsWith(QLatin1String("arm"))
&& MaemoManager::instance().isValidMaemoQtVersion(this)) {
m_toolChains << ToolChainPtr(MaemoManager::instance().maemoToolChain(this));
m_targetIds.insert(QLatin1String(Constants::MAEMO_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;
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);
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);
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());
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.";
}
QStringList configValues = evaluator.values("CONFIG");
m_defaultConfigIsDebugAndRelease = false;
foreach(const QString &value, configValues) {
if (value == "debug")
m_defaultConfigIsDebug = true;
else if (value == "release")
m_defaultConfigIsDebug = false;
else if (value == "build_all")
m_defaultConfigIsDebugAndRelease = true;
}
// Is this actually a simulator Qt?
if (configValues.contains(QLatin1String("simulator"))) {
m_targetIds.clear();
m_targetIds.insert(QLatin1String(Constants::QT_SIMULATOR_TARGET_ID));
}
ProFileCacheManager::instance()->decRefCount();
m_toolChainUpToDate = true;
QString QtVersion::mwcDirectory() const
{
return m_mwcDirectory;
}
void QtVersion::setMwcDirectory(const QString &directory)
{
m_mwcDirectory = directory;
QString QtVersion::s60SDKDirectory() const
{
return m_s60SDKDirectory;
}
void QtVersion::setS60SDKDirectory(const QString &directory)
{
m_s60SDKDirectory = directory;
QString QtVersion::gcceDirectory() const
{
return m_gcceDirectory;
}
void QtVersion::setGcceDirectory(const QString &directory)
{
m_gcceDirectory = 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
env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA")));
env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
}
int QtVersion::uniqueId() const
{
return m_id;
}
int QtVersion::getUniqueId()
{
return QtVersionManager::instance()->getUniqueId();
&& !qmakeCommand().isEmpty()
&& !displayName().isEmpty()
&& !m_notInstalled
&& m_versionInfo.contains("QT_INSTALL_BINS");
}
QString QtVersion::invalidReason() const
{
if (isValid())
return QString();
return QCoreApplication::translate("QtVersion", "No qmake path set");
return QCoreApplication::translate("QtVersion", "Qt version has no name");
return QCoreApplication::translate("QtVersion", "Qt version is not properly installed, please run make install");
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?");
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0);
if (m_defaultConfigIsDebugAndRelease)
result = QtVersion::BuildAll;
if (m_defaultConfigIsDebug)
result = result | QtVersion::DebugBuild;
bool QtVersion::hasDebuggingHelper() const
{
return m_hasDebuggingHelper;
}
QString QtVersion::debuggingHelperLibrary() const
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
QStringList QtVersion::debuggingHelperLibraryLocations() const
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
return DebuggingHelperLibrary::debuggingHelperLibraryLocationsByInstallData(qtInstallData);
bool QtVersion::supportsBinaryDebuggingHelper() const
{
QList<ProjectExplorer::ToolChain::ToolChainType> types = possibleToolChainTypes();
if (types.contains(ProjectExplorer::ToolChain::GCC)
|| types.contains(ProjectExplorer::ToolChain::LINUX_ICC)
|| types.contains(ProjectExplorer::ToolChain::MSVC)
|| types.contains(ProjectExplorer::ToolChain::WINCE)
|| types.contains(ProjectExplorer::ToolChain::GCC_MAEMO)
|| types.contains(ProjectExplorer::ToolChain::OTHER)
|| types.contains(ProjectExplorer::ToolChain::UNKNOWN))
return true;
return false;
}
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
bool QtVersion::hasDocumentation() const
{
updateVersionInfo();
return m_hasDocumentation;
}
QString QtVersion::documentationPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_DOCS"];
}
bool QtVersion::hasDemos() const
{
updateVersionInfo();
return m_hasDemos;
}
QString QtVersion::demosPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_DEMOS"];
}
QString QtVersion::headerInstallPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_HEADERS"];
}
bool QtVersion::hasExamples() const
{
updateVersionInfo();
return m_hasExamples;
}
QString QtVersion::examplesPath() const
{
updateVersionInfo();
return m_versionInfo["QT_INSTALL_EXAMPLES"];
}
{
const QString make = qmakeCommand();
bool isAmd64 = false;
#ifdef Q_OS_WIN32
# ifdef __GNUC__ // MinGW lacking some definitions/winbase.h
# define SCS_64BIT_BINARY 6
# endif
bool success = GetBinaryTypeW(reinterpret_cast<const TCHAR*>(make.utf16()), &binaryType) != 0;
if (success && binaryType == SCS_64BIT_BINARY)
isAmd64=true;
// qDebug() << "isAmd64:" << isAmd64 << binaryType;
return isAmd64;
#else
Q_UNUSED(isAmd64)
return false;
QString QtVersion::buildDebuggingHelperLibrary()
{
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
if (qtInstallData.isEmpty())
Utils::Environment env = Utils::Environment::systemEnvironment();
addToEnvironment(env);
// TODO: the debugging helper doesn't comply to actual tool chain yet
QList<QSharedPointer<ProjectExplorer::ToolChain> > alltc = toolChains();
ProjectExplorer::ToolChain *tc = alltc.isEmpty() ? 0 : alltc.first().data();
return QCoreApplication::translate("QtVersion", "The Qt Version has no toolchain.");
QString output;
QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, &output);
if (!directory.isEmpty()) {
output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(),
qmakeCommand(), mkspec(), env,
(tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String("")));
}