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"
|
2009-05-25 16:43:50 +02:00
|
|
|
#include "profilereader.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-28 18:36:52 +02:00
|
|
|
#ifdef QTCREATOR_WITH_S60
|
|
|
|
#include "qt-s60/s60manager.h"
|
|
|
|
#endif
|
|
|
|
|
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>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <help/helpplugin.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-25 16:43:50 +02: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-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 *defaultQtVersionKey = "DefaultQtVersion";
|
|
|
|
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-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_defaultVersion = s->value(defaultQtVersionKey, 0).toInt();
|
|
|
|
|
|
|
|
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();
|
|
|
|
else if (id > m_idcount)
|
|
|
|
m_idcount = id;
|
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);
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersion *version = new QtVersion(s->value("Name").toString(),
|
|
|
|
s->value("Path").toString(),
|
|
|
|
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
|
|
|
#ifdef QTCREATOR_WITH_S60
|
|
|
|
version->setMwcDirectory(s->value("MwcDirectory").toString());
|
|
|
|
#endif
|
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-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)
|
|
|
|
{
|
|
|
|
m_versions.append(version);
|
|
|
|
emit qtVersionsChanged();
|
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)
|
|
|
|
{
|
|
|
|
m_versions.removeAll(version);
|
|
|
|
emit qtVersionsChanged();
|
|
|
|
writeVersionsIntoSettings();
|
|
|
|
delete version;
|
|
|
|
}
|
|
|
|
|
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 fileEndings = QStringList() << "/qch/qt.qch" << "/qch/qmake.qch" << "/qch/designer.qch";
|
|
|
|
QStringList files;
|
|
|
|
foreach (QtVersion *version, m_versions) {
|
2009-05-28 18:15:02 +02:00
|
|
|
QString docPath = version->documentationPath();
|
2008-12-02 12:01:29 +01:00
|
|
|
foreach (const QString &fileEnding, fileEndings)
|
|
|
|
files << docPath+fileEnding;
|
|
|
|
}
|
|
|
|
helpManager->registerDocumentation(files);
|
|
|
|
}
|
|
|
|
|
2009-05-28 18:15:02 +02:00
|
|
|
void QtVersionManager::updateExamples()
|
|
|
|
{
|
|
|
|
QList<QtVersion *> versions;
|
|
|
|
versions.append(currentQtVersion());
|
|
|
|
versions.append(m_versions);
|
|
|
|
|
|
|
|
QString examplesPath;
|
|
|
|
QString docPath;
|
|
|
|
QString demosPath;
|
|
|
|
QtVersion *version = 0;
|
2009-06-12 14:58:59 +02:00
|
|
|
// try to find a version which has both, demos and examples, starting with default Qt
|
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();
|
2008-12-02 12:01:29 +01:00
|
|
|
s->setValue(defaultQtVersionKey, m_defaultVersion);
|
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);
|
2009-05-28 11:48:33 +02:00
|
|
|
s->setValue("Name", version->name());
|
|
|
|
s->setValue("Path", version->path());
|
|
|
|
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
|
|
|
#ifdef QTCREATOR_WITH_S60
|
|
|
|
s->setValue("MwcDirectory", version->mwcDirectory());
|
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
s->endArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QtVersion* > QtVersionManager::versions() const
|
|
|
|
{
|
|
|
|
return m_versions;
|
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion *QtVersionManager::version(int id) const
|
|
|
|
{
|
|
|
|
int pos = m_uniqueIdToIndex.value(id, -1);
|
|
|
|
if (pos != -1)
|
|
|
|
return m_versions.at(pos);
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
if (m_defaultVersion < m_versions.count())
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_versions.at(m_defaultVersion);
|
|
|
|
else
|
|
|
|
return m_emptyVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::addNewVersionsFromInstaller()
|
|
|
|
{
|
|
|
|
// Add new versions which may have been installed by the WB installer in the form:
|
|
|
|
// NewQtVersions="qt 4.3.2=c:\\qt\\qt432;qt embedded=c:\\qtembedded;"
|
|
|
|
// or NewQtVersions="qt 4.3.2=c:\\qt\\qt432=c:\\qtcreator\\mingw\\=prependToPath;
|
|
|
|
// 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();
|
2009-02-11 19:41:01 +01:00
|
|
|
|
|
|
|
if (!settings->contains(newQtVersionsKey) &&
|
|
|
|
!settings->contains(QLatin1String("Installer/")+newQtVersionsKey))
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
// qDebug()<<"QtVersionManager::addNewVersionsFromInstaller()";
|
|
|
|
|
|
|
|
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);
|
|
|
|
bool defaultVersionWasReset = false;
|
|
|
|
foreach (QString newVersion, newVersionsList) {
|
|
|
|
QStringList newVersionData = newVersion.split('=');
|
2008-12-09 11:07:24 +01:00
|
|
|
if (newVersionData.count()>=2) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (QDir(newVersionData[1]).exists()) {
|
|
|
|
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]);
|
|
|
|
|
|
|
|
bool versionWasAlreadyInList = false;
|
|
|
|
foreach(const QtVersion * const it, m_versions) {
|
2008-12-09 11:07:24 +01:00
|
|
|
if (QDir(version->path()).canonicalPath() == QDir(it->path()).canonicalPath()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
versionWasAlreadyInList = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!versionWasAlreadyInList) {
|
|
|
|
m_versions.append(version);
|
|
|
|
} else {
|
|
|
|
// clean up
|
|
|
|
delete version;
|
|
|
|
}
|
|
|
|
if (!defaultVersionWasReset) {
|
|
|
|
m_defaultVersion = versionWasAlreadyInList? m_defaultVersion : m_versions.count() - 1;
|
|
|
|
defaultVersionWasReset = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
settings->remove(newQtVersionsKey);
|
2009-02-11 19:41:01 +01:00
|
|
|
settings->remove(QLatin1String("Installer/")+newQtVersionsKey);
|
2008-12-02 12:01:29 +01:00
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersionManager::updateSystemVersion()
|
|
|
|
{
|
|
|
|
bool haveSystemVersion = false;
|
2009-04-28 12:43:04 +02:00
|
|
|
QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(ProjectExplorer::Environment::systemEnvironment());
|
2009-04-23 16:05:51 +02:00
|
|
|
QString systemQtPath;
|
|
|
|
if (systemQMakePath.isNull()) {
|
|
|
|
systemQtPath = tr("<not found>");
|
|
|
|
} else {
|
|
|
|
QDir dir(QFileInfo(systemQMakePath).absoluteDir());
|
|
|
|
dir.cdUp();
|
|
|
|
systemQtPath = dir.absolutePath();
|
|
|
|
}
|
|
|
|
|
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-04-23 16:05:51 +02:00
|
|
|
version->setPath(systemQtPath);
|
2009-05-26 17:21:30 +02:00
|
|
|
version->setName(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-04-23 16:05:51 +02:00
|
|
|
systemQtPath,
|
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();
|
|
|
|
if (m_versions.size() > 1) // we had other versions before adding system version
|
|
|
|
++m_defaultVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion *QtVersionManager::currentQtVersion() const
|
|
|
|
{
|
2008-12-09 11:07:24 +01:00
|
|
|
if (m_defaultVersion < m_versions.count())
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_versions.at(m_defaultVersion);
|
|
|
|
else
|
|
|
|
return m_emptyVersion;
|
|
|
|
}
|
|
|
|
|
2009-04-22 18:05:55 +02:00
|
|
|
void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion)
|
|
|
|
{
|
|
|
|
bool versionPathsChanged = m_versions.size() != newVersions.size();
|
|
|
|
if (!versionPathsChanged) {
|
|
|
|
for (int i = 0; i < m_versions.size(); ++i) {
|
|
|
|
if (m_versions.at(i)->path() != newVersions.at(i)->path()) {
|
|
|
|
versionPathsChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qDeleteAll(m_versions);
|
|
|
|
m_versions.clear();
|
|
|
|
foreach(QtVersion *version, newVersions)
|
|
|
|
m_versions.append(new QtVersion(*version));
|
|
|
|
if (versionPathsChanged)
|
|
|
|
updateDocumentation();
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
|
|
|
|
bool emitDefaultChanged = false;
|
|
|
|
if (m_defaultVersion != newDefaultVersion) {
|
|
|
|
m_defaultVersion = newDefaultVersion;
|
|
|
|
emitDefaultChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
emit qtVersionsChanged();
|
2009-05-28 18:15:02 +02:00
|
|
|
if (emitDefaultChanged) {
|
2009-04-22 18:05:55 +02:00
|
|
|
emit defaultQtVersionChanged();
|
2009-05-28 18:15:02 +02:00
|
|
|
}
|
2009-04-22 18:05:55 +02:00
|
|
|
|
2009-07-20 14:24:41 +02:00
|
|
|
updateExamples();
|
2009-04-22 18:05:55 +02:00
|
|
|
writeVersionsIntoSettings();
|
|
|
|
}
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// QtVersion
|
|
|
|
///
|
|
|
|
|
2009-05-28 11:48:33 +02:00
|
|
|
QtVersion::QtVersion(const QString &name, const QString &path, int id,
|
|
|
|
bool isAutodetected, const QString &autodetectionSource)
|
2009-03-25 15:18:37 +01:00
|
|
|
: m_name(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-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-05-18 14:57:33 +02:00
|
|
|
setPath(path);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-05-28 13:22:23 +02:00
|
|
|
QtVersion::QtVersion(const QString &name, const QString &path,
|
|
|
|
bool isAutodetected, const QString &autodetectionSource)
|
2008-12-02 12:01:29 +01:00
|
|
|
: m_name(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),
|
|
|
|
m_mkspecUpToDate(false),
|
2009-06-22 14:00:04 +02:00
|
|
|
m_versionInfoUpToDate(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
m_id = getUniqueId();
|
2009-05-18 14:57:33 +02:00
|
|
|
setPath(path);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
QtVersion::~QtVersion()
|
|
|
|
{
|
2009-06-05 11:16:09 +02:00
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString QtVersion::name() const
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::path() const
|
|
|
|
{
|
|
|
|
return m_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::sourcePath() const
|
|
|
|
{
|
|
|
|
return m_sourcePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::mkspec() const
|
|
|
|
{
|
|
|
|
updateMkSpec();
|
|
|
|
return m_mkspec;
|
|
|
|
}
|
|
|
|
|
2008-12-08 12:44:28 +01:00
|
|
|
QString QtVersion::mkspecPath() const
|
|
|
|
{
|
|
|
|
updateMkSpec();
|
|
|
|
return m_mkspecFullPath;
|
|
|
|
}
|
|
|
|
|
2008-12-08 14:20:35 +01:00
|
|
|
QString QtVersion::qtVersionString() const
|
|
|
|
{
|
|
|
|
qmakeCommand();
|
|
|
|
return m_qtVersionString;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QHash<QString,QString> QtVersion::versionInfo() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
return m_versionInfo;
|
|
|
|
}
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
QString QtVersion::qmakeCXX() const
|
|
|
|
{
|
|
|
|
updateQMakeCXX();
|
|
|
|
return m_qmakeCXX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void QtVersion::setName(const QString &name)
|
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setPath(const QString &path)
|
|
|
|
{
|
|
|
|
m_path = QDir::cleanPath(path);
|
|
|
|
updateSourcePath();
|
|
|
|
m_versionInfoUpToDate = false;
|
|
|
|
m_mkspecUpToDate = false;
|
2009-05-19 14:54:52 +02:00
|
|
|
m_designerCommand = m_linguistCommand = m_qmakeCommand = m_uicCommand = QString::null;
|
|
|
|
// TODO do i need to optimize this?
|
2009-04-24 14:59:47 +02:00
|
|
|
m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
|
2009-05-25 16:43:50 +02:00
|
|
|
m_qmakeCXX = QString::null;
|
|
|
|
m_qmakeCXXUpToDate = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::updateSourcePath()
|
|
|
|
{
|
|
|
|
m_sourcePath = m_path;
|
|
|
|
QFile qmakeCache(m_path + QLatin1String("/.qmake.cache"));
|
|
|
|
if (qmakeCache.exists()) {
|
|
|
|
qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
QTextStream stream(&qmakeCache);
|
|
|
|
while (!stream.atEnd()) {
|
|
|
|
QString line = stream.readLine().trimmed();
|
|
|
|
if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) {
|
|
|
|
m_sourcePath = line.split(QLatin1Char('=')).at(1).trimmed();
|
|
|
|
if (m_sourcePath.startsWith(QLatin1String("$$quote("))) {
|
|
|
|
m_sourcePath.remove(0, 8);
|
|
|
|
m_sourcePath.chop(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-06 18:49:10 +02:00
|
|
|
m_sourcePath = QDir::cleanPath(m_sourcePath);
|
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
|
|
|
|
// To find out wheter we already have a qtversion for that directory call
|
|
|
|
// QtVersion *QtVersionManager::qtVersionForDirectory(const QString directory);
|
|
|
|
QString QtVersionManager::findQtVersionFromMakefile(const QString &directory)
|
|
|
|
{
|
|
|
|
bool debugAdding = false;
|
|
|
|
QFile makefile(directory + "/Makefile" );
|
|
|
|
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream ts(&makefile);
|
|
|
|
while (!ts.atEnd()) {
|
|
|
|
QString line = ts.readLine();
|
|
|
|
QRegExp r1("QMAKE\\s*=(.*)");
|
|
|
|
if (r1.exactMatch(line)) {
|
|
|
|
if (debugAdding)
|
|
|
|
qDebug()<<"#~~ QMAKE is:"<<r1.cap(1).trimmed();
|
|
|
|
QFileInfo qmake(r1.cap(1).trimmed());
|
|
|
|
QFileInfo binDir(qmake.absolutePath());
|
|
|
|
QString qtDir = binDir.absolutePath();
|
|
|
|
if (debugAdding)
|
|
|
|
qDebug() << "#~~ QtDir:"<<qtDir;
|
|
|
|
return qtDir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
makefile.close();
|
|
|
|
}
|
2009-04-23 14:23:30 +02:00
|
|
|
return QString::null;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion *QtVersionManager::qtVersionForDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
foreach(QtVersion *v, versions()) {
|
|
|
|
if (v->path() == directory) {
|
|
|
|
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
|
|
|
{
|
2009-07-22 16:52:44 +02:00
|
|
|
foreach(QMakeAssignment qa, list) {
|
|
|
|
qDebug()<<qa.variable<<qa.op<<qa.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// New code
|
|
|
|
QPair<QtVersion::QmakeBuildConfig, QStringList> QtVersionManager::scanMakeFile(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig)
|
|
|
|
{
|
|
|
|
qDebug()<<"ScanMakeFile, the gory details:";
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersion::QmakeBuildConfig result = QtVersion::NoBuild;
|
2009-07-22 16:52:44 +02:00
|
|
|
QStringList result2;
|
|
|
|
|
|
|
|
QString line = findQMakeLine(directory);
|
|
|
|
if (!line.isEmpty()) {
|
|
|
|
qDebug()<<"Found line"<<line;
|
|
|
|
line = trimLine(line);
|
|
|
|
qDebug()<<"Trimmed to"<<line;
|
|
|
|
QStringList parts = splitLine(line);
|
|
|
|
qDebug()<<"Splitted into"<<parts;
|
|
|
|
QList<QMakeAssignment> assignments;
|
|
|
|
QList<QMakeAssignment> afterAssignments;
|
|
|
|
QStringList additionalArguments;
|
|
|
|
parseParts(parts, &assignments, &afterAssignments, &additionalArguments);
|
|
|
|
|
|
|
|
dumpQMakeAssignments(assignments);
|
2009-07-29 12:46:11 +02:00
|
|
|
if (!afterAssignments.isEmpty())
|
|
|
|
qDebug()<<"-after";
|
2009-07-22 16:52:44 +02:00
|
|
|
dumpQMakeAssignments(afterAssignments);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
foreach(QMakeAssignment qa, assignments)
|
|
|
|
result2.append(qa.variable + qa.op + qa.value);
|
|
|
|
if (!afterAssignments.isEmpty()) {
|
|
|
|
result2.append("-after");
|
|
|
|
foreach(QMakeAssignment qa, afterAssignments)
|
|
|
|
result2.append(qa.variable + qa.op + qa.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dump the gathered information:
|
|
|
|
qDebug()<<"\n\nDumping information from scanMakeFile";
|
|
|
|
qDebug()<<"QMake CONFIG variable parsing";
|
|
|
|
qDebug()<<" "<< (result & QtVersion::NoBuild ? "No Build" : QString::number(int(result)));
|
|
|
|
qDebug()<<" "<< (result & QtVersion::DebugBuild ? "debug" : "release");
|
|
|
|
qDebug()<<" "<< (result & QtVersion::BuildAll ? "debug_and_release" : "no debug_and_release");
|
|
|
|
qDebug()<<"\nAddtional Arguments";
|
|
|
|
qDebug()<<result2;
|
|
|
|
qDebug()<<"\n\n";
|
|
|
|
return qMakePair(result, result2);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersionManager::findQMakeLine(const QString &directory)
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
QFile makefile(directory + "/Makefile" );
|
|
|
|
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream ts(&makefile);
|
|
|
|
while (!ts.atEnd()) {
|
|
|
|
QString line = ts.readLine();
|
2009-07-22 16:52:44 +02:00
|
|
|
if (line.startsWith("# Command:"))
|
|
|
|
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
|
|
|
|
int firstSpace = line.indexOf(" ", 11);
|
|
|
|
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)) {
|
|
|
|
qDebug()<<regExp.cap(1)<<"|"<<regExp.cap(2)<<"|"<<regExp.cap(3);
|
|
|
|
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 {
|
|
|
|
qDebug()<<"Not parsed"<<part;
|
|
|
|
additionalArguments->append(part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
additionalArguments->removeAll("-win32");
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
additionalArguments->removeAll("-macx");
|
|
|
|
#elif defined(Q_OS_QNX6)
|
|
|
|
additionalArguments->removeAll("-qnx6");
|
|
|
|
#else
|
|
|
|
additionalArguments->removeAll("-unix");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// This function extracts all the CONFIG+=debug, CONFIG+=release
|
|
|
|
QtVersion::QmakeBuildConfig QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfig defaultBuildConfig)
|
|
|
|
{
|
|
|
|
QtVersion::QmakeBuildConfig result = defaultBuildConfig;
|
|
|
|
QList<QMakeAssignment> oldAssignments = *assignments;
|
|
|
|
assignments->clear();
|
|
|
|
foreach(QMakeAssignment qa, oldAssignments) {
|
|
|
|
if (qa.variable == "CONFIG") {
|
|
|
|
QStringList values = qa.value.split(' ');
|
|
|
|
QStringList newValues;
|
|
|
|
foreach(const QString &value, values) {
|
|
|
|
if (value == "debug") {
|
|
|
|
if (qa.op == "+=")
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
|
|
|
|
} else if (value == "release") {
|
|
|
|
if (qa.op == "+=")
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
|
|
|
|
} else if (value == "debug_and_release") {
|
|
|
|
if (qa.op == "+=")
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::BuildAll);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::BuildAll);
|
|
|
|
} 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;
|
|
|
|
// 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;
|
2008-12-02 12:01:29 +01:00
|
|
|
QFileInfo qmake(qmakeCommand());
|
|
|
|
if (qmake.exists()) {
|
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()) {
|
|
|
|
QString line = stream.readLine();
|
|
|
|
int index = line.indexOf(":");
|
|
|
|
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
|
|
|
|
|
|
|
// Parse qconfigpri
|
|
|
|
QString baseDir = m_versionInfo.contains("QT_INSTALL_DATA") ?
|
|
|
|
m_versionInfo.value("QT_INSTALL_DATA") :
|
|
|
|
m_path;
|
|
|
|
QFile qconfigpri(baseDir + QLatin1String("/mkspecs/qconfig.pri"));
|
|
|
|
if (qconfigpri.exists()) {
|
|
|
|
qconfigpri.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
|
|
QTextStream stream(&qconfigpri);
|
|
|
|
while (!stream.atEnd()) {
|
|
|
|
QString line = stream.readLine().trimmed();
|
|
|
|
if (line.startsWith(QLatin1String("CONFIG"))) {
|
|
|
|
m_defaultConfigIsDebugAndRelease = false;
|
|
|
|
QStringList values = line.split(QLatin1Char('=')).at(1).trimmed().split(" ");
|
|
|
|
foreach(const QString &value, values) {
|
|
|
|
if (value == "debug")
|
|
|
|
m_defaultConfigIsDebug = true;
|
2008-12-09 11:07:24 +01:00
|
|
|
else if (value == "release")
|
2008-12-02 12:01:29 +01:00
|
|
|
m_defaultConfigIsDebug = false;
|
2008-12-09 11:07:24 +01:00
|
|
|
else if (value == "build_all")
|
2008-12-02 12:01:29 +01:00
|
|
|
m_defaultConfigIsDebugAndRelease = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_versionInfoUpToDate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QtVersion::isInstalled() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
return !m_notInstalled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::updateMkSpec() const
|
|
|
|
{
|
|
|
|
if (m_mkspecUpToDate)
|
|
|
|
return;
|
|
|
|
//qDebug()<<"Finding mkspec for"<<path();
|
|
|
|
|
|
|
|
QString mkspec;
|
2009-04-24 16:09:22 +02:00
|
|
|
// no .qmake.cache so look at the default mkspec
|
|
|
|
QString mkspecPath = versionInfo().value("QMAKE_MKSPECS");
|
|
|
|
if (mkspecPath.isEmpty())
|
|
|
|
mkspecPath = path() + "/mkspecs/default";
|
|
|
|
else
|
|
|
|
mkspecPath = mkspecPath + "/default";
|
2008-12-02 12:01:29 +01:00
|
|
|
// qDebug() << "default mkspec is located at" << mkspecPath;
|
|
|
|
#ifdef Q_OS_WIN
|
2009-04-24 16:09:22 +02:00
|
|
|
QFile f2(mkspecPath + "/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) {
|
|
|
|
mkspec = temp.at(1).trimmed();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-04-24 16:09:22 +02:00
|
|
|
break;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
2009-04-24 16:09:22 +02:00
|
|
|
f2.close();
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
#elif defined(Q_OS_MAC)
|
2009-04-24 16:09:22 +02:00
|
|
|
QFile f2(mkspecPath + "/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++";
|
|
|
|
mkspec = "macx-g++";
|
|
|
|
} else {
|
|
|
|
//resolve mkspec link
|
|
|
|
QFileInfo f3(mkspecPath);
|
|
|
|
if (f3.isSymLink()) {
|
|
|
|
mkspec = f3.symLinkTarget();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-24 16:09:22 +02:00
|
|
|
break;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
2009-04-24 16:09:22 +02:00
|
|
|
f2.close();
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
#else
|
2009-04-24 16:09:22 +02:00
|
|
|
QFileInfo f2(mkspecPath);
|
|
|
|
if (f2.isSymLink()) {
|
|
|
|
mkspec = f2.symLinkTarget();
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
2008-12-08 12:44:28 +01:00
|
|
|
m_mkspecFullPath = mkspec;
|
|
|
|
int index = mkspec.lastIndexOf('/');
|
2008-12-09 11:07:24 +01:00
|
|
|
if (index == -1)
|
2008-12-02 12:01:29 +01:00
|
|
|
index = mkspec.lastIndexOf('\\');
|
2008-12-05 12:55:31 +01:00
|
|
|
QString mkspecDir = QDir(m_path + "/mkspecs/").canonicalPath();
|
|
|
|
if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == mkspecDir)
|
2008-12-02 12:01:29 +01:00
|
|
|
mkspec = mkspec.mid(index+1).trimmed();
|
|
|
|
|
|
|
|
m_mkspec = mkspec;
|
|
|
|
m_mkspecUpToDate = true;
|
|
|
|
// qDebug()<<"mkspec for "<<m_path<<" is "<<mkspec;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::qmakeCommand() const
|
|
|
|
{
|
|
|
|
// We can't use versionInfo QT_INSTALL_BINS here
|
|
|
|
// because that functions calls us to find out the values for versionInfo
|
|
|
|
if (!m_qmakeCommand.isNull())
|
|
|
|
return m_qmakeCommand;
|
|
|
|
|
2009-05-19 14:54:52 +02:00
|
|
|
QDir qtDir = path() + QLatin1String("/bin/");
|
2009-04-24 16:21:51 +02:00
|
|
|
foreach (const QString &possibleCommand, DebuggingHelperLibrary::possibleQMakeCommands()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QString s = qtDir.absoluteFilePath(possibleCommand);
|
|
|
|
QFileInfo qmake(s);
|
|
|
|
if (qmake.exists() && qmake.isExecutable()) {
|
2009-04-24 16:21:51 +02:00
|
|
|
QString qtVersion = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath());
|
2008-12-08 14:20:35 +01:00
|
|
|
if (!qtVersion.isNull()) {
|
|
|
|
m_qtVersionString = qtVersion;
|
2008-12-02 12:01:29 +01:00
|
|
|
m_qmakeCommand = qmake.absoluteFilePath();
|
|
|
|
return qmake.absoluteFilePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString::null;
|
|
|
|
}
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
void QtVersion::updateQMakeCXX() const
|
|
|
|
{
|
|
|
|
if (m_qmakeCXXUpToDate)
|
|
|
|
return;
|
|
|
|
ProFileReader *reader = new ProFileReader();
|
|
|
|
reader->setCumulative(false);
|
|
|
|
reader->setParsePreAndPostFiles(false);
|
|
|
|
reader->readProFile(mkspecPath() + "/qmake.conf");
|
|
|
|
m_qmakeCXX = reader->value("QMAKE_CXX");
|
2009-05-26 14:02:16 +02:00
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
delete reader;
|
|
|
|
m_qmakeCXXUpToDate = true;
|
|
|
|
}
|
|
|
|
|
2009-06-22 14:00:04 +02:00
|
|
|
ProjectExplorer::ToolChain *QtVersion::createToolChain(ProjectExplorer::ToolChain::ToolChainType type) const
|
2009-05-25 16:43:50 +02:00
|
|
|
{
|
2009-06-22 14:00:04 +02:00
|
|
|
ProjectExplorer::ToolChain *tempToolchain = 0;
|
2009-06-09 18:02:23 +02:00
|
|
|
if (type == ProjectExplorer::ToolChain::MinGW) {
|
2009-05-25 16:43:50 +02:00
|
|
|
QString qmake_cxx = qmakeCXX();
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
//addToEnvironment(env);
|
|
|
|
env.prependOrSetPath(mingwDirectory()+"/bin");
|
|
|
|
qmake_cxx = env.searchInPath(qmake_cxx);
|
2009-06-09 18:02:23 +02:00
|
|
|
tempToolchain = ProjectExplorer::ToolChain::createMinGWToolChain(qmake_cxx, mingwDirectory());
|
2009-05-25 16:43:50 +02:00
|
|
|
//qDebug()<<"Mingw ToolChain";
|
2009-06-09 18:02:23 +02:00
|
|
|
} else if(type == ProjectExplorer::ToolChain::MSVC) {
|
2009-07-14 15:28:07 +02:00
|
|
|
tempToolchain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion(), isQt64Bit());
|
2009-05-25 16:43:50 +02:00
|
|
|
//qDebug()<<"MSVC ToolChain ("<<version->msvcVersion()<<")";
|
2009-06-09 18:02:23 +02:00
|
|
|
} else if(type == ProjectExplorer::ToolChain::WINCE) {
|
|
|
|
tempToolchain = ProjectExplorer::ToolChain::createWinCEToolChain(msvcVersion(), wincePlatform());
|
2009-05-25 16:43:50 +02:00
|
|
|
//qDebug()<<"WinCE ToolChain ("<<version->msvcVersion()<<","<<version->wincePlatform()<<")";
|
2009-06-09 18:02:23 +02:00
|
|
|
} else if(type == ProjectExplorer::ToolChain::GCC || type == ProjectExplorer::ToolChain::LinuxICC) {
|
2009-05-25 16:43:50 +02:00
|
|
|
QString qmake_cxx = qmakeCXX();
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
//addToEnvironment(env);
|
|
|
|
qmake_cxx = env.searchInPath(qmake_cxx);
|
|
|
|
if (qmake_cxx.isEmpty()) {
|
|
|
|
// macx-xcode mkspec resets the value of QMAKE_CXX.
|
|
|
|
// Unfortunately, we need a valid QMAKE_CXX to configure the parser.
|
|
|
|
qmake_cxx = QLatin1String("cc");
|
|
|
|
}
|
2009-06-09 18:02:23 +02:00
|
|
|
tempToolchain = ProjectExplorer::ToolChain::createGccToolChain(qmake_cxx);
|
2009-05-25 16:43:50 +02:00
|
|
|
//qDebug()<<"GCC ToolChain ("<<qmake_cxx<<")";
|
2009-05-28 18:36:52 +02:00
|
|
|
#ifdef QTCREATOR_WITH_S60
|
2009-06-09 18:02:23 +02:00
|
|
|
} else if (type == ProjectExplorer::ToolChain::WINSCW) {
|
|
|
|
tempToolchain = S60Manager::instance()->createWINSCWToolChain(this);
|
|
|
|
} else if (type == ProjectExplorer::ToolChain::GCCE) {
|
|
|
|
tempToolchain = S60Manager::instance()->createGCCEToolChain(this);
|
2009-08-05 17:06:52 +02:00
|
|
|
} else if (type == ProjectExplorer::ToolChain::RVCT_ARMV5
|
|
|
|
|| type == ProjectExplorer::ToolChain::RVCT_ARMV6) {
|
|
|
|
tempToolchain = S60Manager::instance()->createRVCTToolChain(this, type);
|
2009-05-28 18:36:52 +02:00
|
|
|
#endif
|
2009-05-25 16:43:50 +02:00
|
|
|
} else {
|
2009-06-09 18:02:23 +02:00
|
|
|
qDebug()<<"Could not create ToolChain for"<<mkspec();
|
2009-05-25 16:43:50 +02:00
|
|
|
qDebug()<<"Qt Creator doesn't know about the system includes, nor the systems defines.";
|
|
|
|
}
|
2009-06-22 14:00:04 +02:00
|
|
|
return tempToolchain;
|
2009-05-25 16:43:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
return QString::null;
|
|
|
|
}
|
|
|
|
|
2009-05-12 14:12:20 +02:00
|
|
|
QString QtVersion::uicCommand() const
|
|
|
|
{
|
|
|
|
if (!isValid())
|
|
|
|
return QString::null;
|
|
|
|
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())
|
|
|
|
return QString::null;
|
|
|
|
if (m_designerCommand.isNull())
|
|
|
|
m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer")));
|
|
|
|
return m_designerCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::linguistCommand() const
|
|
|
|
{
|
|
|
|
if (!isValid())
|
|
|
|
return QString::null;
|
|
|
|
if (m_linguistCommand.isNull())
|
|
|
|
m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist")));
|
|
|
|
return m_linguistCommand;
|
2009-05-12 14:12:20 +02:00
|
|
|
}
|
|
|
|
|
2009-06-09 18:02:23 +02:00
|
|
|
QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-06-09 18:02:23 +02:00
|
|
|
QList<ProjectExplorer::ToolChain::ToolChainType> toolChains;
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!isValid())
|
2009-06-09 18:02:23 +02:00
|
|
|
return toolChains << ProjectExplorer::ToolChain::INVALID;
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString &spec = mkspec();
|
2008-12-09 11:07:24 +01:00
|
|
|
if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::MSVC;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("win32-g++"))
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::MinGW;
|
2008-12-09 11:07:24 +01:00
|
|
|
else if (spec == QString::null)
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::INVALID;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("wince"))
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::WINCE;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("linux-icc"))
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::LinuxICC;
|
|
|
|
#ifdef QTCREATOR_WITH_S60
|
|
|
|
else if (spec.contains("symbian-abld"))
|
2009-08-05 17:06:52 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::GCCE
|
|
|
|
<< ProjectExplorer::ToolChain::RVCT_ARMV5
|
|
|
|
<< ProjectExplorer::ToolChain::RVCT_ARMV6
|
|
|
|
<< ProjectExplorer::ToolChain::WINSCW;
|
2009-06-09 18:02:23 +02:00
|
|
|
#endif
|
2008-12-02 12:01:29 +01:00
|
|
|
else
|
2009-06-09 18:02:23 +02:00
|
|
|
toolChains << ProjectExplorer::ToolChain::GCC;
|
|
|
|
return toolChains;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain::ToolChainType QtVersion::defaultToolchainType() const
|
|
|
|
{
|
|
|
|
return possibleToolChainTypes().at(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-06-04 10:50:44 +02:00
|
|
|
#ifdef QTCREATOR_WITH_S60
|
|
|
|
QString QtVersion::mwcDirectory() const
|
|
|
|
{
|
|
|
|
return m_mwcDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setMwcDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_mwcDirectory = directory;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString QtVersion::mingwDirectory() const
|
|
|
|
{
|
|
|
|
return m_mingwDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::setMingwDirectory(const QString &directory)
|
|
|
|
{
|
|
|
|
m_mingwDirectory = directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::msvcVersion() const
|
|
|
|
{
|
|
|
|
return m_msvcVersion;
|
|
|
|
}
|
|
|
|
|
2009-02-10 15:34:25 +01:00
|
|
|
QString QtVersion::wincePlatform() const
|
|
|
|
{
|
2009-02-12 16:09:23 +01:00
|
|
|
// qDebug()<<"QtVersion::wincePlatform returning"<<ProjectExplorer::CeSdkHandler::platformName(mkspecPath() + "/qmake.conf");
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::CeSdkHandler::platformName(mkspecPath() + "/qmake.conf");
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void QtVersion::setMsvcVersion(const QString &version)
|
|
|
|
{
|
|
|
|
m_msvcVersion = version;
|
|
|
|
}
|
|
|
|
|
2009-05-25 16:43:50 +02:00
|
|
|
void QtVersion::addToEnvironment(ProjectExplorer::Environment &env) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-02-10 15:34:25 +01:00
|
|
|
env.set("QTDIR", m_path);
|
2008-12-02 12:01:29 +01:00
|
|
|
QString qtdirbin = versionInfo().value("QT_INSTALL_BINS");
|
2009-02-10 15:34:25 +01:00
|
|
|
env.prependOrSetPath(qtdirbin);
|
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
|
|
|
|
{
|
|
|
|
return (!(m_id == -1 || m_path == QString::null || m_name == QString::null || mkspec() == QString::null) && !m_notInstalled);
|
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const
|
|
|
|
{
|
|
|
|
updateVersionInfo();
|
|
|
|
QtVersion::QmakeBuildConfig result = QtVersion::QmakeBuildConfig(0);
|
|
|
|
if (m_defaultConfigIsDebugAndRelease)
|
|
|
|
result = QtVersion::BuildAll;
|
|
|
|
if (m_defaultConfigIsDebug)
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
|
|
|
|
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())
|
|
|
|
qtInstallData = path();
|
2009-04-24 16:21:51 +02:00
|
|
|
return DebuggingHelperLibrary::debuggingHelperLibrary(qtInstallData, path());
|
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())
|
|
|
|
qtInstallData = path();
|
|
|
|
return DebuggingHelperLibrary::debuggingHelperLibraryLocations(qtInstallData, path());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
# 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())
|
|
|
|
qtInstallData = path();
|
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-06-22 14:00:04 +02:00
|
|
|
ProjectExplorer::ToolChain *tc = createToolChain(defaultToolchainType());
|
2009-06-10 15:54:56 +02:00
|
|
|
tc->addToEnvironment(env);
|
2009-08-07 15:20:05 +02:00
|
|
|
QString output;
|
|
|
|
QString directory = DebuggingHelperLibrary::copyDebuggingHelperLibrary(qtInstallData, path(), &output);
|
|
|
|
if (!directory.isEmpty())
|
|
|
|
output += DebuggingHelperLibrary::buildDebuggingHelperLibrary(directory, tc->makeCommand(), qmakeCommand(), mkspec(), env);
|
2009-04-24 14:59:47 +02:00
|
|
|
m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty();
|
2009-06-22 14:00:04 +02:00
|
|
|
delete tc;
|
2009-04-24 14:59:47 +02:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|