2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qtversionmanager.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "qt4target.h"
|
2009-05-25 16:43:50 +02:00
|
|
|
#include "profilereader.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
#include "qt-maemo/maemomanager.h"
|
2010-02-08 17:51:58 +01:00
|
|
|
#include "qt-s60/s60manager.h"
|
2009-05-28 18:36:52 +02:00
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <projectexplorer/debugginghelper.h>
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
#include <projectexplorer/cesdkhandler.h>
|
2009-05-28 18:15:02 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2009-05-28 18:15:02 +02:00
|
|
|
#include <coreplugin/modemanager.h>
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-02-02 14:25:22 +01:00
|
|
|
#include <help/helpmanager.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <QtCore/QProcess>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QSettings>
|
|
|
|
#include <QtCore/QTime>
|
2009-07-27 13:55:30 +02:00
|
|
|
#include <QtCore/QTimer>
|
2009-10-27 18:05:04 +01:00
|
|
|
#include <QtCore/QTextStream>
|
2009-11-19 16:50:58 +01:00
|
|
|
#include <QtCore/QDir>
|
2009-03-25 15:18:37 +01:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QDesktopServices>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-18 10:46:12 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
using ProjectExplorer::DebuggingHelperLibrary;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
static const char *QtVersionsSectionName = "QtVersions";
|
|
|
|
static const char *newQtVersionsKey = "NewQtVersions";
|
2009-05-28 11:48:33 +02:00
|
|
|
static const char *PATH_AUTODETECTION_SOURCE = "PATH";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-08-17 11:49:59 +02:00
|
|
|
enum { debug = 0 };
|
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
QtVersionManager *QtVersionManager::m_self = 0;
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersionManager::QtVersionManager()
|
|
|
|
: m_emptyVersion(new QtVersion)
|
|
|
|
{
|
2009-05-27 18:42:27 +02:00
|
|
|
m_self = this;
|
2009-01-20 11:52:04 +01:00
|
|
|
QSettings *s = Core::ICore::instance()->settings();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
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();
|
2009-10-01 18:51:42 +02:00
|
|
|
else if (m_idcount < id)
|
|
|
|
m_idcount = id + 1;
|
2009-05-28 11:31:35 +02:00
|
|
|
bool isAutodetected;
|
2009-05-28 11:48:33 +02:00
|
|
|
QString autodetectionSource;
|
|
|
|
if (s->contains("isAutodetected")) {
|
2009-05-28 11:31:35 +02:00
|
|
|
isAutodetected = s->value("isAutodetected", false).toBool();
|
2009-05-28 11:48:33 +02:00
|
|
|
autodetectionSource = s->value("autodetectionSource", QString()).toString();
|
|
|
|
} else {// compatibility
|
2009-05-28 11:31:35 +02:00
|
|
|
isAutodetected = s->value("IsSystemVersion", false).toBool();
|
2009-05-28 11:48:33 +02:00
|
|
|
if (isAutodetected)
|
|
|
|
autodetectionSource = QLatin1String(PATH_AUTODETECTION_SOURCE);
|
|
|
|
}
|
2009-09-03 19:16:22 +02:00
|
|
|
QString qmakePath = s->value("QMakePath").toString();
|
|
|
|
if (qmakePath.isEmpty()) {
|
|
|
|
QString path = s->value("Path").toString();
|
2009-09-04 09:52:14 +02:00
|
|
|
if (!path.isEmpty()) {
|
|
|
|
foreach(const QString& command, ProjectExplorer::DebuggingHelperLibrary::possibleQMakeCommands())
|
|
|
|
{
|
|
|
|
QFileInfo fi(path + "/bin/" + command);
|
|
|
|
if (fi.exists())
|
|
|
|
{
|
|
|
|
qmakePath = fi.filePath();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-03 19:16:22 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersion *version = new QtVersion(s->value("Name").toString(),
|
2009-09-03 19:16:22 +02:00
|
|
|
qmakePath,
|
2008-12-02 12:01:29 +01:00
|
|
|
id,
|
2009-05-28 11:48:33 +02:00
|
|
|
isAutodetected,
|
|
|
|
autodetectionSource);
|
2008-12-02 12:01:29 +01:00
|
|
|
version->setMingwDirectory(s->value("MingwDirectory").toString());
|
|
|
|
version->setMsvcVersion(s->value("msvcVersion").toString());
|
2009-06-04 10:50:44 +02:00
|
|
|
version->setMwcDirectory(s->value("MwcDirectory").toString());
|
2009-10-27 17:59:53 +01:00
|
|
|
version->setS60SDKDirectory(s->value("S60SDKDirectory").toString());
|
2009-10-29 12:19:56 +01:00
|
|
|
version->setGcceDirectory(s->value("GcceDirectory").toString());
|
2008-12-02 12:01:29 +01:00
|
|
|
m_versions.append(version);
|
|
|
|
}
|
|
|
|
s->endArray();
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
|
|
|
|
++m_idcount;
|
|
|
|
addNewVersionsFromInstaller();
|
|
|
|
updateSystemVersion();
|
|
|
|
|
|
|
|
writeVersionsIntoSettings();
|
2009-05-28 18:15:02 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
updateDocumentation();
|
2009-10-29 14:07:22 +01:00
|
|
|
|
2009-07-27 13:55:30 +02:00
|
|
|
// cannot call from ctor, needs to get connected extenernally first
|
|
|
|
QTimer::singleShot(0, this, SLOT(updateExamples()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QtVersionManager::~QtVersionManager()
|
|
|
|
{
|
|
|
|
qDeleteAll(m_versions);
|
|
|
|
m_versions.clear();
|
|
|
|
delete m_emptyVersion;
|
|
|
|
m_emptyVersion = 0;
|
|
|
|
}
|
|
|
|
|
2009-04-22 18:05:55 +02:00
|
|
|
QtVersionManager *QtVersionManager::instance()
|
2009-04-22 16:51:38 +02:00
|
|
|
{
|
2009-04-28 12:43:04 +02:00
|
|
|
return m_self;
|
2009-04-22 16:51:38 +02:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void QtVersionManager::addVersion(QtVersion *version)
|
|
|
|
{
|
2009-10-12 15:31:20 +02:00
|
|
|
QTC_ASSERT(version != 0, return);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_versions.append(version);
|
2009-12-03 18:37:27 +01:00
|
|
|
int uniqueId = version->uniqueId();
|
|
|
|
m_uniqueIdToIndex.insert(uniqueId, m_versions.count() - 1);
|
|
|
|
emit qtVersionsChanged(QList<int>() << uniqueId);
|
2009-02-05 16:22:32 +01:00
|
|
|
writeVersionsIntoSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-05-28 13:22:23 +02:00
|
|
|
void QtVersionManager::removeVersion(QtVersion *version)
|
|
|
|
{
|
2009-10-12 15:31:20 +02:00
|
|
|
QTC_ASSERT(version != 0, return);
|
2009-05-28 13:22:23 +02:00
|
|
|
m_versions.removeAll(version);
|
2009-12-03 18:37:27 +01:00
|
|
|
int uniqueId = version->uniqueId();
|
|
|
|
m_uniqueIdToIndex.remove(uniqueId);
|
|
|
|
emit qtVersionsChanged(QList<int>() << uniqueId);
|
2009-05-28 13:22:23 +02:00
|
|
|
writeVersionsIntoSettings();
|
|
|
|
delete version;
|
|
|
|
}
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void QtVersionManager::updateDocumentation()
|
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
Help::HelpManager *helpManager
|
|
|
|
= ExtensionSystem::PluginManager::instance()->getObject<Help::HelpManager>();
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(helpManager);
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList files;
|
|
|
|
foreach (QtVersion *version, m_versions) {
|
2009-12-17 15:51:42 +01:00
|
|
|
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;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
helpManager->registerDocumentation(files);
|
|
|
|
}
|
|
|
|
|
2009-05-28 18:15:02 +02:00
|
|
|
void QtVersionManager::updateExamples()
|
|
|
|
{
|
|
|
|
QList<QtVersion *> versions;
|
|
|
|
versions.append(m_versions);
|
|
|
|
|
|
|
|
QString examplesPath;
|
|
|
|
QString docPath;
|
|
|
|
QString demosPath;
|
|
|
|
QtVersion *version = 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
// try to find a version which has both, demos and examples
|
2009-05-28 18:15:02 +02:00
|
|
|
foreach (version, versions) {
|
|
|
|
if (version->hasExamples())
|
|
|
|
examplesPath = version->examplesPath();
|
|
|
|
if (version->hasDemos())
|
|
|
|
demosPath = version->demosPath();
|
2009-06-12 14:58:59 +02:00
|
|
|
if (!examplesPath.isEmpty() && !demosPath.isEmpty()) {
|
2009-07-27 13:55:30 +02:00
|
|
|
emit updateExamples(examplesPath, demosPath, version->sourcePath());
|
2009-05-28 18:15:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
int QtVersionManager::getUniqueId()
|
|
|
|
{
|
|
|
|
return m_idcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::updateUniqueIdToIndexMap()
|
|
|
|
{
|
|
|
|
m_uniqueIdToIndex.clear();
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i < m_versions.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_uniqueIdToIndex.insert(m_versions.at(i)->uniqueId(), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::writeVersionsIntoSettings()
|
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
QSettings *s = Core::ICore::instance()->settings();
|
2009-03-20 11:52:47 +01:00
|
|
|
s->beginWriteArray(QtVersionsSectionName);
|
2008-12-02 12:01:29 +01:00
|
|
|
for (int i = 0; i < m_versions.size(); ++i) {
|
2009-05-28 11:48:33 +02:00
|
|
|
const QtVersion *version = m_versions.at(i);
|
2008-12-02 12:01:29 +01:00
|
|
|
s->setArrayIndex(i);
|
2010-01-07 18:17:24 +01:00
|
|
|
s->setValue("Name", version->displayName());
|
2009-09-03 19:16:22 +02:00
|
|
|
// for downwards compat
|
|
|
|
s->setValue("Path", version->versionInfo().value("QT_INSTALL_DATA"));
|
|
|
|
s->setValue("QMakePath", version->qmakeCommand());
|
2009-05-28 11:48:33 +02:00
|
|
|
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());
|
2009-06-04 10:50:44 +02:00
|
|
|
s->setValue("MwcDirectory", version->mwcDirectory());
|
2009-10-27 17:59:53 +01:00
|
|
|
s->setValue("S60SDKDirectory", version->s60SDKDirectory());
|
2009-10-29 12:19:56 +01:00
|
|
|
s->setValue("GcceDirectory", version->gcceDirectory());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
s->endArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QtVersion* > QtVersionManager::versions() const
|
|
|
|
{
|
|
|
|
return m_versions;
|
|
|
|
}
|
|
|
|
|
2010-01-12 15:46:23 +01:00
|
|
|
bool QtVersionManager::isValidId(int id) const
|
|
|
|
{
|
|
|
|
int pos = m_uniqueIdToIndex.value(id, -1);
|
|
|
|
return (pos != -1);
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersion *QtVersionManager::version(int id) const
|
|
|
|
{
|
|
|
|
int pos = m_uniqueIdToIndex.value(id, -1);
|
|
|
|
if (pos != -1)
|
|
|
|
return m_versions.at(pos);
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
return m_emptyVersion;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::addNewVersionsFromInstaller()
|
|
|
|
{
|
|
|
|
// Add new versions which may have been installed by the WB installer in the form:
|
2009-09-03 19:16:22 +02:00
|
|
|
// NewQtVersions="qt 4.3.2=c:\\qt\\qt432\bin\qmake.exe;qt embedded=c:\\qtembedded;"
|
2009-12-17 18:50:49 +01:00
|
|
|
// or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe=c:\\qtcreator\\mingw\\;
|
|
|
|
// i.e.
|
|
|
|
// NewQtVersions="versionname=pathtoversion=mingw=s60sdk=gcce=carbide;"
|
2008-12-02 12:01:29 +01:00
|
|
|
// Duplicate entries are not added, the first new version is set as default.
|
2009-01-20 11:52:04 +01:00
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
2010-01-13 17:39:31 +01:00
|
|
|
QSettings *globalSettings = Core::ICore::instance()->settings(QSettings::SystemScope);
|
2009-02-11 19:41:01 +01:00
|
|
|
|
2010-01-13 17:39:31 +01:00
|
|
|
QDateTime lastUpdateFromGlobalSettings = globalSettings->value(
|
|
|
|
QLatin1String("General/LastQtVersionUpdate")).toDateTime();
|
|
|
|
|
|
|
|
const QFileInfo gsFi(globalSettings->fileName());
|
2010-01-18 11:24:48 +01:00
|
|
|
if ( !lastUpdateFromGlobalSettings.isNull() &&
|
|
|
|
(!gsFi.exists() || (gsFi.lastModified() > lastUpdateFromGlobalSettings)) )
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
2010-01-13 17:39:31 +01:00
|
|
|
if (!globalSettings->contains(newQtVersionsKey) &&
|
|
|
|
!globalSettings->contains(QLatin1String("Installer/")+newQtVersionsKey))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
QString newVersionsValue = settings->value(newQtVersionsKey).toString();
|
2009-02-11 19:41:01 +01:00
|
|
|
if (newVersionsValue.isEmpty())
|
|
|
|
newVersionsValue = settings->value(QLatin1String("Installer/")+newQtVersionsKey).toString();
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList newVersionsList = newVersionsValue.split(';', QString::SkipEmptyParts);
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach (const QString &newVersion, newVersionsList) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList newVersionData = newVersion.split('=');
|
2009-12-17 18:50:49 +01:00
|
|
|
if (newVersionData.count() >= 2) {
|
2009-10-22 14:23:30 +02:00
|
|
|
if (QFile::exists(newVersionData[1])) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ );
|
2008-12-09 11:07:24 +01:00
|
|
|
if (newVersionData.count() >= 3)
|
2008-12-02 12:01:29 +01:00
|
|
|
version->setMingwDirectory(newVersionData[2]);
|
2009-12-17 18:50:49 +01:00
|
|
|
if (newVersionData.count() >= 4)
|
2010-02-12 11:56:42 +01:00
|
|
|
version->setS60SDKDirectory(QDir::fromNativeSeparators(newVersionData[3]));
|
2009-12-17 18:50:49 +01:00
|
|
|
if (newVersionData.count() >= 5)
|
2010-02-12 11:56:42 +01:00
|
|
|
version->setGcceDirectory(QDir::fromNativeSeparators(newVersionData[4]));
|
2009-12-17 18:50:49 +01:00
|
|
|
if (newVersionData.count() >= 6)
|
2010-02-12 11:56:42 +01:00
|
|
|
version->setMwcDirectory(QDir::fromNativeSeparators(newVersionData[5]));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
bool versionWasAlreadyInList = false;
|
|
|
|
foreach(const QtVersion * const it, m_versions) {
|
2009-09-03 19:16:22 +02:00
|
|
|
if (QDir(version->qmakeCommand()).canonicalPath() == QDir(it->qmakeCommand()).canonicalPath()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
versionWasAlreadyInList = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!versionWasAlreadyInList) {
|
|
|
|
m_versions.append(version);
|
|
|
|
} else {
|
|
|
|
// clean up
|
|
|
|
delete version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateUniqueIdToIndexMap();
|
2010-01-13 17:39:31 +01:00
|
|
|
settings->setValue(QLatin1String("General/LastQtVersionUpdate"), QDateTime::currentDateTime());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::updateSystemVersion()
|
|
|
|
{
|
|
|
|
bool haveSystemVersion = false;
|
2009-04-28 12:43:04 +02:00
|
|
|
QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(ProjectExplorer::Environment::systemEnvironment());
|
2009-09-03 19:16:22 +02:00
|
|
|
if (systemQMakePath.isNull())
|
|
|
|
systemQMakePath = tr("<not found>");
|
2009-04-23 16:05:51 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
foreach (QtVersion *version, m_versions) {
|
2009-05-28 11:48:33 +02:00
|
|
|
if (version->isAutodetected()
|
|
|
|
&& version->autodetectionSource() == PATH_AUTODETECTION_SOURCE) {
|
2009-09-03 19:16:22 +02:00
|
|
|
version->setQMakeCommand(systemQMakePath);
|
2010-01-07 18:17:24 +01:00
|
|
|
version->setDisplayName(tr("Qt in PATH"));
|
2008-12-02 12:01:29 +01:00
|
|
|
haveSystemVersion = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (haveSystemVersion)
|
|
|
|
return;
|
2009-05-26 17:21:30 +02:00
|
|
|
QtVersion *version = new QtVersion(tr("Qt in PATH"),
|
2009-09-03 19:16:22 +02:00
|
|
|
systemQMakePath,
|
2008-12-02 12:01:29 +01:00
|
|
|
getUniqueId(),
|
2009-05-28 11:48:33 +02:00
|
|
|
true,
|
|
|
|
PATH_AUTODETECTION_SOURCE);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_versions.prepend(version);
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
}
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QtVersion *QtVersionManager::emptyVersion() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
return m_emptyVersion;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
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;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions)
|
2009-04-22 18:05:55 +02:00
|
|
|
{
|
2009-12-03 18:37:27 +01:00
|
|
|
// 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;
|
2009-04-22 18:05:55 +02:00
|
|
|
}
|
|
|
|
}
|
2009-12-03 18:37:27 +01:00
|
|
|
|
|
|
|
while (nit != nend) {
|
|
|
|
changedVersions.push_back((*nit)->uniqueId());
|
2009-12-10 12:08:40 +01:00
|
|
|
++nit;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while (oit != oend) {
|
|
|
|
changedVersions.push_back((*oit)->uniqueId());
|
2009-12-10 12:08:40 +01:00
|
|
|
++oit;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
2009-04-22 18:05:55 +02:00
|
|
|
qDeleteAll(m_versions);
|
|
|
|
m_versions.clear();
|
2009-11-04 11:30:39 +01:00
|
|
|
m_versions = newVersions;
|
2009-12-03 18:37:27 +01:00
|
|
|
|
|
|
|
if (!changedVersions.isEmpty())
|
2009-04-22 18:05:55 +02:00
|
|
|
updateDocumentation();
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
|
2009-07-20 14:24:41 +02:00
|
|
|
updateExamples();
|
2009-04-22 18:05:55 +02:00
|
|
|
writeVersionsIntoSettings();
|
2009-12-03 18:37:27 +01:00
|
|
|
|
|
|
|
if (!changedVersions.isEmpty())
|
|
|
|
emit qtVersionsChanged(changedVersions);
|
2009-04-22 18:05:55 +02:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
|
|
|
/// QtVersion
|
|
|
|
///
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id,
|
2009-05-28 11:48:33 +02:00
|
|
|
bool isAutodetected, const QString &autodetectionSource)
|
2010-01-07 18:17:24 +01:00
|
|
|
: m_displayName(name),
|
2009-05-28 11:31:35 +02:00
|
|
|
m_isAutodetected(isAutodetected),
|
2009-05-28 11:48:33 +02:00
|
|
|
m_autodetectionSource(autodetectionSource),
|
2009-05-25 16:43:50 +02:00
|
|
|
m_hasDebuggingHelper(false),
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate(false),
|
2009-09-03 19:16:22 +02:00
|
|
|
m_versionInfoUpToDate(false),
|
2009-03-25 15:18:37 +01:00
|
|
|
m_notInstalled(false),
|
|
|
|
m_defaultConfigIsDebug(true),
|
|
|
|
m_defaultConfigIsDebugAndRelease(true),
|
2009-05-28 18:15:02 +02:00
|
|
|
m_hasExamples(false),
|
|
|
|
m_hasDemos(false),
|
2009-06-22 14:00:04 +02:00
|
|
|
m_hasDocumentation(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
if (id == -1)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_id = getUniqueId();
|
|
|
|
else
|
|
|
|
m_id = id;
|
2009-09-03 19:16:22 +02:00
|
|
|
setQMakeCommand(qmakeCommand);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QtVersion::QtVersion(const QString &name, const QString &qmakeCommand,
|
2009-05-28 13:22:23 +02:00
|
|
|
bool isAutodetected, const QString &autodetectionSource)
|
2010-01-07 18:17:24 +01:00
|
|
|
: m_displayName(name),
|
2009-05-28 13:22:23 +02:00
|
|
|
m_isAutodetected(isAutodetected),
|
|
|
|
m_autodetectionSource(autodetectionSource),
|
2009-05-25 16:43:50 +02:00
|
|
|
m_hasDebuggingHelper(false),
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate(false),
|
2009-09-03 19:16:22 +02:00
|
|
|
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),
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate(false),
|
2009-09-03 19:16:22 +02:00
|
|
|
m_versionInfoUpToDate(false),
|
|
|
|
m_notInstalled(false),
|
|
|
|
m_defaultConfigIsDebug(true),
|
|
|
|
m_defaultConfigIsDebugAndRelease(true),
|
|
|
|
m_hasExamples(false),
|
|
|
|
m_hasDemos(false),
|
|
|
|
m_hasDocumentation(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
m_id = getUniqueId();
|
2009-09-03 19:16:22 +02:00
|
|
|
setQMakeCommand(qmakeCommand);
|
2010-01-07 18:17:24 +01:00
|
|
|
m_displayName = qtVersionString();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 19:45:09 +02:00
|
|
|
QtVersion::QtVersion()
|
2010-02-02 17:09:41 +01:00
|
|
|
: m_id(-1),
|
2009-09-03 19:45:09 +02:00
|
|
|
m_isAutodetected(false),
|
|
|
|
m_hasDebuggingHelper(false),
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate(false),
|
2009-09-03 19:45:09 +02:00
|
|
|
m_versionInfoUpToDate(false),
|
|
|
|
m_notInstalled(false),
|
|
|
|
m_defaultConfigIsDebug(true),
|
|
|
|
m_defaultConfigIsDebugAndRelease(true),
|
|
|
|
m_hasExamples(false),
|
|
|
|
m_hasDemos(false),
|
|
|
|
m_hasDocumentation(false)
|
|
|
|
{
|
2010-02-02 17:09:41 +01:00
|
|
|
setQMakeCommand(QString());
|
2009-09-03 19:45:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
QtVersion::~QtVersion()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-10-27 18:05:04 +01:00
|
|
|
QString QtVersion::toHtml() const
|
|
|
|
{
|
|
|
|
QString rc;
|
|
|
|
QTextStream str(&rc);
|
|
|
|
str << "<html></head><body><table>";
|
|
|
|
str << "<tr><td><b>" << QtVersionManager::tr("Name:")
|
2010-01-07 18:17:24 +01:00
|
|
|
<< "</b></td><td>" << displayName() << "</td></tr>";
|
2009-10-27 18:05:04 +01:00
|
|
|
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>";
|
2009-11-09 18:59:11 +01:00
|
|
|
updateToolChainAndMkspec();
|
2009-10-27 18:05:04 +01:00
|
|
|
if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) {
|
2009-11-05 16:40:27 +01:00
|
|
|
str << "<tr><td><b>" << QtVersionManager::tr("Default:") << "</b></td><td>"
|
|
|
|
<< (m_defaultConfigIsDebug ? "debug" : "release");
|
2009-10-27 18:05:04 +01:00
|
|
|
if (m_defaultConfigIsDebugAndRelease)
|
2009-11-05 16:40:27 +01:00
|
|
|
str << " debug_and_release";
|
2009-10-27 18:05:04 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString QtVersion::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
return m_displayName;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QString QtVersion::qmakeCommand() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-03 19:16:22 +02:00
|
|
|
return m_qmakeCommand;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::sourcePath() const
|
|
|
|
{
|
|
|
|
return m_sourcePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::mkspec() const
|
|
|
|
{
|
2009-11-09 18:59:11 +01:00
|
|
|
updateToolChainAndMkspec();
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_mkspec;
|
|
|
|
}
|
|
|
|
|
2008-12-08 12:44:28 +01:00
|
|
|
QString QtVersion::mkspecPath() const
|
|
|
|
{
|
2009-11-09 18:59:11 +01:00
|
|
|
updateToolChainAndMkspec();
|
2008-12-08 12:44:28 +01:00
|
|
|
return m_mkspecFullPath;
|
|
|
|
}
|
|
|
|
|
2008-12-08 14:20:35 +01:00
|
|
|
QString QtVersion::qtVersionString() const
|
|
|
|
{
|
|
|
|
return m_qtVersionString;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QHash<QString,QString> QtVersion::versionInfo() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
return m_versionInfo;
|
|
|
|
}
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
void QtVersion::setDisplayName(const QString &name)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
m_displayName = name;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
void QtVersion::setQMakeCommand(const QString& qmakeCommand)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-06 18:34:44 +02:00
|
|
|
m_qmakeCommand = QDir::fromNativeSeparators(qmakeCommand);
|
2009-08-27 15:08:47 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2009-09-03 19:16:22 +02:00
|
|
|
m_qmakeCommand = m_qmakeCommand.toLower();
|
2009-08-27 15:08:47 +02:00
|
|
|
#endif
|
2010-02-02 17:09:41 +01:00
|
|
|
m_designerCommand.clear();
|
|
|
|
m_linguistCommand.clear();
|
|
|
|
m_uicCommand.clear();
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate = false;
|
2009-09-03 19:16:22 +02:00
|
|
|
// TODO do i need to optimize this?
|
|
|
|
m_versionInfoUpToDate = false;
|
|
|
|
m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
|
|
|
|
|
|
|
|
QFileInfo qmake(qmakeCommand);
|
|
|
|
if (qmake.exists() && qmake.isExecutable()) {
|
|
|
|
m_qtVersionString = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath());
|
|
|
|
} else {
|
2010-02-02 17:09:41 +01:00
|
|
|
m_qtVersionString.clear();
|
2009-09-03 19:16:22 +02:00
|
|
|
}
|
|
|
|
updateSourcePath();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::updateSourcePath()
|
|
|
|
{
|
2009-09-03 19:16:22 +02:00
|
|
|
updateVersionInfo();
|
|
|
|
const QString installData = m_versionInfo["QT_INSTALL_DATA"];
|
|
|
|
m_sourcePath = installData;
|
|
|
|
QFile qmakeCache(installData + QLatin1String("/.qmake.cache"));
|
2008-12-02 12:01:29 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-06 18:49:10 +02:00
|
|
|
m_sourcePath = QDir::cleanPath(m_sourcePath);
|
2009-11-09 18:59:11 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
m_sourcePath = m_sourcePath.toLower();
|
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the version that was used to build the project in that directory
|
|
|
|
// That is returns the directory
|
2010-01-11 10:22:55 +01:00
|
|
|
// To find out whether we already have a qtversion for that directory call
|
2008-12-02 12:01:29 +01:00
|
|
|
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
|
2009-09-03 19:16:22 +02:00
|
|
|
QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
bool debugAdding = false;
|
|
|
|
QFile makefile(directory + "/Makefile" );
|
|
|
|
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream ts(&makefile);
|
2009-12-10 19:12:51 +01:00
|
|
|
QRegExp r1("QMAKE\\s*=(.*)");
|
2008-12-02 12:01:29 +01:00
|
|
|
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());
|
2009-09-03 19:16:22 +02:00
|
|
|
QString qmakePath = qmake.filePath();
|
2009-08-27 15:08:47 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2009-09-03 19:16:22 +02:00
|
|
|
qmakePath = qmakePath.toLower();
|
2009-08-27 15:08:47 +02:00
|
|
|
#endif
|
2009-09-03 19:16:22 +02:00
|
|
|
return qmakePath;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
makefile.close();
|
|
|
|
}
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
foreach(QtVersion *v, versions()) {
|
2009-09-03 19:16:22 +02:00
|
|
|
if (v->qmakeCommand() == qmakePath) {
|
2008-12-02 12:01:29 +01:00
|
|
|
return v;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-22 16:52:44 +02:00
|
|
|
void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, list) {
|
2009-07-22 16:52:44 +02:00
|
|
|
qDebug()<<qa.variable<<qa.op<<qa.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-13 13:44:13 +02:00
|
|
|
QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfigs defaultBuildConfig)
|
2009-07-22 16:52:44 +02:00
|
|
|
{
|
2009-08-17 11:49:59 +02:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"ScanMakeFile, the gory details:";
|
2009-12-10 19:12:51 +01:00
|
|
|
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
|
2009-07-22 16:52:44 +02:00
|
|
|
QStringList result2;
|
|
|
|
|
|
|
|
QString line = findQMakeLine(directory);
|
|
|
|
if (!line.isEmpty()) {
|
2009-08-17 11:49:59 +02:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"Found line"<<line;
|
2009-07-22 16:52:44 +02:00
|
|
|
line = trimLine(line);
|
|
|
|
QStringList parts = splitLine(line);
|
2009-08-17 11:49:59 +02:00
|
|
|
if (debug)
|
2010-01-11 10:22:55 +01:00
|
|
|
qDebug()<<"Split into"<<parts;
|
2009-07-22 16:52:44 +02:00
|
|
|
QList<QMakeAssignment> assignments;
|
|
|
|
QList<QMakeAssignment> afterAssignments;
|
|
|
|
QStringList additionalArguments;
|
|
|
|
parseParts(parts, &assignments, &afterAssignments, &additionalArguments);
|
|
|
|
|
2009-08-17 11:49:59 +02:00
|
|
|
if (debug) {
|
|
|
|
dumpQMakeAssignments(assignments);
|
|
|
|
if (!afterAssignments.isEmpty())
|
|
|
|
qDebug()<<"-after";
|
|
|
|
dumpQMakeAssignments(afterAssignments);
|
|
|
|
}
|
2009-07-22 16:52:44 +02:00
|
|
|
|
|
|
|
// Search in assignments for CONFIG(+=,-=,=)(debug,release,debug_and_release)
|
|
|
|
// Also remove them from the list
|
|
|
|
result = qmakeBuildConfigFromCmdArgs(&assignments, defaultBuildConfig);
|
|
|
|
|
|
|
|
dumpQMakeAssignments(assignments);
|
|
|
|
|
|
|
|
result2.append(additionalArguments);
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, assignments)
|
2009-07-22 16:52:44 +02:00
|
|
|
result2.append(qa.variable + qa.op + qa.value);
|
|
|
|
if (!afterAssignments.isEmpty()) {
|
|
|
|
result2.append("-after");
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, afterAssignments)
|
2009-07-22 16:52:44 +02:00
|
|
|
result2.append(qa.variable + qa.op + qa.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dump the gathered information:
|
2009-08-17 11:49:59 +02:00
|
|
|
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";
|
|
|
|
}
|
2009-07-22 16:52:44 +02:00
|
|
|
return qMakePair(result, result2);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersionManager::findQMakeLine(const QString &directory)
|
|
|
|
{
|
2010-02-01 12:43:56 +01:00
|
|
|
QFile makefile(directory + QLatin1String("/Makefile" ));
|
2008-12-02 12:01:29 +01:00
|
|
|
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream ts(&makefile);
|
|
|
|
while (!ts.atEnd()) {
|
2010-02-01 12:43:56 +01:00
|
|
|
const QString line = ts.readLine();
|
|
|
|
if (line.startsWith(QLatin1String("# Command:")))
|
2009-07-22 16:52:44 +02:00
|
|
|
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
|
2010-02-01 12:43:56 +01:00
|
|
|
const int firstSpace = line.indexOf(QLatin1Char(' '), 11);
|
2009-07-22 16:52:44 +02:00
|
|
|
return line.mid(firstSpace).trimmed();
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QtVersionManager::splitLine(const QString &line)
|
|
|
|
{
|
|
|
|
// Split on each " ", except on those which are escaped
|
2009-07-23 14:00:45 +02:00
|
|
|
// On Unix also remove all escaping
|
|
|
|
// On Windows also, but different escaping
|
2009-07-22 16:52:44 +02:00
|
|
|
bool escape = false;
|
|
|
|
QString currentWord;
|
|
|
|
QStringList results;
|
|
|
|
int length = line.length();
|
|
|
|
for (int i=0; i<length; ++i) {
|
2009-07-23 14:00:45 +02:00
|
|
|
#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
|
2009-07-22 16:52:44 +02:00
|
|
|
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);
|
|
|
|
}
|
2009-07-23 14:00:45 +02:00
|
|
|
#endif
|
2009-07-22 16:52:44 +02:00
|
|
|
}
|
|
|
|
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") {
|
|
|
|
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
|
2009-10-13 13:44:13 +02:00
|
|
|
QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfigs defaultBuildConfig)
|
2009-07-22 16:52:44 +02:00
|
|
|
{
|
2009-10-13 13:44:13 +02:00
|
|
|
QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
|
2009-07-22 16:52:44 +02:00
|
|
|
QList<QMakeAssignment> oldAssignments = *assignments;
|
|
|
|
assignments->clear();
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, oldAssignments) {
|
2009-07-22 16:52:44 +02:00
|
|
|
if (qa.variable == "CONFIG") {
|
|
|
|
QStringList values = qa.value.split(' ');
|
|
|
|
QStringList newValues;
|
|
|
|
foreach(const QString &value, values) {
|
|
|
|
if (value == "debug") {
|
|
|
|
if (qa.op == "+=")
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result | QtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result & ~QtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
} else if (value == "release") {
|
|
|
|
if (qa.op == "+=")
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result & ~QtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result | QtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
} else if (value == "debug_and_release") {
|
|
|
|
if (qa.op == "+=")
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result | QtVersion::BuildAll;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result & ~QtVersion::BuildAll;
|
2009-07-22 16:52:44 +02:00
|
|
|
} else {
|
|
|
|
newValues.append(value);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-07-22 16:52:44 +02:00
|
|
|
QMakeAssignment newQA = qa;
|
|
|
|
newQA.value = newValues.join(" ");
|
|
|
|
if (!newValues.isEmpty())
|
|
|
|
assignments->append(newQA);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-07-22 16:52:44 +02:00
|
|
|
} else {
|
|
|
|
assignments->append(qa);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::updateVersionInfo() const
|
|
|
|
{
|
|
|
|
if (m_versionInfoUpToDate)
|
|
|
|
return;
|
2009-10-06 17:16:18 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// extract data from qmake executable
|
|
|
|
m_versionInfo.clear();
|
|
|
|
m_notInstalled = false;
|
2009-05-28 18:15:02 +02:00
|
|
|
m_hasExamples = false;
|
|
|
|
m_hasDocumentation = false;
|
2009-09-03 19:16:22 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QFileInfo qmake(qmakeCommand());
|
2009-12-11 16:30:49 +01:00
|
|
|
if (qmake.exists() && qmake.isExecutable()) {
|
2009-03-22 13:47:57 +01:00
|
|
|
static const char * const variables[] = {
|
2009-07-31 20:37:47 +02:00
|
|
|
"QT_VERSION",
|
2009-03-22 13:47:57 +01:00
|
|
|
"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",
|
|
|
|
"QT_INSTALL_PREFIX"
|
|
|
|
};
|
|
|
|
QStringList args;
|
|
|
|
for (uint i = 0; i < sizeof variables / sizeof variables[0]; ++i)
|
|
|
|
args << "-query" << variables[i];
|
2008-12-02 12:01:29 +01:00
|
|
|
QProcess process;
|
|
|
|
process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly);
|
|
|
|
if (process.waitForFinished(2000)) {
|
|
|
|
QByteArray output = process.readAllStandardOutput();
|
|
|
|
QTextStream stream(&output);
|
|
|
|
while (!stream.atEnd()) {
|
2010-02-01 12:43:56 +01:00
|
|
|
const QString line = stream.readLine();
|
|
|
|
const int index = line.indexOf(QLatin1Char(':'));
|
2008-12-02 12:01:29 +01:00
|
|
|
if (index != -1)
|
2008-12-05 12:55:31 +01:00
|
|
|
m_versionInfo.insert(line.left(index), QDir::fromNativeSeparators(line.mid(index+1)));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_versionInfo.contains("QT_INSTALL_DATA"))
|
|
|
|
m_versionInfo.insert("QMAKE_MKSPECS", QDir::cleanPath(m_versionInfo.value("QT_INSTALL_DATA")+"/mkspecs"));
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2009-05-28 18:15:02 +02:00
|
|
|
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;
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
m_versionInfoUpToDate = true;
|
|
|
|
}
|
|
|
|
|
2009-05-19 14:54:52 +02:00
|
|
|
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);
|
|
|
|
}
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-05-19 14:54:52 +02:00
|
|
|
}
|
|
|
|
|
2009-05-12 14:12:20 +02:00
|
|
|
QString QtVersion::uicCommand() const
|
|
|
|
{
|
|
|
|
if (!isValid())
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-05-12 14:12:20 +02:00
|
|
|
if (!m_uicCommand.isNull())
|
|
|
|
return m_uicCommand;
|
2009-05-19 14:54:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
const QStringList possibleCommands(QLatin1String("uic.exe"));
|
|
|
|
#else
|
2009-05-12 14:12:20 +02:00
|
|
|
QStringList possibleCommands;
|
2009-05-19 14:54:52 +02:00
|
|
|
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)
|
|
|
|
{
|
2009-05-12 14:12:20 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2009-05-19 14:54:52 +02:00
|
|
|
return QStringList(name + QLatin1String(".exe"));
|
2009-06-03 20:45:49 +02:00
|
|
|
#elif defined(Q_OS_MAC) // 'Foo.app/Contents/MacOS/Foo'
|
2009-05-19 14:54:52 +02:00
|
|
|
QString upCaseName = name;
|
|
|
|
upCaseName[0] = upCaseName.at(0).toUpper();
|
|
|
|
QString macBinary = upCaseName;
|
|
|
|
macBinary += QLatin1String(".app/Contents/MacOS/");
|
|
|
|
macBinary += upCaseName;
|
|
|
|
return QStringList(macBinary);
|
2009-05-12 14:12:20 +02:00
|
|
|
#else
|
2009-05-19 14:54:52 +02:00
|
|
|
return QStringList(name);
|
2009-05-12 14:12:20 +02:00
|
|
|
#endif
|
2009-05-19 14:54:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::designerCommand() const
|
|
|
|
{
|
|
|
|
if (!isValid())
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-05-19 14:54:52 +02:00
|
|
|
if (m_designerCommand.isNull())
|
|
|
|
m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer")));
|
|
|
|
return m_designerCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::linguistCommand() const
|
|
|
|
{
|
|
|
|
if (!isValid())
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-05-19 14:54:52 +02:00
|
|
|
if (m_linguistCommand.isNull())
|
|
|
|
m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist")));
|
|
|
|
return m_linguistCommand;
|
2009-05-12 14:12:20 +02:00
|
|
|
}
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool QtVersion::supportsTargetId(const QString &id) const
|
|
|
|
{
|
2010-02-11 18:01:52 +01:00
|
|
|
updateToolChainAndMkspec();
|
|
|
|
return m_targetIds.contains(id);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QSet<QString> QtVersion::supportedTargetIds() const
|
|
|
|
{
|
2010-02-11 18:01:52 +01:00
|
|
|
updateToolChainAndMkspec();
|
|
|
|
return m_targetIds;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
2009-10-22 17:09:28 +02:00
|
|
|
QList<QSharedPointer<ProjectExplorer::ToolChain> > QtVersion::toolChains() const
|
2009-10-22 14:22:16 +02:00
|
|
|
{
|
2009-11-09 18:59:11 +01:00
|
|
|
updateToolChainAndMkspec();
|
2009-10-22 14:22:16 +02:00
|
|
|
return m_toolChains;
|
|
|
|
}
|
|
|
|
|
2009-10-22 17:09:28 +02:00
|
|
|
ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChain::ToolChainType type) const
|
|
|
|
{
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tcptr, toolChains())
|
2009-10-22 17:09:28 +02:00
|
|
|
if (tcptr->type() == type)
|
|
|
|
return tcptr.data();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-09 18:02:23 +02:00
|
|
|
QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-22 14:22:16 +02:00
|
|
|
QList<ProjectExplorer::ToolChain::ToolChainType> types;
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tc, toolChains())
|
2009-10-22 14:22:16 +02:00
|
|
|
types << tc->type();
|
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if none, then it's INVALID everywhere this function is called
|
2009-11-09 18:59:11 +01:00
|
|
|
void QtVersion::updateToolChainAndMkspec() const
|
2009-10-22 14:22:16 +02:00
|
|
|
{
|
2009-11-13 15:47:35 +01:00
|
|
|
typedef QSharedPointer<ProjectExplorer::ToolChain> ToolChainPtr;
|
2009-10-22 14:22:16 +02:00
|
|
|
if (m_toolChainUpToDate)
|
|
|
|
return;
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_toolChains.clear();
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.clear();
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2009-11-09 18:59:11 +01:00
|
|
|
if (!isValid())
|
|
|
|
return;
|
|
|
|
|
2009-11-11 18:36:03 +01:00
|
|
|
// qDebug()<<"Finding mkspec for"<<qmakeCommand();
|
2009-11-09 18:59:11 +01:00
|
|
|
|
|
|
|
// 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";
|
|
|
|
|
2009-11-10 18:57:40 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
baseMkspecDir = baseMkspecDir.toLower();
|
|
|
|
#endif
|
|
|
|
|
2009-11-09 18:59:11 +01:00
|
|
|
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) {
|
|
|
|
mkspecFullPath = temp.at(1).trimmed();
|
|
|
|
}
|
|
|
|
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
|
2009-11-10 18:57:40 +01:00
|
|
|
mkspecFullPath = mkspecFullPath.toLower();
|
2009-11-09 18:59:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
m_mkspecFullPath = mkspecFullPath;
|
|
|
|
QString mkspec = m_mkspecFullPath;
|
|
|
|
|
|
|
|
if (mkspec.startsWith(baseMkspecDir)) {
|
|
|
|
mkspec = mkspec.mid(baseMkspecDir.length() + 1);
|
2009-11-11 18:36:03 +01:00
|
|
|
// qDebug() << "Setting mkspec to"<<mkspec;
|
2009-11-09 18:59:11 +01:00
|
|
|
} else {
|
|
|
|
QString sourceMkSpecPath = sourcePath() + "/mkspecs";
|
|
|
|
if (mkspec.startsWith(sourceMkSpecPath)) {
|
|
|
|
mkspec = mkspec.mid(sourceMkSpecPath.length() + 1);
|
|
|
|
} else {
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_mkspec = mkspec;
|
|
|
|
|
2009-11-11 18:36:03 +01:00
|
|
|
// qDebug()<<"mkspec for "<<qmakeCommand()<<" is "<<m_mkspec<<m_mkspecFullPath;
|
2009-10-22 14:22:16 +02:00
|
|
|
|
2009-12-07 20:49:39 +01:00
|
|
|
ProFileOption option;
|
|
|
|
option.properties = versionInfo();
|
2009-12-07 22:58:47 +01:00
|
|
|
option.cache = ProFileCacheManager::instance()->cache();
|
2009-12-07 20:49:39 +01:00
|
|
|
ProFileReader *reader = new ProFileReader(&option);
|
2009-10-22 14:22:16 +02:00
|
|
|
reader->setCumulative(false);
|
|
|
|
reader->setParsePreAndPostFiles(false);
|
2009-11-09 18:59:11 +01:00
|
|
|
reader->readProFile(m_mkspecFullPath + "/qmake.conf");
|
2009-10-22 14:22:16 +02:00
|
|
|
QString qmakeCXX = reader->value("QMAKE_CXX");
|
|
|
|
QString makefileGenerator = reader->value("MAKEFILE_GENERATOR");
|
2009-10-27 17:23:06 +10:00
|
|
|
QString ce_sdk = reader->values("CE_SDK").join(QLatin1String(" "));
|
2009-10-22 14:22:16 +02:00
|
|
|
QString ce_arch = reader->value("CE_ARCH");
|
|
|
|
QString qt_arch = reader->value("QT_ARCH");
|
|
|
|
if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) {
|
2009-11-13 15:47:35 +01:00
|
|
|
QString wincePlatformName = ce_sdk + " (" + ce_arch + QLatin1Char(')');
|
|
|
|
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createWinCEToolChain(msvcVersion(), wincePlatformName));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(DESKTOP_TARGET_ID);
|
2009-11-19 16:37:13 +01:00
|
|
|
} else if (makefileGenerator == QLatin1String("SYMBIAN_ABLD") ||
|
|
|
|
makefileGenerator == QLatin1String("SYMBIAN_SBSV2")) {
|
|
|
|
if (S60Manager *s60mgr = S60Manager::instance()) {
|
2009-11-13 15:47:35 +01:00
|
|
|
# ifdef Q_OS_WIN
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(S60_DEVICE_TARGET_ID));
|
2010-02-10 12:19:43 +01:00
|
|
|
m_toolChains << ToolChainPtr(s60mgr->createGCCEToolChain(this));
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qgetenv("RVCT22BIN").isEmpty())
|
|
|
|
m_toolChains << ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV5))
|
|
|
|
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV6));
|
2010-02-11 18:01:52 +01:00
|
|
|
if (!mwcDirectory().isEmpty()) {
|
2010-02-08 15:50:06 +01:00
|
|
|
m_toolChains << ToolChainPtr(s60mgr->createWINSCWToolChain(this));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(S60_EMULATOR_TARGET_ID));
|
|
|
|
}
|
2009-11-13 15:47:35 +01:00
|
|
|
# else
|
|
|
|
m_toolChains << ToolChainPtr(s60mgr->createGCCE_GnuPocToolChain(this))
|
|
|
|
<< ToolChainPtr(s60mgr->createRVCTToolChain(this, ProjectExplorer::ToolChain::RVCT_ARMV6_GNUPOC));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(S60_DEVICE_TARGET_ID));
|
2009-11-13 15:47:35 +01:00
|
|
|
# endif
|
|
|
|
}
|
2010-02-08 17:51:58 +01:00
|
|
|
} else if (qt_arch == "arm"
|
|
|
|
&& MaemoManager::instance()->isValidMaemoQtVersion(this)) {
|
|
|
|
m_toolChains << ToolChainPtr(MaemoManager::instance()->maemoToolChain(this));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(MAEMO_EMULATOR_TARGET_ID));
|
|
|
|
m_targetIds.insert(QLatin1String(MAEMO_DEVICE_TARGET_ID));
|
2009-10-22 14:22:16 +02:00
|
|
|
} else if (qmakeCXX == "cl" || qmakeCXX == "icl") {
|
|
|
|
// TODO proper support for intel cl
|
2009-11-13 15:47:35 +01:00
|
|
|
m_toolChains << ToolChainPtr(
|
2009-10-22 17:09:28 +02:00
|
|
|
ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isQt64Bit()));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(DESKTOP_TARGET_ID));
|
2009-10-22 14:22:16 +02:00
|
|
|
} else if (qmakeCXX == "g++" && makefileGenerator == "MINGW") {
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
//addToEnvironment(env);
|
|
|
|
env.prependOrSetPath(mingwDirectory() + "/bin");
|
|
|
|
qmakeCXX = env.searchInPath(qmakeCXX);
|
2009-11-13 15:47:35 +01:00
|
|
|
m_toolChains << ToolChainPtr(
|
2009-10-22 17:09:28 +02:00
|
|
|
ProjectExplorer::ToolChain::createMinGWToolChain(qmakeCXX, mingwDirectory()));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(DESKTOP_TARGET_ID));
|
2009-10-22 14:22:16 +02:00
|
|
|
} else if (qmakeCXX == "g++" || qmakeCXX == "icc") {
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
//addToEnvironment(env);
|
|
|
|
qmakeCXX = env.searchInPath(qmakeCXX);
|
|
|
|
if (qmakeCXX.isEmpty()) {
|
|
|
|
// macx-xcode mkspec resets the value of QMAKE_CXX.
|
|
|
|
// Unfortunately, we need a valid QMAKE_CXX to configure the parser.
|
|
|
|
qmakeCXX = QLatin1String("cc");
|
|
|
|
}
|
2009-11-13 15:47:35 +01:00
|
|
|
m_toolChains << ToolChainPtr(ProjectExplorer::ToolChain::createGccToolChain(qmakeCXX));
|
2010-02-11 18:01:52 +01:00
|
|
|
m_targetIds.insert(QLatin1String(DESKTOP_TARGET_ID));
|
2009-10-16 16:48:49 +02:00
|
|
|
}
|
2009-06-09 18:02:23 +02:00
|
|
|
|
2009-10-22 14:22:16 +02:00
|
|
|
if (m_toolChains.isEmpty()) {
|
2009-11-09 18:59:11 +01:00
|
|
|
qDebug()<<"Could not create ToolChain for"<<m_mkspecFullPath<<qmakeCXX;
|
2009-10-22 14:22:16 +02:00
|
|
|
qDebug()<<"Qt Creator doesn't know about the system includes, nor the systems defines.";
|
|
|
|
}
|
|
|
|
|
2009-11-09 18:59:11 +01:00
|
|
|
QStringList configValues = reader->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;
|
|
|
|
}
|
|
|
|
|
2009-10-22 14:22:16 +02:00
|
|
|
delete reader;
|
|
|
|
m_toolChainUpToDate = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-06-04 10:50:44 +02:00
|
|
|
QString QtVersion::mwcDirectory() const
|
|
|
|
{
|
|
|
|
return m_mwcDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setMwcDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_mwcDirectory = directory;
|
2010-02-08 15:50:06 +01:00
|
|
|
m_toolChainUpToDate = false;
|
2009-06-04 10:50:44 +02:00
|
|
|
}
|
2009-10-27 17:59:53 +01:00
|
|
|
QString QtVersion::s60SDKDirectory() const
|
|
|
|
{
|
|
|
|
return m_s60SDKDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setS60SDKDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_s60SDKDirectory = directory;
|
2010-02-08 15:50:06 +01:00
|
|
|
m_toolChainUpToDate = false;
|
2009-10-27 17:59:53 +01:00
|
|
|
}
|
2009-10-29 12:19:56 +01:00
|
|
|
|
|
|
|
QString QtVersion::gcceDirectory() const
|
|
|
|
{
|
|
|
|
return m_gcceDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setGcceDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_gcceDirectory = directory;
|
2010-02-08 15:50:06 +01:00
|
|
|
m_toolChainUpToDate = false;
|
2009-10-29 12:19:56 +01:00
|
|
|
}
|
2009-06-04 10:50:44 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString QtVersion::mingwDirectory() const
|
|
|
|
{
|
|
|
|
return m_mingwDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setMingwDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_mingwDirectory = directory;
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::msvcVersion() const
|
|
|
|
{
|
|
|
|
return m_msvcVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setMsvcVersion(const QString &version)
|
|
|
|
{
|
|
|
|
m_msvcVersion = version;
|
2009-10-22 14:22:16 +02:00
|
|
|
m_toolChainUpToDate = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
void QtVersion::addToEnvironment(ProjectExplorer::Environment &env) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-19 16:50:58 +01:00
|
|
|
env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA")));
|
2009-11-19 17:29:12 +01:00
|
|
|
env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS"));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int QtVersion::uniqueId() const
|
|
|
|
{
|
|
|
|
return m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
int QtVersion::getUniqueId()
|
|
|
|
{
|
2009-04-22 16:51:38 +02:00
|
|
|
return QtVersionManager::instance()->getUniqueId();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QtVersion::isValid() const
|
|
|
|
{
|
2009-11-09 18:59:11 +01:00
|
|
|
updateVersionInfo();
|
2010-01-12 15:46:23 +01:00
|
|
|
return m_id != -1
|
2010-02-02 17:09:41 +01:00
|
|
|
&& !qmakeCommand().isEmpty()
|
|
|
|
&& !displayName().isEmpty()
|
2010-01-12 15:46:23 +01:00
|
|
|
&& !m_notInstalled
|
|
|
|
&& m_versionInfo.contains("QT_INSTALL_BINS");
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::invalidReason() const
|
|
|
|
{
|
|
|
|
if (isValid())
|
|
|
|
return QString();
|
2010-02-01 12:43:56 +01:00
|
|
|
if (qmakeCommand().isEmpty())
|
2010-01-12 15:46:23 +01:00
|
|
|
return QApplication::translate("QtVersion", "No QMake path set");
|
2010-02-01 12:43:56 +01:00
|
|
|
if (displayName().isEmpty())
|
2010-01-12 15:46:23 +01:00
|
|
|
return QApplication::translate("QtVersion", "Qt Version has no name");
|
|
|
|
if (m_notInstalled)
|
|
|
|
return QApplication::translate("QtVersion", "Qt Version is not installed, please run make install");
|
|
|
|
if (!m_versionInfo.contains("QT_INSTALL_BINS"))
|
|
|
|
return QApplication::translate("QtVersion", "Could not determine qt install binary, maybe the qmake path is wrong?");
|
|
|
|
return QString();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-10-13 13:44:13 +02:00
|
|
|
QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-09 18:59:11 +01:00
|
|
|
updateToolChainAndMkspec();
|
2009-10-13 13:44:13 +02:00
|
|
|
QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0);
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
if (m_defaultConfigIsDebugAndRelease)
|
|
|
|
result = QtVersion::BuildAll;
|
|
|
|
if (m_defaultConfigIsDebug)
|
2009-10-13 13:44:13 +02:00
|
|
|
result = result | QtVersion::DebugBuild;
|
2008-12-02 12:01:29 +01:00
|
|
|
return result;
|
|
|
|
}
|
2009-03-25 15:18:37 +01:00
|
|
|
|
|
|
|
bool QtVersion::hasDebuggingHelper() const
|
|
|
|
{
|
|
|
|
return m_hasDebuggingHelper;
|
|
|
|
}
|
|
|
|
|
2009-04-24 14:59:47 +02:00
|
|
|
QString QtVersion::debuggingHelperLibrary() const
|
|
|
|
{
|
|
|
|
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
|
|
|
|
if (qtInstallData.isEmpty())
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-09-03 19:16:22 +02:00
|
|
|
return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData);
|
2009-04-24 14:59:47 +02:00
|
|
|
}
|
|
|
|
|
2009-07-15 17:41:45 +02:00
|
|
|
QStringList QtVersion::debuggingHelperLibraryLocations() const
|
|
|
|
{
|
|
|
|
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
|
|
|
|
if (qtInstallData.isEmpty())
|
2009-09-10 18:07:51 +02:00
|
|
|
return QStringList();
|
2009-09-17 15:45:22 +02:00
|
|
|
return DebuggingHelperLibrary::debuggingHelperLibraryLocationsByInstallData(qtInstallData);
|
2009-07-15 17:41:45 +02:00
|
|
|
}
|
|
|
|
|
2009-05-28 18:15:02 +02:00
|
|
|
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"];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QtVersion::hasExamples() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
return m_hasExamples;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::examplesPath() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
return m_versionInfo["QT_INSTALL_EXAMPLES"];
|
|
|
|
}
|
2009-04-08 11:49:24 +02:00
|
|
|
|
2009-07-14 15:28:07 +02:00
|
|
|
bool QtVersion::isQt64Bit() const
|
2009-05-18 10:46:12 +02:00
|
|
|
{
|
|
|
|
const QString make = qmakeCommand();
|
2009-06-02 17:25:17 +02:00
|
|
|
// qDebug() << make;
|
2009-05-18 10:46:12 +02:00
|
|
|
bool isAmd64 = false;
|
|
|
|
#ifdef Q_OS_WIN32
|
2009-05-22 08:43:05 +02:00
|
|
|
# ifdef __GNUC__ // MinGW lacking some definitions/winbase.h
|
|
|
|
# define SCS_64BIT_BINARY 6
|
2009-10-27 18:05:04 +01:00
|
|
|
# endif
|
2009-05-18 10:46:12 +02:00
|
|
|
DWORD binaryType = 0;
|
2009-05-22 08:43:05 +02:00
|
|
|
bool success = GetBinaryTypeW(reinterpret_cast<const TCHAR*>(make.utf16()), &binaryType) != 0;
|
2009-05-18 10:46:12 +02:00
|
|
|
if (success && binaryType == SCS_64BIT_BINARY)
|
|
|
|
isAmd64=true;
|
|
|
|
// qDebug() << "isAmd64:" << isAmd64 << binaryType;
|
|
|
|
return isAmd64;
|
2009-05-19 14:54:52 +02:00
|
|
|
#else
|
|
|
|
Q_UNUSED(isAmd64)
|
|
|
|
return false;
|
2009-05-18 10:46:12 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
QString QtVersion::buildDebuggingHelperLibrary()
|
|
|
|
{
|
2009-04-08 15:16:02 +02:00
|
|
|
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
|
|
|
|
if (qtInstallData.isEmpty())
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-04-24 14:59:47 +02:00
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
addToEnvironment(env);
|
|
|
|
|
2009-06-10 15:54:56 +02:00
|
|
|
// TODO: the debugging helper doesn't comply to actual tool chain yet
|
2009-10-22 17:09:28 +02:00
|
|
|
QList<QSharedPointer<ProjectExplorer::ToolChain> > alltc = toolChains();
|
|
|
|
ProjectExplorer::ToolChain *tc = alltc.isEmpty() ? 0 : alltc.first().data();
|
2009-10-28 17:01:48 +01:00
|
|
|
if (!tc)
|
2009-10-28 19:03:18 +01:00
|
|
|
return QApplication::tr("The Qt Version has no toolchain.");
|
2009-06-10 15:54:56 +02:00
|
|
|
tc->addToEnvironment(env);
|
2009-08-07 15:20:05 +02:00
|
|
|
QString output;
|
2009-09-03 19:16:22 +02:00
|
|
|
QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, &output);
|
2009-08-07 15:20:05 +02:00
|
|
|
if (!directory.isEmpty())
|
2009-11-09 18:59:11 +01:00
|
|
|
output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
|
2009-04-24 14:59:47 +02:00
|
|
|
m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|