2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
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
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
#include "qtversionfactory.h"
|
|
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
#include "qtsupportconstants.h"
|
|
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <projectexplorer/debugginghelper.h>
|
2011-05-04 13:14:46 +02:00
|
|
|
// only for legay restore
|
2010-04-19 16:07:55 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2011-02-01 18:36:00 +01:00
|
|
|
#include <projectexplorer/toolchainmanager.h>
|
|
|
|
|
#include <projectexplorer/gcctoolchain.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2010-06-11 13:11:37 +02:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2012-03-23 17:41:45 +01:00
|
|
|
#include <utils/filesystemwatcher.h>
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <utils/persistentsettings.h>
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2011-05-04 13:14:46 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-11-03 09:17:02 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
# include <utils/winutils.h>
|
|
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-04-17 08:01:25 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFile>
|
2012-04-17 08:01:25 +02:00
|
|
|
#include <QMainWindow>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-03-11 15:58:33 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
using namespace QtSupport;
|
|
|
|
|
using namespace QtSupport::Internal;
|
2009-04-28 12:43:04 +02:00
|
|
|
|
|
|
|
|
using ProjectExplorer::DebuggingHelperLibrary;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
static const char QTVERSION_DATA_KEY[] = "QtVersion.";
|
|
|
|
|
static const char QTVERSION_TYPE_KEY[] = "QtVersion.Type";
|
|
|
|
|
static const char QTVERSION_COUNT_KEY[] = "QtVersion.Count";
|
2011-05-12 11:53:58 +02:00
|
|
|
static const char OLDQTVERSION_COUNT_KEY[] = "QtVersion.Old.Count";
|
|
|
|
|
static const char OLDQTVERSION_DATA_KEY[] = "QtVersion.Old.";
|
|
|
|
|
static const char OLDQTVERSION_SDKSOURCE[] = "QtVersion.Old.SdkSource";
|
|
|
|
|
static const char OLDQTVERSION_PATH[] = "QtVersion.Old.Path";
|
2011-05-04 13:14:46 +02:00
|
|
|
static const char QTVERSION_FILE_VERSION_KEY[] = "Version";
|
|
|
|
|
static const char QTVERSION_FILENAME[] = "/qtversion.xml";
|
|
|
|
|
|
|
|
|
|
// legacy settings
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char QtVersionsSectionName[] = "QtVersions";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-08-17 11:49:59 +02:00
|
|
|
enum { debug = 0 };
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
template<class T>
|
|
|
|
|
static T *createToolChain(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
QList<ProjectExplorer::ToolChainFactory *> factories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<ProjectExplorer::ToolChainFactory>();
|
|
|
|
|
foreach (ProjectExplorer::ToolChainFactory *f, factories) {
|
|
|
|
|
if (f->id() == id) {
|
|
|
|
|
Q_ASSERT(f->canCreate());
|
|
|
|
|
return static_cast<T *>(f->create());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-23 17:41:45 +01:00
|
|
|
static QString globalSettingsFileName()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
return QFileInfo(pm->globalSettings()->fileName()).absolutePath()
|
|
|
|
|
+ QLatin1String(QTVERSION_FILENAME);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
static QString settingsFileName()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
QFileInfo settingsLocation(pm->settings()->fileName());
|
|
|
|
|
return settingsLocation.absolutePath() + QLatin1String(QTVERSION_FILENAME);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-21 12:16:20 +01:00
|
|
|
|
|
|
|
|
// prefer newer qts otherwise compare on id
|
2011-05-04 13:14:46 +02:00
|
|
|
bool qtVersionNumberCompare(BaseQtVersion *a, BaseQtVersion *b)
|
2011-02-21 12:16:20 +01:00
|
|
|
{
|
|
|
|
|
return a->qtVersion() > b->qtVersion() || (a->qtVersion() == b->qtVersion() && a->uniqueId() < b->uniqueId());
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
// QtVersionManager
|
|
|
|
|
// --------------------------------------------------------------------------
|
2009-04-28 12:43:04 +02:00
|
|
|
QtVersionManager *QtVersionManager::m_self = 0;
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2012-03-30 10:56:09 +02:00
|
|
|
QtVersionManager::QtVersionManager() :
|
2012-05-09 10:47:12 +00:00
|
|
|
m_configFileWatcher(0),
|
|
|
|
|
m_fileWatcherTimer(new QTimer)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-05-27 18:42:27 +02:00
|
|
|
m_self = this;
|
2008-12-02 12:01:29 +01:00
|
|
|
m_idcount = 1;
|
2011-11-25 13:19:58 +01:00
|
|
|
|
|
|
|
|
qRegisterMetaType<Utils::FileName>();
|
2012-05-09 10:47:12 +00:00
|
|
|
|
|
|
|
|
// Give the file a bit of time to settle before reading it...
|
|
|
|
|
m_fileWatcherTimer->setInterval(2000);
|
|
|
|
|
connect(m_fileWatcherTimer, SIGNAL(timeout()), SLOT(updateFromInstaller()));
|
2011-05-04 13:14:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QtVersionManager::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
bool success = restoreQtVersions();
|
|
|
|
|
if (!success)
|
|
|
|
|
success = legacyRestore();
|
|
|
|
|
updateFromInstaller();
|
|
|
|
|
if (!success) {
|
|
|
|
|
// We did neither restore our settings or upgraded
|
|
|
|
|
// in that case figure out if there's a qt in path
|
|
|
|
|
// and add it to the qt versions
|
|
|
|
|
findSystemQt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveQtVersions();
|
2012-03-23 17:41:45 +01:00
|
|
|
|
2012-04-03 10:05:08 +02:00
|
|
|
const QString configFileName = globalSettingsFileName();
|
|
|
|
|
if (QFileInfo(configFileName).exists()) {
|
|
|
|
|
m_configFileWatcher = new Utils::FileSystemWatcher(this);
|
|
|
|
|
connect(m_configFileWatcher, SIGNAL(fileChanged(QString)),
|
2012-05-09 10:47:12 +00:00
|
|
|
m_fileWatcherTimer, SLOT(start()));
|
2012-04-03 10:05:08 +02:00
|
|
|
m_configFileWatcher->addFile(configFileName,
|
|
|
|
|
Utils::FileSystemWatcher::WatchModifiedDate);
|
|
|
|
|
} // exists
|
2011-05-04 13:14:46 +02:00
|
|
|
}
|
|
|
|
|
|
2012-02-02 10:47:33 +01:00
|
|
|
bool QtVersionManager::delayedInitialize()
|
|
|
|
|
{
|
|
|
|
|
updateDocumentation();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
QtVersionManager::~QtVersionManager()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_versions);
|
|
|
|
|
m_versions.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtVersionManager *QtVersionManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QtVersionManager::restoreQtVersions()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
QList<QtVersionFactory *> factories = pm->getObjects<QtVersionFactory>();
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
Utils::PersistentSettingsReader reader;
|
2011-05-04 13:14:46 +02:00
|
|
|
if (!reader.load(settingsFileName()))
|
|
|
|
|
return false;
|
|
|
|
|
QVariantMap data = reader.restoreValues();
|
|
|
|
|
|
|
|
|
|
// Check version:
|
|
|
|
|
int version = data.value(QLatin1String(QTVERSION_FILE_VERSION_KEY), 0).toInt();
|
|
|
|
|
if (version < 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = data.value(QLatin1String(QTVERSION_COUNT_KEY), 0).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1(QTVERSION_DATA_KEY) + QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
const QVariantMap qtversionMap = data.value(key).toMap();
|
2012-01-06 17:43:27 +01:00
|
|
|
const QString type = qtversionMap.value(QLatin1String(QTVERSION_TYPE_KEY)).toString();
|
2011-05-04 13:14:46 +02:00
|
|
|
|
|
|
|
|
bool restored = false;
|
|
|
|
|
foreach (QtVersionFactory *f, factories) {
|
|
|
|
|
if (f->canRestore(type)) {
|
2011-06-28 14:35:38 +02:00
|
|
|
if (BaseQtVersion *qtv = f->restore(type, qtversionMap)) {
|
2011-05-04 13:14:46 +02:00
|
|
|
if (m_versions.contains(qtv->uniqueId())) {
|
|
|
|
|
// This shouldn't happen, we are restoring the same id multiple times?
|
2011-06-14 17:17:24 +02:00
|
|
|
qWarning() << "A Qt version with id"<<qtv->uniqueId()<<"already exists";
|
2011-05-04 13:14:46 +02:00
|
|
|
delete qtv;
|
|
|
|
|
} else {
|
|
|
|
|
m_versions.insert(qtv->uniqueId(), qtv);
|
|
|
|
|
m_idcount = qtv->uniqueId() > m_idcount ? qtv->uniqueId() : m_idcount;
|
|
|
|
|
restored = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!restored)
|
2011-06-14 17:17:24 +02:00
|
|
|
qWarning("Warning: Unable to restore Qt version '%s' stored in %s.",
|
2011-05-04 13:14:46 +02:00
|
|
|
qPrintable(type),
|
|
|
|
|
qPrintable(QDir::toNativeSeparators(settingsFileName())));
|
|
|
|
|
}
|
|
|
|
|
++m_idcount;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QtVersionManager::updateFromInstaller()
|
|
|
|
|
{
|
2012-05-09 10:47:12 +00:00
|
|
|
m_fileWatcherTimer->stop();
|
|
|
|
|
|
2012-03-23 17:41:45 +01:00
|
|
|
// Handle overwritting of data:
|
|
|
|
|
if (m_configFileWatcher) {
|
|
|
|
|
const QString path = globalSettingsFileName();
|
|
|
|
|
m_configFileWatcher->removeFile(path);
|
|
|
|
|
m_configFileWatcher->addFile(path, Utils::FileSystemWatcher::WatchModifiedDate);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-12 11:53:58 +02:00
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
QList<QtVersionFactory *> factories = pm->getObjects<QtVersionFactory>();
|
2011-08-16 10:45:23 +02:00
|
|
|
Utils::PersistentSettingsReader reader;
|
2012-04-30 13:36:33 +02:00
|
|
|
QVariantMap data;
|
|
|
|
|
if (reader.load(globalSettingsFileName()))
|
|
|
|
|
data = reader.restoreValues();
|
2011-05-12 11:53:58 +02:00
|
|
|
|
|
|
|
|
if (debug) {
|
2011-06-14 17:17:24 +02:00
|
|
|
qDebug()<< "======= Existing Qt versions =======";
|
2011-05-12 11:53:58 +02:00
|
|
|
foreach (BaseQtVersion *version, m_versions) {
|
2011-11-25 13:19:58 +01:00
|
|
|
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
2011-05-12 11:53:58 +02:00
|
|
|
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
|
|
|
|
qDebug() << "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int oldcount = data.value(QLatin1String(OLDQTVERSION_COUNT_KEY), 0).toInt();
|
|
|
|
|
for (int i=0; i < oldcount; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1(OLDQTVERSION_DATA_KEY) +QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
break;
|
|
|
|
|
QVariantMap map = data.value(key).toMap();
|
2012-01-06 17:43:27 +01:00
|
|
|
Utils::FileName path = Utils::FileName::fromString(map.value(QLatin1String(OLDQTVERSION_PATH)).toString());
|
|
|
|
|
QString autodetectionSource = map.value(QLatin1String(OLDQTVERSION_SDKSOURCE)).toString();
|
2011-05-12 11:53:58 +02:00
|
|
|
foreach (BaseQtVersion *v, m_versions) {
|
|
|
|
|
if (v->qmakeCommand() == path) {
|
|
|
|
|
if (v->autodetectionSource().isEmpty()) {
|
|
|
|
|
v->setAutoDetectionSource(autodetectionSource);
|
|
|
|
|
} else {
|
|
|
|
|
if (debug)
|
2011-11-25 13:19:58 +01:00
|
|
|
qDebug() << "## Conflicting autodetictonSource for"<<path.toString()<<"\n"
|
2011-05-12 11:53:58 +02:00
|
|
|
<<" version retains"<<v->autodetectionSource();
|
|
|
|
|
}
|
|
|
|
|
// No break, we want to mark all qt versions matching that path
|
|
|
|
|
// There's no way for us to decide whether this qt was added
|
|
|
|
|
// by the user or by the installer, so we treat them all as coming
|
|
|
|
|
// from the installer. Thus removing/updating them deletes/updates them all
|
|
|
|
|
// Note: This only applies to versions that are marked via QtVersion.Old
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
qDebug()<< "======= After using OLD QtVersion data to mark versions =======";
|
|
|
|
|
foreach (BaseQtVersion *version, m_versions) {
|
2011-11-25 13:19:58 +01:00
|
|
|
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
2011-05-12 11:53:58 +02:00
|
|
|
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
|
|
|
|
qDebug() << "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qDebug()<< "======= Adding sdk versions =======";
|
|
|
|
|
}
|
|
|
|
|
QStringList sdkVersions;
|
|
|
|
|
int count = data.value(QLatin1String(QTVERSION_COUNT_KEY), 0).toInt();
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
|
const QString key = QString::fromLatin1(QTVERSION_DATA_KEY) + QString::number(i);
|
|
|
|
|
if (!data.contains(key))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
QVariantMap qtversionMap = data.value(key).toMap();
|
2012-01-06 17:43:27 +01:00
|
|
|
const QString type = qtversionMap.value(QLatin1String(QTVERSION_TYPE_KEY)).toString();
|
2011-05-12 11:53:58 +02:00
|
|
|
const QString autoDetectionSource = qtversionMap.value(QLatin1String("autodetectionSource")).toString();
|
|
|
|
|
sdkVersions << autoDetectionSource;
|
|
|
|
|
int id = -1; // see BaseQtVersion::fromMap()
|
|
|
|
|
QtVersionFactory *factory = 0;
|
|
|
|
|
foreach (QtVersionFactory *f, factories) {
|
|
|
|
|
if (f->canRestore(type)) {
|
|
|
|
|
factory = f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!factory) {
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug("Warning: Unable to find factory for type '%s'", qPrintable(type));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// First try to find a existing qt version to update
|
|
|
|
|
bool restored = false;
|
|
|
|
|
foreach (BaseQtVersion *v, m_versions) {
|
|
|
|
|
if (v->autodetectionSource() == autoDetectionSource) {
|
|
|
|
|
id = v->uniqueId();
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << " Qt version found with same autodetection source" << autoDetectionSource << " => Migrating id:" << id;
|
|
|
|
|
removeVersion(v);
|
|
|
|
|
qtversionMap[QLatin1String("Id")] = id;
|
|
|
|
|
|
2011-06-28 14:35:38 +02:00
|
|
|
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
2011-05-12 11:53:58 +02:00
|
|
|
Q_ASSERT(qtv->isAutodetected());
|
|
|
|
|
addVersion(qtv);
|
|
|
|
|
restored = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Create a new qtversion
|
|
|
|
|
if (!restored) { // didn't replace any existing versions
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << " No Qt version found matching" << autoDetectionSource << " => Creating new version";
|
2011-06-28 14:35:38 +02:00
|
|
|
if (BaseQtVersion *qtv = factory->restore(type, qtversionMap)) {
|
2011-05-12 11:53:58 +02:00
|
|
|
Q_ASSERT(qtv->isAutodetected());
|
|
|
|
|
addVersion(qtv);
|
|
|
|
|
restored = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!restored)
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug("Warning: Unable to update qtversion '%s' from sdk installer.",
|
|
|
|
|
qPrintable(autoDetectionSource));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
qDebug() << "======= Before removing outdated sdk versions =======";
|
|
|
|
|
foreach (BaseQtVersion *version, m_versions) {
|
2011-11-25 13:19:58 +01:00
|
|
|
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
2011-05-12 11:53:58 +02:00
|
|
|
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
|
|
|
|
qDebug() << "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (BaseQtVersion *qtVersion, QtVersionManager::instance()->versions()) {
|
2012-01-06 17:43:27 +01:00
|
|
|
if (qtVersion->autodetectionSource().startsWith(QLatin1String("SDK."))) {
|
2011-05-12 11:53:58 +02:00
|
|
|
if (!sdkVersions.contains(qtVersion->autodetectionSource())) {
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << " removing version"<<qtVersion->autodetectionSource();
|
|
|
|
|
removeVersion(qtVersion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
qDebug()<< "======= End result =======";
|
|
|
|
|
foreach (BaseQtVersion *version, m_versions) {
|
2011-11-25 13:19:58 +01:00
|
|
|
qDebug() << version->qmakeCommand().toString() << "id:"<<version->uniqueId();
|
2011-05-12 11:53:58 +02:00
|
|
|
qDebug() << " autodetection source:"<< version->autodetectionSource();
|
|
|
|
|
qDebug() << "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-04 13:14:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QtVersionManager::saveQtVersions()
|
|
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
Utils::PersistentSettingsWriter writer;
|
2011-05-04 13:14:46 +02:00
|
|
|
writer.saveValue(QLatin1String(QTVERSION_FILE_VERSION_KEY), 1);
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (BaseQtVersion *qtv, m_versions) {
|
|
|
|
|
QVariantMap tmp = qtv->toMap();
|
|
|
|
|
if (tmp.isEmpty())
|
|
|
|
|
continue;
|
2012-01-06 17:43:27 +01:00
|
|
|
tmp.insert(QLatin1String(QTVERSION_TYPE_KEY), qtv->type());
|
2011-05-04 13:14:46 +02:00
|
|
|
writer.saveValue(QString::fromLatin1(QTVERSION_DATA_KEY) + QString::number(count), tmp);
|
|
|
|
|
++count;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
writer.saveValue(QLatin1String(QTVERSION_COUNT_KEY), count);
|
2012-01-24 15:36:40 +01:00
|
|
|
writer.save(settingsFileName(), QLatin1String("QtCreatorQtVersions"), Core::ICore::mainWindow());
|
2011-05-04 13:14:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QtVersionManager::findSystemQt()
|
|
|
|
|
{
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName systemQMakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment());
|
2011-05-04 13:14:46 +02:00
|
|
|
if (systemQMakePath.isNull())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath);
|
2011-05-20 15:52:58 +02:00
|
|
|
version->setDisplayName(BaseQtVersion::defaultDisplayName(version->qtVersionString(), systemQMakePath, true));
|
2011-05-04 13:14:46 +02:00
|
|
|
m_versions.insert(version->uniqueId(), version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QtVersionManager::legacyRestore()
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *s = Core::ICore::settings();
|
2012-01-06 17:43:27 +01:00
|
|
|
const QString qtVersionSection = QLatin1String(QtVersionsSectionName);
|
|
|
|
|
if (!s->contains(qtVersionSection + QLatin1String("/size")))
|
2011-05-04 13:14:46 +02:00
|
|
|
return false;
|
2012-01-06 17:43:27 +01:00
|
|
|
int size = s->beginReadArray(qtVersionSection);
|
2008-12-02 12:01:29 +01:00
|
|
|
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.
|
2012-01-06 17:43:27 +01:00
|
|
|
int id = s->value(QLatin1String("Id"), -1).toInt();
|
2008-12-02 12:01:29 +01:00
|
|
|
if (id == -1)
|
|
|
|
|
id = getUniqueId();
|
2009-10-01 18:51:42 +02:00
|
|
|
else if (m_idcount < id)
|
|
|
|
|
m_idcount = id + 1;
|
2011-05-04 13:14:46 +02:00
|
|
|
|
2012-01-06 17:43:27 +01:00
|
|
|
Utils::FileName qmakePath = Utils::FileName::fromString(s->value(QLatin1String("QMakePath")).toString());
|
2011-05-04 13:14:46 +02:00
|
|
|
if (qmakePath.isEmpty())
|
|
|
|
|
continue; //skip this version
|
|
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
BaseQtVersion *version = QtVersionFactory::createQtVersionFromLegacySettings(qmakePath, id, s);
|
2011-05-04 13:14:46 +02:00
|
|
|
if (!version) // Likely to be a invalid version
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (m_versions.contains(version->uniqueId())) {
|
|
|
|
|
// oh uh;
|
|
|
|
|
delete version;
|
|
|
|
|
} else {
|
|
|
|
|
m_versions.insert(version->uniqueId(), version);
|
2009-09-03 19:16:22 +02:00
|
|
|
}
|
2011-05-04 13:14:46 +02:00
|
|
|
// Update from 2.1 or earlier:
|
|
|
|
|
QString mingwDir = s->value(QLatin1String("MingwDirectory")).toString();
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!mingwDir.isEmpty()) {
|
2011-03-15 17:23:17 +01:00
|
|
|
QFileInfo fi(mingwDir + QLatin1String("/bin/g++.exe"));
|
|
|
|
|
if (fi.exists() && fi.isExecutable()) {
|
2012-01-06 17:43:27 +01:00
|
|
|
ProjectExplorer::MingwToolChain *tc = createToolChain<ProjectExplorer::MingwToolChain>(QLatin1String(ProjectExplorer::Constants::MINGW_TOOLCHAIN_ID));
|
2011-03-15 17:23:17 +01:00
|
|
|
if (tc) {
|
2012-01-30 13:07:51 +01:00
|
|
|
tc->setCompilerCommand(Utils::FileName(fi));
|
2011-03-15 17:23:17 +01:00
|
|
|
tc->setDisplayName(tr("MinGW from %1").arg(version->displayName()));
|
2011-04-13 16:45:38 +02:00
|
|
|
// The debugger is set later in the autoDetect method of the MinGw tool chain factory
|
|
|
|
|
// as the default debuggers are not yet registered.
|
2011-03-15 17:23:17 +01:00
|
|
|
ProjectExplorer::ToolChainManager::instance()->registerToolChain(tc);
|
|
|
|
|
}
|
2011-02-01 18:36:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-30 15:47:51 +02:00
|
|
|
const QString mwcDir = s->value(QLatin1String("MwcDirectory")).toString();
|
|
|
|
|
if (!mwcDir.isEmpty())
|
|
|
|
|
m_pendingMwcUpdates.append(mwcDir);
|
|
|
|
|
const QString gcceDir = s->value(QLatin1String("GcceDirectory")).toString();
|
|
|
|
|
if (!gcceDir.isEmpty())
|
|
|
|
|
m_pendingGcceUpdates.append(gcceDir);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
s->endArray();
|
2012-01-06 17:43:27 +01:00
|
|
|
s->remove(qtVersionSection);
|
2011-05-04 13:14:46 +02:00
|
|
|
return true;
|
2009-04-22 16:51:38 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
void QtVersionManager::addVersion(BaseQtVersion *version)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-12 15:31:20 +02:00
|
|
|
QTC_ASSERT(version != 0, return);
|
2011-02-21 12:16:20 +01:00
|
|
|
if (m_versions.contains(version->uniqueId()))
|
2010-03-26 10:37:05 +01:00
|
|
|
return;
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
int uniqueId = version->uniqueId();
|
2011-02-21 12:16:20 +01:00
|
|
|
m_versions.insert(uniqueId, version);
|
|
|
|
|
|
2012-02-24 18:57:33 +01:00
|
|
|
emit qtVersionsChanged(QList<int>() << uniqueId, QList<int>(), QList<int>());
|
2011-05-04 13:14:46 +02:00
|
|
|
saveQtVersions();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
void QtVersionManager::removeVersion(BaseQtVersion *version)
|
2009-05-28 13:22:23 +02:00
|
|
|
{
|
2009-10-12 15:31:20 +02:00
|
|
|
QTC_ASSERT(version != 0, return);
|
2011-02-21 12:16:20 +01:00
|
|
|
m_versions.remove(version->uniqueId());
|
2012-02-24 18:57:33 +01:00
|
|
|
emit qtVersionsChanged(QList<int>(), QList<int>() << version->uniqueId(), QList<int>());
|
2011-05-04 13:14:46 +02:00
|
|
|
saveQtVersions();
|
2009-05-28 13:22:23 +02:00
|
|
|
delete version;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
bool QtVersionManager::supportsTargetId(Core::Id id) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(id);
|
|
|
|
|
foreach (BaseQtVersion *v, versions)
|
2011-04-12 19:05:32 +02:00
|
|
|
if (v->isValid() && v->toolChainAvailable(id))
|
2010-02-08 15:50:06 +01:00
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<BaseQtVersion *> QtVersionManager::versionsForTargetId(Core::Id id,
|
2011-10-17 14:18:40 +02:00
|
|
|
const QtVersionNumber &minimumQtVersion,
|
|
|
|
|
const QtVersionNumber &maximumQtVersion) const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> targetVersions;
|
|
|
|
|
foreach (BaseQtVersion *version, m_versions) {
|
2011-10-17 14:18:40 +02:00
|
|
|
if (version->supportsTargetId(id) && version->qtVersion() >= minimumQtVersion
|
|
|
|
|
&& version->qtVersion() <= maximumQtVersion)
|
2010-02-08 15:50:06 +01:00
|
|
|
targetVersions.append(version);
|
|
|
|
|
}
|
2011-02-21 12:16:20 +01:00
|
|
|
qSort(targetVersions.begin(), targetVersions.end(), &qtVersionNumberCompare);
|
2010-02-08 15:50:06 +01:00
|
|
|
return targetVersions;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QSet<Core::Id> QtVersionManager::supportedTargetIds() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
QSet<Core::Id> results;
|
2011-05-04 13:14:46 +02:00
|
|
|
foreach (BaseQtVersion *version, m_versions)
|
2010-02-08 15:50:06 +01:00
|
|
|
results.unite(version->supportedTargetIds());
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void QtVersionManager::updateDocumentation()
|
|
|
|
|
{
|
2010-06-11 13:11:37 +02:00
|
|
|
Core::HelpManager *helpManager = Core::HelpManager::instance();
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(helpManager);
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList files;
|
2011-05-04 13:14:46 +02:00
|
|
|
foreach (BaseQtVersion *v, m_versions) {
|
|
|
|
|
const QString docPath = v->documentationPath() + QLatin1String("/qch/");
|
2009-12-17 15:51:42 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
void QtVersionManager::updateDumpFor(const Utils::FileName &qmakeCommand)
|
2011-05-09 11:19:37 +02:00
|
|
|
{
|
|
|
|
|
foreach (BaseQtVersion *v, versions()) {
|
|
|
|
|
if (v->qmakeCommand() == qmakeCommand)
|
|
|
|
|
v->recheckDumper();
|
|
|
|
|
}
|
2011-05-13 13:17:24 +02:00
|
|
|
emit dumpUpdatedFor(qmakeCommand);
|
2011-05-09 11:19:37 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
int QtVersionManager::getUniqueId()
|
|
|
|
|
{
|
|
|
|
|
return m_idcount++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> QtVersionManager::versions() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> versions;
|
|
|
|
|
foreach (BaseQtVersion *version, m_versions)
|
2011-02-21 12:16:20 +01:00
|
|
|
versions << version;
|
|
|
|
|
qSort(versions.begin(), versions.end(), &qtVersionNumberCompare);
|
|
|
|
|
return versions;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> QtVersionManager::validVersions() const
|
2010-03-26 10:37:05 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> results;
|
2011-05-12 12:25:25 +02:00
|
|
|
foreach (BaseQtVersion *v, m_versions) {
|
2010-03-26 10:37:05 +01:00
|
|
|
if (v->isValid())
|
|
|
|
|
results.append(v);
|
|
|
|
|
}
|
2011-02-21 12:16:20 +01:00
|
|
|
qSort(results.begin(), results.end(), &qtVersionNumberCompare);
|
2010-03-26 10:37:05 +01:00
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 15:46:23 +01:00
|
|
|
bool QtVersionManager::isValidId(int id) const
|
|
|
|
|
{
|
2011-02-21 12:16:20 +01:00
|
|
|
return m_versions.contains(id);
|
2010-01-12 15:46:23 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-30 15:47:51 +02:00
|
|
|
QString QtVersionManager::popPendingMwcUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (m_pendingMwcUpdates.isEmpty())
|
|
|
|
|
return QString();
|
|
|
|
|
return m_pendingMwcUpdates.takeFirst();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QtVersionManager::popPendingGcceUpdate()
|
|
|
|
|
{
|
|
|
|
|
if (m_pendingGcceUpdates.isEmpty())
|
|
|
|
|
return QString();
|
|
|
|
|
return m_pendingGcceUpdates.takeFirst();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 17:25:35 +01:00
|
|
|
Core::FeatureSet QtVersionManager::availableFeatures(const QString &platformName) const
|
2012-01-18 13:50:14 +01:00
|
|
|
{
|
|
|
|
|
Core::FeatureSet features;
|
|
|
|
|
foreach (BaseQtVersion *const qtVersion, validVersions()) {
|
2012-02-08 17:25:35 +01:00
|
|
|
if (qtVersion->isValid() && ((qtVersion->platformName() == platformName) || platformName.isEmpty()))
|
2012-01-18 13:50:14 +01:00
|
|
|
features |= qtVersion->availableFeatures();
|
|
|
|
|
}
|
2012-02-14 13:50:38 +01:00
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
return features;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 17:25:35 +01:00
|
|
|
QStringList QtVersionManager::availablePlatforms() const
|
|
|
|
|
{
|
|
|
|
|
QStringList platforms;
|
|
|
|
|
foreach (BaseQtVersion *const qtVersion, validVersions()) {
|
|
|
|
|
if (qtVersion->isValid() && !qtVersion->platformName().isEmpty())
|
|
|
|
|
platforms.append(qtVersion->platformName());
|
|
|
|
|
}
|
|
|
|
|
platforms.removeDuplicates();
|
|
|
|
|
return platforms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QtVersionManager::displayNameForPlatform(const QString &string) const
|
|
|
|
|
{
|
|
|
|
|
foreach (BaseQtVersion *const qtVersion, validVersions()) {
|
|
|
|
|
if (qtVersion->platformName() == string)
|
|
|
|
|
return qtVersion->platformDisplayName();
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
BaseQtVersion *QtVersionManager::version(int id) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
QMap<int, BaseQtVersion *>::const_iterator it = m_versions.find(id);
|
2011-02-21 12:16:20 +01:00
|
|
|
if (it == m_versions.constEnd())
|
2011-05-04 13:14:46 +02:00
|
|
|
return 0;
|
2011-02-21 12:16:20 +01:00
|
|
|
return it.value();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
class SortByUniqueId
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-05-04 13:14:46 +02:00
|
|
|
bool operator()(BaseQtVersion *a, BaseQtVersion *b)
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
|
|
|
|
return a->uniqueId() < b->uniqueId();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
bool QtVersionManager::equals(BaseQtVersion *a, BaseQtVersion *b)
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
return a->equals(b);
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> 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
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *> sortedNewVersions = newVersions;
|
2009-12-03 18:37:27 +01:00
|
|
|
SortByUniqueId sortByUniqueId;
|
|
|
|
|
qSort(sortedNewVersions.begin(), sortedNewVersions.end(), sortByUniqueId);
|
|
|
|
|
|
2012-02-24 18:57:33 +01:00
|
|
|
QList<int> addedVersions;
|
|
|
|
|
QList<int> removedVersions;
|
2009-12-03 18:37:27 +01:00
|
|
|
QList<int> changedVersions;
|
|
|
|
|
// So we trying to find the minimal set of changed versions,
|
|
|
|
|
// iterate over both sorted list
|
|
|
|
|
|
|
|
|
|
// newVersions and oldVersions iterator
|
2011-05-04 13:14:46 +02:00
|
|
|
QList<BaseQtVersion *>::const_iterator nit, nend;
|
|
|
|
|
QMap<int, BaseQtVersion *>::const_iterator oit, oend;
|
2009-12-03 18:37:27 +01:00
|
|
|
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) {
|
2012-02-24 18:57:33 +01:00
|
|
|
addedVersions.push_back(nid);
|
2009-12-03 18:37:27 +01:00
|
|
|
++nit;
|
|
|
|
|
} else if (oid < nid) {
|
2012-02-24 18:57:33 +01:00
|
|
|
removedVersions.push_back(oid);
|
2009-12-03 18:37:27 +01:00
|
|
|
++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) {
|
2012-02-24 18:57:33 +01:00
|
|
|
addedVersions.push_back((*nit)->uniqueId());
|
2009-12-10 12:08:40 +01:00
|
|
|
++nit;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (oit != oend) {
|
2012-02-24 18:57:33 +01:00
|
|
|
removedVersions.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();
|
2011-05-04 13:14:46 +02:00
|
|
|
foreach (BaseQtVersion *v, sortedNewVersions)
|
2011-02-21 12:16:20 +01:00
|
|
|
m_versions.insert(v->uniqueId(), v);
|
2009-12-03 18:37:27 +01:00
|
|
|
|
2012-02-24 18:57:33 +01:00
|
|
|
if (!changedVersions.isEmpty() || !addedVersions.isEmpty() || !removedVersions.isEmpty())
|
2009-04-22 18:05:55 +02:00
|
|
|
updateDocumentation();
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
saveQtVersions();
|
2009-12-03 18:37:27 +01:00
|
|
|
|
2012-02-24 18:57:33 +01:00
|
|
|
if (!changedVersions.isEmpty() || !addedVersions.isEmpty() || !removedVersions.isEmpty())
|
|
|
|
|
emit qtVersionsChanged(addedVersions, removedVersions, changedVersions);
|
2009-04-22 18:05:55 +02:00
|
|
|
}
|
|
|
|
|
|
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);
|
2011-11-25 13:19:58 +01:00
|
|
|
Utils::FileName QtVersionManager::findQMakeBinaryFromMakefile(const QString &makefile)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
bool debugAdding = false;
|
2010-10-05 17:38:45 +02:00
|
|
|
QFile fi(makefile);
|
|
|
|
|
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
|
|
|
|
QTextStream ts(&fi);
|
2012-01-06 17:43:27 +01:00
|
|
|
QRegExp r1(QLatin1String("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
|
2010-04-14 17:45:23 +02:00
|
|
|
if (!qmakePath.endsWith(QLatin1String(".exe")))
|
|
|
|
|
qmakePath.append(QLatin1String(".exe"));
|
2009-08-27 15:08:47 +02:00
|
|
|
#endif
|
2010-02-19 11:41:34 +01:00
|
|
|
// Is qmake still installed?
|
2010-08-24 18:10:08 +02:00
|
|
|
QFileInfo fi(qmakePath);
|
|
|
|
|
if (fi.exists()) {
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName(fi);
|
2010-08-24 18:10:08 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-25 13:19:58 +01:00
|
|
|
return Utils::FileName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-25 13:19:58 +01:00
|
|
|
BaseQtVersion *QtVersionManager::qtVersionForQMakeBinary(const Utils::FileName &qmakePath)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-05-12 12:25:25 +02:00
|
|
|
foreach (BaseQtVersion *version, versions()) {
|
2011-05-04 13:14:46 +02:00
|
|
|
if (version->qmakeCommand() == qmakePath) {
|
|
|
|
|
return version;
|
2010-08-24 18:07:03 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-19 19:24:30 +02:00
|
|
|
QtVersionManager::MakefileCompatible QtVersionManager::makefileIsFor(const QString &makefile, const QString &proFile)
|
2010-04-12 19:16:49 +02:00
|
|
|
{
|
|
|
|
|
if (proFile.isEmpty())
|
2011-04-19 19:24:30 +02:00
|
|
|
return CouldNotParse;
|
2010-04-12 19:16:49 +02:00
|
|
|
|
2011-11-21 17:36:00 +01:00
|
|
|
// The Makefile.Debug / Makefile.Release lack a # Command: line
|
|
|
|
|
if (findQMakeLine(makefile, QLatin1String("# Command:")).trimmed().isEmpty())
|
|
|
|
|
return CouldNotParse;
|
|
|
|
|
|
2010-10-05 17:38:45 +02:00
|
|
|
QString line = findQMakeLine(makefile, QLatin1String("# Project:")).trimmed();
|
2010-04-12 19:16:49 +02:00
|
|
|
if (line.isEmpty())
|
2011-04-19 19:24:30 +02:00
|
|
|
return CouldNotParse;
|
2010-04-12 19:16:49 +02:00
|
|
|
|
2012-01-06 17:43:27 +01:00
|
|
|
line.remove(0, line.indexOf(QLatin1Char(':')) + 1);
|
2010-04-12 19:16:49 +02:00
|
|
|
line = line.trimmed();
|
|
|
|
|
|
2010-10-05 17:38:45 +02:00
|
|
|
QFileInfo srcFileInfo(QFileInfo(makefile).absoluteDir(), line);
|
2010-04-12 19:16:49 +02:00
|
|
|
QFileInfo proFileInfo(proFile);
|
2011-04-19 19:24:30 +02:00
|
|
|
return (srcFileInfo == proFileInfo) ? SameProject : DifferentProject;
|
2010-04-12 19:16:49 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-04 13:14:46 +02:00
|
|
|
QPair<BaseQtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, BaseQtVersion::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:";
|
2011-05-04 13:14:46 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs result = defaultBuildConfig;
|
2010-10-19 11:14:03 +02:00
|
|
|
QString result2;
|
2009-07-22 16:52:44 +02:00
|
|
|
|
2010-10-05 17:38:45 +02:00
|
|
|
QString line = findQMakeLine(makefile, QLatin1String("# Command:"));
|
2009-07-22 16:52:44 +02:00
|
|
|
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);
|
|
|
|
|
QList<QMakeAssignment> assignments;
|
|
|
|
|
QList<QMakeAssignment> afterAssignments;
|
2010-10-19 11:14:03 +02:00
|
|
|
parseArgs(line, &assignments, &afterAssignments, &result2);
|
2009-07-22 16:52:44 +02:00
|
|
|
|
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);
|
|
|
|
|
|
2010-04-23 11:28:02 +02:00
|
|
|
if (debug)
|
|
|
|
|
dumpQMakeAssignments(assignments);
|
2009-07-22 16:52:44 +02:00
|
|
|
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, assignments)
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&result2, qa.variable + qa.op + qa.value);
|
2009-07-22 16:52:44 +02:00
|
|
|
if (!afterAssignments.isEmpty()) {
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&result2, QLatin1String("-after"));
|
2010-02-01 14:00:07 +01:00
|
|
|
foreach(const QMakeAssignment &qa, afterAssignments)
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&result2, qa.variable + qa.op + qa.value);
|
2009-07-22 16:52:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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";
|
2012-01-06 17:43:27 +01:00
|
|
|
qDebug()<<" "<< (result & BaseQtVersion::NoBuild ? QByteArray("No Build") : QByteArray::number(int(result)));
|
2011-05-04 13:14:46 +02:00
|
|
|
qDebug()<<" "<< (result & BaseQtVersion::DebugBuild ? "debug" : "release");
|
|
|
|
|
qDebug()<<" "<< (result & BaseQtVersion::BuildAll ? "debug_and_release" : "no debug_and_release");
|
2009-08-17 11:49:59 +02:00
|
|
|
qDebug()<<"\nAddtional Arguments";
|
|
|
|
|
qDebug()<<result2;
|
|
|
|
|
qDebug()<<"\n\n";
|
|
|
|
|
}
|
2009-07-22 16:52:44 +02:00
|
|
|
return qMakePair(result, result2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-05 17:38:45 +02:00
|
|
|
QString QtVersionManager::findQMakeLine(const QString &makefile, const QString &key)
|
2009-07-22 16:52:44 +02:00
|
|
|
{
|
2010-10-05 17:38:45 +02:00
|
|
|
QFile fi(makefile);
|
|
|
|
|
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
|
|
|
|
QTextStream ts(&fi);
|
2008-12-02 12:01:29 +01:00
|
|
|
while (!ts.atEnd()) {
|
2010-02-01 12:43:56 +01:00
|
|
|
const QString line = ts.readLine();
|
2010-04-12 19:16:49 +02:00
|
|
|
if (line.startsWith(key))
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
void QtVersionManager::parseArgs(const QString &args, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments, QString *additionalArguments)
|
2009-07-22 16:52:44 +02:00
|
|
|
{
|
2012-01-06 17:43:27 +01:00
|
|
|
QRegExp regExp(QLatin1String("([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)"));
|
2009-07-22 16:52:44 +02:00
|
|
|
bool after = false;
|
|
|
|
|
bool ignoreNext = false;
|
2010-10-19 11:14:03 +02:00
|
|
|
*additionalArguments = args;
|
|
|
|
|
Utils::QtcProcess::ArgIterator ait(additionalArguments);
|
|
|
|
|
while (ait.next()) {
|
2009-07-22 16:52:44 +02:00
|
|
|
if (ignoreNext) {
|
|
|
|
|
// Ignoring
|
|
|
|
|
ignoreNext = false;
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (ait.value() == QLatin1String("-after")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
after = true;
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (ait.value().contains(QLatin1Char('='))) {
|
|
|
|
|
if (regExp.exactMatch(ait.value())) {
|
2009-07-22 16:52:44 +02:00
|
|
|
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";
|
|
|
|
|
}
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
} else if (ait.value() == QLatin1String("-o")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
ignoreNext = true;
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
2009-07-22 16:52:44 +02:00
|
|
|
#if defined(Q_OS_WIN32)
|
2010-10-19 11:14:03 +02:00
|
|
|
} else if (ait.value() == QLatin1String("-win32")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
#elif defined(Q_OS_MAC)
|
2010-10-19 11:14:03 +02:00
|
|
|
} else if (ait.value() == QLatin1String("-macx")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
#elif defined(Q_OS_QNX6)
|
2010-10-19 11:14:03 +02:00
|
|
|
} else if (ait.value() == QLatin1String("-qnx6")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
#else
|
2010-10-19 11:14:03 +02:00
|
|
|
} else if (ait.value() == QLatin1String("-unix")) {
|
2009-07-22 16:52:44 +02:00
|
|
|
#endif
|
2010-10-19 11:14:03 +02:00
|
|
|
ait.deleteArg();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ait.deleteArg(); // The .pro file is always the last arg
|
2009-07-22 16:52:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// This function extracts all the CONFIG+=debug, CONFIG+=release
|
2011-05-04 13:14:46 +02:00
|
|
|
BaseQtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, BaseQtVersion::QmakeBuildConfigs defaultBuildConfig)
|
2009-07-22 16:52:44 +02:00
|
|
|
{
|
2011-05-04 13:14:46 +02:00
|
|
|
BaseQtVersion::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) {
|
2012-01-06 17:43:27 +01:00
|
|
|
if (qa.variable == QLatin1String("CONFIG")) {
|
|
|
|
|
QStringList values = qa.value.split(QLatin1Char(' '));
|
2009-07-22 16:52:44 +02:00
|
|
|
QStringList newValues;
|
|
|
|
|
foreach(const QString &value, values) {
|
2012-01-06 17:43:27 +01:00
|
|
|
if (value == QLatin1String("debug")) {
|
|
|
|
|
if (qa.op == QLatin1String("+="))
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result | BaseQtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result & ~BaseQtVersion::DebugBuild;
|
2012-01-06 17:43:27 +01:00
|
|
|
} else if (value == QLatin1String("release")) {
|
|
|
|
|
if (qa.op == QLatin1String("+="))
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result & ~BaseQtVersion::DebugBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result | BaseQtVersion::DebugBuild;
|
2012-01-06 17:43:27 +01:00
|
|
|
} else if (value == QLatin1String("debug_and_release")) {
|
|
|
|
|
if (qa.op == QLatin1String("+="))
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result | BaseQtVersion::BuildAll;
|
2009-07-22 16:52:44 +02:00
|
|
|
else
|
2011-05-04 13:14:46 +02:00
|
|
|
result = result & ~BaseQtVersion::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;
|
2012-01-06 17:43:27 +01:00
|
|
|
newQA.value = newValues.join(QLatin1String(" "));
|
2009-07-22 16:52:44 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2012-02-08 17:25:35 +01:00
|
|
|
Core::FeatureSet QtFeatureProvider::availableFeatures(const QString &platformName) const
|
|
|
|
|
{
|
|
|
|
|
return QtVersionManager::instance()->availableFeatures(platformName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList QtFeatureProvider::availablePlatforms() const
|
|
|
|
|
{
|
|
|
|
|
return QtVersionManager::instance()->availablePlatforms();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QtFeatureProvider::displayNameForPlatform(const QString &string) const
|
2012-01-18 13:50:14 +01:00
|
|
|
{
|
2012-02-08 17:25:35 +01:00
|
|
|
return QtVersionManager::instance()->displayNameForPlatform(string);
|
2012-01-18 13:50:14 +01:00
|
|
|
}
|