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
|
|
|
**
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
**
|
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
|
|
|
|
** contact the sales department at qt-sales@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
|
|
|
|
2009-04-22 14:52:35 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2009-04-22 16:51:38 +02:00
|
|
|
#include "cesdkhandler.h"
|
|
|
|
|
|
|
|
#include "projectexplorer.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.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
|
|
|
|
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-03-25 15:18:37 +01:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QDesktopServices>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-22 14:52:35 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
using namespace ProjectExplorer::Internal;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
static const char *QtVersionsSectionName = "QtVersions";
|
|
|
|
static const char *defaultQtVersionKey = "DefaultQtVersion";
|
|
|
|
static const char *newQtVersionsKey = "NewQtVersions";
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QtVersionManager::QtVersionManager()
|
|
|
|
: m_emptyVersion(new QtVersion)
|
|
|
|
{
|
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;
|
|
|
|
QtVersion *version = new QtVersion(s->value("Name").toString(),
|
|
|
|
s->value("Path").toString(),
|
|
|
|
id,
|
|
|
|
s->value("IsSystemVersion", false).toBool());
|
|
|
|
version->setMingwDirectory(s->value("MingwDirectory").toString());
|
|
|
|
version->setMsvcVersion(s->value("msvcVersion").toString());
|
|
|
|
m_versions.append(version);
|
|
|
|
}
|
|
|
|
s->endArray();
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
|
|
|
|
++m_idcount;
|
|
|
|
addNewVersionsFromInstaller();
|
|
|
|
updateSystemVersion();
|
|
|
|
|
|
|
|
writeVersionsIntoSettings();
|
|
|
|
updateDocumentation();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
return ProjectExplorerPlugin::instance()->qtVersionManager();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
QString docPath = version->versionInfo().value("QT_INSTALL_DOCS");
|
|
|
|
foreach (const QString &fileEnding, fileEndings)
|
|
|
|
files << docPath+fileEnding;
|
|
|
|
}
|
|
|
|
helpManager->registerDocumentation(files);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
s->setArrayIndex(i);
|
|
|
|
s->setValue("Name", m_versions.at(i)->name());
|
|
|
|
s->setValue("Path", m_versions.at(i)->path());
|
|
|
|
s->setValue("Id", m_versions.at(i)->uniqueId());
|
|
|
|
s->setValue("MingwDirectory", m_versions.at(i)->mingwDirectory());
|
|
|
|
s->setValue("msvcVersion", m_versions.at(i)->msvcVersion());
|
|
|
|
s->setValue("IsSystemVersion", m_versions.at(i)->isSystemVersion());
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
foreach (QtVersion *version, m_versions) {
|
|
|
|
if (version->isSystemVersion()) {
|
|
|
|
version->setPath(findSystemQt());
|
2009-02-17 13:01:09 +01:00
|
|
|
version->setName(tr("Auto-detected Qt"));
|
2008-12-02 12:01:29 +01:00
|
|
|
haveSystemVersion = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (haveSystemVersion)
|
|
|
|
return;
|
2009-02-17 13:01:09 +01:00
|
|
|
QtVersion *version = new QtVersion(tr("Auto-detected Qt"),
|
2008-12-02 12:01:29 +01:00
|
|
|
findSystemQt(),
|
|
|
|
getUniqueId(),
|
|
|
|
true);
|
|
|
|
m_versions.prepend(version);
|
|
|
|
updateUniqueIdToIndexMap();
|
|
|
|
if (m_versions.size() > 1) // we had other versions before adding system version
|
|
|
|
++m_defaultVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QtVersionManager::possibleQMakeCommands()
|
|
|
|
{
|
|
|
|
// On windows noone has renamed qmake, right?
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
return QStringList() << "qmake.exe";
|
|
|
|
#endif
|
|
|
|
// On unix some distributions renamed qmake to avoid clashes
|
|
|
|
QStringList result;
|
|
|
|
result << "qmake-qt4" << "qmake4" << "qmake";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-12-08 14:20:35 +01:00
|
|
|
QString QtVersionManager::qtVersionForQMake(const QString &qmakePath)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
QProcess qmake;
|
|
|
|
qmake.start(qmakePath, QStringList()<<"--version");
|
|
|
|
if (!qmake.waitForFinished())
|
|
|
|
return false;
|
|
|
|
QString output = qmake.readAllStandardOutput();
|
|
|
|
QRegExp regexp("(QMake version|Qmake version:)[\\s]*([\\d.]*)");
|
|
|
|
regexp.indexIn(output);
|
2008-12-08 14:20:35 +01:00
|
|
|
if (regexp.cap(2).startsWith("2.")) {
|
|
|
|
QRegExp regexp2("Using Qt version[\\s]*([\\d\\.]*)");
|
|
|
|
regexp2.indexIn(output);
|
|
|
|
return regexp2.cap(1);
|
|
|
|
}
|
|
|
|
return QString();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersionManager::findSystemQt() const
|
|
|
|
{
|
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
QStringList paths = env.path();
|
|
|
|
foreach (const QString &path, paths) {
|
|
|
|
foreach (const QString &possibleCommand, possibleQMakeCommands()) {
|
|
|
|
QFileInfo qmake(path + "/" + possibleCommand);
|
|
|
|
if (qmake.exists()) {
|
2008-12-08 14:20:35 +01:00
|
|
|
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QDir dir(qmake.absoluteDir());
|
|
|
|
dir.cdUp();
|
|
|
|
return dir.absolutePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tr("<not found>");
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
if (emitDefaultChanged)
|
|
|
|
emit defaultQtVersionChanged();
|
|
|
|
|
|
|
|
writeVersionsIntoSettings();
|
|
|
|
}
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// QtVersion
|
|
|
|
///
|
|
|
|
|
|
|
|
QtVersion::QtVersion(const QString &name, const QString &path, int id, bool isSystemVersion)
|
2009-03-25 15:18:37 +01:00
|
|
|
: m_name(name),
|
|
|
|
m_isSystemVersion(isSystemVersion),
|
|
|
|
m_notInstalled(false),
|
|
|
|
m_defaultConfigIsDebug(true),
|
|
|
|
m_defaultConfigIsDebugAndRelease(true),
|
|
|
|
m_hasDebuggingHelper(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
setPath(path);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion::QtVersion(const QString &name, const QString &path)
|
|
|
|
: m_name(name),
|
|
|
|
m_versionInfoUpToDate(false),
|
|
|
|
m_mkspecUpToDate(false),
|
2009-03-25 15:18:37 +01:00
|
|
|
m_isSystemVersion(false),
|
|
|
|
m_hasDebuggingHelper(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
setPath(path);
|
|
|
|
m_id = getUniqueId();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
m_qmakeCommand = QString::null;
|
2009-03-25 15:18:37 +01:00
|
|
|
// TODO do i need to optimize this?
|
|
|
|
m_hasDebuggingHelper = !dumperLibrary().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QtVersion::dumperLibrary() const
|
|
|
|
{
|
|
|
|
uint hash = qHash(path());
|
2009-04-08 15:16:02 +02:00
|
|
|
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
|
|
|
|
if (qtInstallData.isEmpty())
|
|
|
|
qtInstallData = path();
|
2009-03-25 15:18:37 +01:00
|
|
|
QStringList directories;
|
|
|
|
directories
|
2009-04-08 15:16:02 +02:00
|
|
|
<< (qtInstallData + "/qtc-debugging-helper/")
|
2009-03-25 16:36:16 +01:00
|
|
|
<< (QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash)) + "/"
|
|
|
|
<< (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash)) + "/";
|
2009-03-25 15:18:37 +01:00
|
|
|
foreach(const QString &directory, directories) {
|
|
|
|
#if defined(Q_OS_WIN)
|
2009-03-25 16:36:16 +01:00
|
|
|
QFileInfo fi(directory + "debug/gdbmacros.dll");
|
2009-03-25 15:18:37 +01:00
|
|
|
#elif defined(Q_OS_MAC)
|
2009-03-25 16:36:16 +01:00
|
|
|
QFileInfo fi(directory + "libgdbmacros.dylib");
|
2009-03-25 15:18:37 +01:00
|
|
|
#else // generic UNIX
|
2009-03-25 16:36:16 +01:00
|
|
|
QFileInfo fi(directory + "libgdbmacros.so");
|
2009-03-25 15:18:37 +01:00
|
|
|
#endif
|
|
|
|
if (fi.exists())
|
|
|
|
return fi.filePath();
|
|
|
|
}
|
|
|
|
return QString();
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
QtVersion::QmakeBuildConfig QtVersionManager::scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig)
|
|
|
|
{
|
|
|
|
bool debugScan = false;
|
|
|
|
QtVersion::QmakeBuildConfig result = QtVersion::NoBuild;
|
|
|
|
QFile makefile(directory + "/Makefile" );
|
|
|
|
if (makefile.exists() && makefile.open(QFile::ReadOnly)) {
|
|
|
|
QTextStream ts(&makefile);
|
|
|
|
while (!ts.atEnd()) {
|
|
|
|
QString line = ts.readLine();
|
|
|
|
if (line.startsWith("# Command:")) {
|
|
|
|
// if nothing is specified
|
|
|
|
result = defaultBuildConfig;
|
|
|
|
|
|
|
|
// Actually parsing that line is not trivial in the general case
|
|
|
|
// There might things like this
|
|
|
|
// # Command: /home/dteske/git/bqt-45/bin/qmake -unix CONFIG+=debug\ release CONFIG\ +=\ debug_and_release\ debug -o Makefile test.pro
|
|
|
|
// which sets debug_and_release and debug
|
|
|
|
// or something like this:
|
|
|
|
//[...] CONFIG+=debug\ release CONFIG\ +=\ debug_and_release\ debug CONFIG\ -=\ debug_and_release CONFIG\ -=\ debug -o Makefile test.pro
|
|
|
|
// which sets -build_all and release
|
|
|
|
|
|
|
|
// To parse that, we search for the first CONFIG, then look for " " which is not after a "\" or the end
|
|
|
|
// And then look at each config individually
|
|
|
|
// we then remove all "\ " with just " "
|
|
|
|
// += sets adding flags
|
|
|
|
// -= sets removing flags
|
|
|
|
// and then split the string after the =
|
|
|
|
// and go over each item separetly
|
|
|
|
// debug sets/removes the flag DebugBuild
|
|
|
|
// release removes/sets the flag DebugBuild
|
|
|
|
// debug_and_release sets/removes the flag BuildAll
|
|
|
|
int pos = line.indexOf("CONFIG");
|
|
|
|
if (pos != -1) {
|
|
|
|
// Chopped of anything that is not interesting
|
|
|
|
line = line.mid(pos);
|
|
|
|
line = line.trimmed();
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"chopping line :"<<line;
|
|
|
|
|
|
|
|
//Now chop into parts that are intresting
|
|
|
|
QStringList parts;
|
|
|
|
int lastpos = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 1; i < line.size(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (line.at(i) == QLatin1Char(' ') && line.at(i-1) != QLatin1Char('\\')) {
|
|
|
|
// found a part
|
|
|
|
parts.append(line.mid(lastpos, i-lastpos));
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"part appended:"<<line.mid(lastpos, i-lastpos);
|
|
|
|
lastpos = i + 1; // Nex one starts after the space
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parts.append(line.mid(lastpos));
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"part appended:"<<line.mid(lastpos);
|
|
|
|
|
|
|
|
foreach(const QString &part, parts) {
|
2008-12-09 11:07:24 +01:00
|
|
|
if (debugScan)
|
2008-12-02 12:01:29 +01:00
|
|
|
qDebug()<<"now interpreting part"<<part;
|
|
|
|
bool setFlags;
|
|
|
|
// Now try to understand each part for that we do a rather stupid approach, optimize it if you care
|
|
|
|
if (part.startsWith("CONFIG")) {
|
|
|
|
// Yep something interesting
|
|
|
|
if (part.indexOf("+=") != -1) {
|
|
|
|
setFlags = true;
|
|
|
|
} else if (part.indexOf("-=") != -1) {
|
|
|
|
setFlags = false;
|
|
|
|
} else {
|
|
|
|
setFlags = true;
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"This can never happen, except if we can't parse Makefiles...";
|
|
|
|
}
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"part has setFlags:"<<setFlags;
|
|
|
|
// now loop forward, looking for something that looks like debug, release or debug_and_release
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i < part.size(); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
int left = part.size() - i;
|
|
|
|
if (left >= 17 && QStringRef(&part, i, 17) == "debug_and_release") {
|
|
|
|
if (setFlags)
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::BuildAll);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::BuildAll);
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"found debug_and_release new value"<<result;
|
|
|
|
i += 17;
|
|
|
|
} else if (left >=7 && QStringRef(&part, i, 7) == "release") {
|
|
|
|
if (setFlags)
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"found release new value"<<result;
|
2008-12-09 11:07:24 +01:00
|
|
|
i += 7;
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (left >= 5 && QStringRef(&part, i, 5) == "debug") {
|
|
|
|
if (setFlags)
|
|
|
|
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
|
|
|
|
else
|
|
|
|
result = QtVersion::QmakeBuildConfig(result & ~QtVersion::DebugBuild);
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"found debug new value"<<result;
|
2008-12-09 11:07:24 +01:00
|
|
|
i += 5;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"returning: "<<result;
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"buildall = "<<bool(result & QtVersion::BuildAll);
|
|
|
|
if (debugScan)
|
|
|
|
qDebug()<<"debug ="<<bool(result & QtVersion::DebugBuild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
makefile.close();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QtVersion::updateVersionInfo() const
|
|
|
|
{
|
|
|
|
if (m_versionInfoUpToDate)
|
|
|
|
return;
|
|
|
|
// extract data from qmake executable
|
|
|
|
m_versionInfo.clear();
|
|
|
|
m_notInstalled = false;
|
|
|
|
QFileInfo qmake(qmakeCommand());
|
|
|
|
if (qmake.exists()) {
|
2009-03-22 13:47:57 +01:00
|
|
|
static const char * const variables[] = {
|
|
|
|
"QT_INSTALL_DATA",
|
|
|
|
"QT_INSTALL_LIBS",
|
|
|
|
"QT_INSTALL_HEADERS",
|
|
|
|
"QT_INSTALL_DEMOS",
|
|
|
|
"QT_INSTALL_EXAMPLES",
|
|
|
|
"QT_INSTALL_CONFIGURATION",
|
|
|
|
"QT_INSTALL_TRANSLATIONS",
|
|
|
|
"QT_INSTALL_PLUGINS",
|
|
|
|
"QT_INSTALL_BINS",
|
|
|
|
"QT_INSTALL_DOCS",
|
|
|
|
"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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
2008-12-08 12:44:28 +01:00
|
|
|
// QFile f(path() + "/.qmake.cache");
|
|
|
|
// if (f.exists() && f.open(QIODevice::ReadOnly)) {
|
2008-12-09 11:07:24 +01:00
|
|
|
// while (!f.atEnd()) {
|
2008-12-08 12:44:28 +01:00
|
|
|
// QByteArray line = f.readLine();
|
2008-12-09 11:07:24 +01:00
|
|
|
// if (line.startsWith("QMAKESPEC")) {
|
2008-12-08 12:44:28 +01:00
|
|
|
// const QList<QByteArray> &temp = line.split('=');
|
2008-12-09 11:07:24 +01:00
|
|
|
// if (temp.size() == 2) {
|
2008-12-08 12:44:28 +01:00
|
|
|
// mkspec = temp.at(1).trimmed();
|
|
|
|
// if (mkspec.startsWith("$$QT_BUILD_TREE/mkspecs/"))
|
|
|
|
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
|
|
|
|
// else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
|
|
|
|
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());
|
2008-12-08 12:47:15 +01:00
|
|
|
// mkspec = QDir::fromNativeSeparators(mkspec);
|
2008-12-08 12:44:28 +01:00
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// f.close();
|
|
|
|
// } else {
|
2008-12-02 12:01:29 +01: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";
|
|
|
|
// qDebug() << "default mkspec is located at" << mkspecPath;
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
QFile f2(mkspecPath + "/qmake.conf");
|
|
|
|
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!f2.atEnd()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QByteArray line = f2.readLine();
|
2008-12-09 11:07:24 +01:00
|
|
|
if (line.startsWith("QMAKESPEC_ORIGINAL")) {
|
2008-12-02 12:01:29 +01:00
|
|
|
const QList<QByteArray> &temp = line.split('=');
|
|
|
|
if (temp.size() == 2) {
|
2008-12-18 13:23:05 +01:00
|
|
|
mkspec = temp.at(1).trimmed();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f2.close();
|
|
|
|
}
|
|
|
|
#elif defined(Q_OS_MAC)
|
|
|
|
QFile f2(mkspecPath + "/qmake.conf");
|
|
|
|
if (f2.exists() && f2.open(QIODevice::ReadOnly)) {
|
2008-12-09 11:07:24 +01:00
|
|
|
while (!f2.atEnd()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QByteArray line = f2.readLine();
|
2008-12-09 11:07:24 +01:00
|
|
|
if (line.startsWith("MAKEFILE_GENERATOR")) {
|
2008-12-02 12:01:29 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f2.close();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
QFileInfo f2(mkspecPath);
|
|
|
|
if (f2.isSymLink()) {
|
|
|
|
mkspec = f2.symLinkTarget();
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-08 12:44:28 +01:00
|
|
|
// }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
QDir qtDir = path() + "/bin/";
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &possibleCommand, QtVersionManager::possibleQMakeCommands()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QString s = qtDir.absoluteFilePath(possibleCommand);
|
|
|
|
QFileInfo qmake(s);
|
|
|
|
if (qmake.exists() && qmake.isExecutable()) {
|
2008-12-08 14:20:35 +01:00
|
|
|
QString qtVersion = QtVersionManager::qtVersionForQMake(qmake.absoluteFilePath());
|
|
|
|
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-02-10 15:34:25 +01:00
|
|
|
ProjectExplorer::ToolChain::ToolChainType QtVersion::toolchainType() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
if (!isValid())
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::INVALID;
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString &spec = mkspec();
|
2009-02-12 16:09:23 +01:00
|
|
|
// qDebug()<<"spec="<<spec;
|
2008-12-09 11:07:24 +01:00
|
|
|
if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::MSVC;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("win32-g++"))
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::MinGW;
|
2008-12-09 11:07:24 +01:00
|
|
|
else if (spec == QString::null)
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::INVALID;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("wince"))
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::WINCE;
|
2009-02-12 16:09:23 +01:00
|
|
|
else if (spec.contains("linux-icc"))
|
2009-02-12 12:44:49 +01:00
|
|
|
return ProjectExplorer::ToolChain::LinuxICC;
|
2008-12-02 12:01:29 +01:00
|
|
|
else
|
2009-02-10 15:34:25 +01:00
|
|
|
return ProjectExplorer::ToolChain::GCC;
|
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-02-10 15:34:25 +01:00
|
|
|
void QtVersion::addToEnvironment(Environment &env)
|
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
|
|
|
// add libdir, includedir and bindir
|
|
|
|
// or add Mingw dirs
|
|
|
|
// or do nothing on other
|
|
|
|
}
|
|
|
|
|
|
|
|
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-08 11:49:24 +02:00
|
|
|
|
|
|
|
// TODO buildDebuggingHelperLibrary needs to be accessible outside of the
|
|
|
|
// qt4versionmanager
|
|
|
|
// That probably means moving qt4version management into either the projectexplorer
|
|
|
|
// (The Projectexplorer plugin probably needs some splitting up, most of the stuff
|
|
|
|
// could be in a plugin shared by qt4projectmanager, cmakemanager and debugger.)
|
2009-03-25 15:18:37 +01:00
|
|
|
QString QtVersion::buildDebuggingHelperLibrary()
|
|
|
|
{
|
|
|
|
// Locations to try:
|
|
|
|
// $QTDIR/qtc-debugging-helper
|
|
|
|
// $APPLICATION-DIR/qtc-debugging-helper/$hash
|
|
|
|
// $USERDIR/qtc-debugging-helper/$hash
|
|
|
|
|
|
|
|
QString output;
|
|
|
|
uint hash = qHash(path());
|
2009-04-08 15:16:02 +02:00
|
|
|
QString qtInstallData = versionInfo().value("QT_INSTALL_DATA");
|
|
|
|
if (qtInstallData.isEmpty())
|
|
|
|
qtInstallData = path();
|
2009-03-25 15:18:37 +01:00
|
|
|
QStringList directories;
|
|
|
|
directories
|
2009-04-08 15:16:02 +02:00
|
|
|
<< qtInstallData + "/qtc-debugging-helper/"
|
2009-03-25 16:36:16 +01:00
|
|
|
<< QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash) +"/"
|
|
|
|
<< QDesktopServices::storageLocation (QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash) +"/";
|
2009-03-25 15:18:37 +01:00
|
|
|
|
|
|
|
QStringList files;
|
|
|
|
files << "gdbmacros.cpp" << "gdbmacros.pro"
|
|
|
|
<< "LICENSE.LGPL" << "LGPL_EXCEPTION.TXT";
|
|
|
|
|
|
|
|
foreach(const QString &directory, directories) {
|
|
|
|
QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/";
|
|
|
|
bool success = true;
|
|
|
|
QDir().mkpath(directory);
|
|
|
|
foreach (const QString &file, files) {
|
|
|
|
QString source = dumperPath + file;
|
|
|
|
QString dest = directory + file;
|
|
|
|
QFileInfo destInfo(dest);
|
|
|
|
if (destInfo.exists()) {
|
|
|
|
if (destInfo.lastModified() >= QFileInfo(source).lastModified())
|
|
|
|
continue;
|
|
|
|
success &= QFile::remove(dest);
|
|
|
|
}
|
|
|
|
success &= QFile::copy(source, dest);
|
|
|
|
}
|
|
|
|
if (!success)
|
|
|
|
continue;
|
|
|
|
|
2009-04-16 17:12:19 +02:00
|
|
|
// Setup process
|
|
|
|
QProcess proc;
|
2009-03-25 15:18:37 +01:00
|
|
|
|
|
|
|
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
|
|
|
addToEnvironment(env);
|
2009-04-08 11:49:24 +02:00
|
|
|
// TODO this is a hack to get, to be removed and rewritten for 1.2
|
2009-04-16 17:12:19 +02:00
|
|
|
// For MSVC and MINGW, we need a toolchain to get the right environment
|
2009-04-08 11:49:24 +02:00
|
|
|
ProjectExplorer::ToolChain *toolChain = 0;
|
|
|
|
ProjectExplorer::ToolChain::ToolChainType t = toolchainType();
|
|
|
|
if (t == ProjectExplorer::ToolChain::MinGW)
|
|
|
|
toolChain = ProjectExplorer::ToolChain::createMinGWToolChain("g++", mingwDirectory());
|
|
|
|
else if(t == ProjectExplorer::ToolChain::MSVC)
|
|
|
|
toolChain = ProjectExplorer::ToolChain::createMSVCToolChain(msvcVersion());
|
|
|
|
if (toolChain) {
|
|
|
|
toolChain->addToEnvironment(env);
|
|
|
|
delete toolChain;
|
|
|
|
toolChain = 0;
|
|
|
|
}
|
|
|
|
|
2009-04-16 17:12:19 +02:00
|
|
|
proc.setEnvironment(env.toStringList());
|
|
|
|
proc.setWorkingDirectory(directory);
|
|
|
|
proc.setProcessChannelMode(QProcess::MergedChannels);
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2009-04-16 17:12:19 +02:00
|
|
|
output += QString("Building debugging helper library in %1\n").arg(directory);
|
|
|
|
output += "\n";
|
2009-03-25 15:18:37 +01:00
|
|
|
|
2009-04-16 17:12:19 +02:00
|
|
|
QString make;
|
2009-03-25 15:18:37 +01:00
|
|
|
// TODO this is butt ugly
|
|
|
|
// only qt4projects have a toolchain() method. (Reason mostly, that in order to create
|
|
|
|
// the toolchain, we need to have the path to gcc
|
|
|
|
// which might depend on environment settings of the project
|
|
|
|
// so we hardcode the toolchainType to make conversation here
|
|
|
|
// and think about how to fix that later
|
|
|
|
if (t == ProjectExplorer::ToolChain::MinGW)
|
|
|
|
make = "mingw32-make.exe";
|
|
|
|
else if(t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE)
|
|
|
|
make = "nmake.exe";
|
|
|
|
else if (t == ProjectExplorer::ToolChain::GCC || t == ProjectExplorer::ToolChain::LinuxICC)
|
|
|
|
make = "make";
|
|
|
|
|
|
|
|
QString makeFullPath = env.searchInPath(make);
|
2009-04-16 17:12:19 +02:00
|
|
|
if (!makeFullPath.isEmpty()) {
|
|
|
|
output += QString("Running %1 clean...\n").arg(makeFullPath);
|
|
|
|
proc.start(makeFullPath, QStringList() << "clean");
|
|
|
|
proc.waitForFinished();
|
|
|
|
output += proc.readAll();
|
|
|
|
} else {
|
|
|
|
output += QString("%1 not found in PATH\n").arg(make);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-17 21:11:52 +02:00
|
|
|
output += QString("\nRunning %1 ...\n").arg(qmakeCommand());
|
2009-04-16 17:12:19 +02:00
|
|
|
|
|
|
|
proc.start(qmakeCommand(), QStringList()<<"-spec"<< mkspec() <<"gdbmacros.pro");
|
|
|
|
proc.waitForFinished();
|
|
|
|
|
|
|
|
output += proc.readAll();
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
output += "\n";
|
|
|
|
if (!makeFullPath.isEmpty()) {
|
2009-04-01 12:25:55 +02:00
|
|
|
output += QString("Running %1 ...\n").arg(makeFullPath);
|
2009-04-16 17:12:19 +02:00
|
|
|
proc.start(makeFullPath, QStringList());
|
|
|
|
proc.waitForFinished();
|
|
|
|
output += proc.readAll();
|
2009-03-25 15:18:37 +01:00
|
|
|
} else {
|
|
|
|
output += QString("%1 not found in PATH\n").arg(make);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_hasDebuggingHelper = !dumperLibrary().isEmpty();
|
|
|
|
return output;
|
|
|
|
}
|