diff options
author | dt <qtc-committer@nokia.com> | 2011-05-04 13:14:46 +0200 |
---|---|---|
committer | dt <qtc-committer@nokia.com> | 2011-05-12 12:23:06 +0200 |
commit | 8e171e0be0239c18843fc65784cb91120b252c8f (patch) | |
tree | 06900feae14b15b3897fff193cf36dbd44bad8b3 | |
parent | 9ef4ea40f27befa4b5b553c3dfa94d979a34748c (diff) | |
download | qt-creator-8e171e0be0239c18843fc65784cb91120b252c8f.tar.gz |
Qt Version refactoring
Split up target specific code into subclasses. Also change
Qt4BuildConfiguration to allow a null qtversion.
Remove code that relied on always having a qt version.
Also make it possible to remove all qt versions.
Completly change the qt in path autodetection to be only
a fall back if no configuration was found.
Note: For now the old settings are not removed, as such 2.2 and master
can coexist.
Reviewed-By: hunger
104 files changed, 4410 insertions, 2481 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index c705d75388..2a7d2a1b99 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -211,6 +211,7 @@ void BuildConfiguration::setToolChain(ProjectExplorer::ToolChain *tc) return; m_toolChain = tc; emit toolChainChanged(); + emit environmentChanged(); } Utils::Environment BuildConfiguration::baseEnvironment() const diff --git a/src/plugins/projectexplorer/headerpath.h b/src/plugins/projectexplorer/headerpath.h index 3b0a52096a..523d359750 100644 --- a/src/plugins/projectexplorer/headerpath.h +++ b/src/plugins/projectexplorer/headerpath.h @@ -33,6 +33,8 @@ #ifndef HEADERPATH_H #define HEADERPATH_H +#include <QtCore/QString> + #include "projectexplorer_export.h" namespace ProjectExplorer { diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index e48305c327..617a0e8983 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -42,7 +42,7 @@ #include <coreplugin/messagemanager.h> #include <extensionsystem/pluginmanager.h> #include <qt4projectmanager/qmldumptool.h> -#include <qt4projectmanager/qtversionmanager.h> +#include <qt4projectmanager/baseqtversion.h> #include <qmljs/qmljsmodelmanagerinterface.h> #include <utils/fileutils.h> @@ -192,7 +192,7 @@ QStringList QmlProject::importPaths() const const QmlProjectRunConfiguration *runConfig = qobject_cast<QmlProjectRunConfiguration*>(activeTarget()->activeRunConfiguration()); if (runConfig) { - const Qt4ProjectManager::QtVersion *qtVersion = runConfig->qtVersion(); + const Qt4ProjectManager::BaseQtVersion *qtVersion = runConfig->qtVersion(); if (qtVersion && qtVersion->isValid()) { const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS"); if (!qtVersionImportPath.isEmpty()) diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index b37f9c987b..760927bb99 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -120,7 +120,7 @@ QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const QString QmlProjectRunConfiguration::viewerPath() const { - Qt4ProjectManager::QtVersion *version = qtVersion(); + Qt4ProjectManager::BaseQtVersion *version = qtVersion(); if (!version) { return QString(); } else { @@ -130,7 +130,7 @@ QString QmlProjectRunConfiguration::viewerPath() const QString QmlProjectRunConfiguration::observerPath() const { - Qt4ProjectManager::QtVersion *version = qtVersion(); + Qt4ProjectManager::BaseQtVersion *version = qtVersion(); if (!version) { return QString(); } else { @@ -193,13 +193,13 @@ QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName) } -Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const +Qt4ProjectManager::BaseQtVersion *QmlProjectRunConfiguration::qtVersion() const { if (m_qtVersionId == -1) return 0; QtVersionManager *versionManager = QtVersionManager::instance(); - Qt4ProjectManager::QtVersion *version = versionManager->version(m_qtVersionId); + Qt4ProjectManager::BaseQtVersion *version = versionManager->version(m_qtVersionId); QTC_ASSERT(version, return 0); return version; @@ -381,7 +381,7 @@ void QmlProjectRunConfiguration::updateQtVersions() || !isValidVersion(qtVersions->version(m_qtVersionId))) { int newVersionId = -1; // take first one you find - foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) { + foreach (Qt4ProjectManager::BaseQtVersion *version, qtVersions->validVersions()) { if (isValidVersion(version)) { newVersionId = version->uniqueId(); break; @@ -393,7 +393,7 @@ void QmlProjectRunConfiguration::updateQtVersions() updateEnabled(); } -bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *version) +bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::BaseQtVersion *version) { if (version && (version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID) diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h index f228117695..66058bda53 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h @@ -51,7 +51,7 @@ namespace Utils { } namespace Qt4ProjectManager { - class QtVersion; + class BaseQtVersion; } namespace QmlProjectManager { @@ -82,7 +82,7 @@ public: QString viewerArguments() const; QString workingDirectory() const; int qtVersionId() const; - Qt4ProjectManager::QtVersion *qtVersion() const; + Qt4ProjectManager::BaseQtVersion *qtVersion() const; enum MainScriptSource { FileInEditor, @@ -119,7 +119,7 @@ protected: private: void ctor(); - static bool isValidVersion(Qt4ProjectManager::QtVersion *version); + static bool isValidVersion(Qt4ProjectManager::BaseQtVersion *version); void setQtVersionId(int id); static QString canonicalCapsPath(const QString &filePath); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp index 85cfaa9b9d..4a7097c906 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationwidget.cpp @@ -295,7 +295,7 @@ void QmlProjectRunConfigurationWidget::updateQtVersionComboBox() m_qtVersionComboBox->clear(); QtVersionManager *qtVersions = QtVersionManager::instance(); - foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) { + foreach (Qt4ProjectManager::BaseQtVersion *version, qtVersions->validVersions()) { if (m_runConfiguration->isValidVersion(version)) { m_qtVersionComboBox->addItem(version->displayName(), version->uniqueId()); } diff --git a/src/plugins/qt4projectmanager/baseqtversion.cpp b/src/plugins/qt4projectmanager/baseqtversion.cpp new file mode 100644 index 0000000000..98bffa5e8b --- /dev/null +++ b/src/plugins/qt4projectmanager/baseqtversion.cpp @@ -0,0 +1,1124 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "baseqtversion.h" +#include "qt4projectmanagerconstants.h" +#include "qmlobservertool.h" +#include "qmldumptool.h" +#include "qmldebugginglibrary.h" +#include "profilereader.h" +#include "qt4basetargetfactory.h" + +#include "qtversionmanager.h" +#include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/debugginghelper.h> +#include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/persistentsettings.h> + +#include <utils/synchronousprocess.h> + +#include <QtCore/QDir> +#include <QtCore/QCoreApplication> +#include <QtCore/QProcess> + +#include <algorithm> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +static const char QTVERSIONID[] = "Id"; +static const char QTVERSIONNAME[] = "Name"; +static const char QTVERSIONAUTODETECTED[] = "isAutodetected"; +static const char QTVERSIONAUTODETECTIONSOURCE []= "autodetectionSource"; +static const char QTVERSIONQMAKEPATH[] = "QMakePath"; + +/////////////// +// QtVersionNumber +/////////////// +QtVersionNumber::QtVersionNumber(int ma, int mi, int p) + : majorVersion(ma), minorVersion(mi), patchVersion(p) +{ +} + +QtVersionNumber::QtVersionNumber(const QString &versionString) +{ + if (!checkVersionString(versionString)) { + majorVersion = minorVersion = patchVersion = -1; + return; + } + + QStringList parts = versionString.split(QLatin1Char('.')); + majorVersion = parts.at(0).toInt(); + minorVersion = parts.at(1).toInt(); + patchVersion = parts.at(2).toInt(); +} + +QtVersionNumber::QtVersionNumber() +{ + majorVersion = minorVersion = patchVersion = -1; +} + +bool QtVersionNumber::checkVersionString(const QString &version) const +{ + int dots = 0; + QString validChars = "0123456789."; + foreach (const QChar &c, version) { + if (!validChars.contains(c)) + return false; + if (c == '.') + ++dots; + } + if (dots != 2) + return false; + return true; +} + +bool QtVersionNumber::operator <(const QtVersionNumber &b) const +{ + if (majorVersion < b.majorVersion) + return true; + if (majorVersion > b.majorVersion) + return false; + if (minorVersion < b.minorVersion) + return true; + if (minorVersion > b.minorVersion) + return false; + if (patchVersion < b.patchVersion) + return true; + return false; +} + +bool QtVersionNumber::operator >(const QtVersionNumber &b) const +{ + return b < *this; +} + +bool QtVersionNumber::operator ==(const QtVersionNumber &b) const +{ + return majorVersion == b.majorVersion + && minorVersion == b.minorVersion + && patchVersion == b.patchVersion; +} + +bool QtVersionNumber::operator !=(const QtVersionNumber &b) const +{ + return !(*this == b); +} + +bool QtVersionNumber::operator <=(const QtVersionNumber &b) const +{ + return !(*this > b); +} + +bool QtVersionNumber::operator >=(const QtVersionNumber &b) const +{ + return b <= *this; +} + +/////////////// +// QtConfigWidget +/////////////// +QtConfigWidget::QtConfigWidget() +{ + +} + +/////////////// +// BaseQtVersion +/////////////// +int BaseQtVersion::getUniqueId() +{ + return QtVersionManager::instance()->getUniqueId(); +} + +BaseQtVersion::BaseQtVersion(const QString &qmakeCommand, bool isAutodetected, const QString &autodetectionSource) + : m_id(getUniqueId()), + m_isAutodetected(isAutodetected), + m_autodetectionSource(autodetectionSource), + m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlDebuggingLibrary(false), + m_hasQmlObserver(false), + m_mkspecUpToDate(false), + m_mkspecReadUpToDate(false), + m_defaultConfigIsDebug(true), + m_defaultConfigIsDebugAndRelease(true), + m_versionInfoUpToDate(false), + m_notInstalled(false), + m_hasExamples(false), + m_hasDemos(false), + m_hasDocumentation(false), + m_qmakeIsExecutable(false) +{ + ctor(qmakeCommand); + setDisplayName(qtVersionString()); +} + +BaseQtVersion::BaseQtVersion() + : m_id(-1), m_isAutodetected(false), + m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlDebuggingLibrary(false), + m_hasQmlObserver(false), + m_mkspecUpToDate(false), + m_mkspecReadUpToDate(false), + m_defaultConfigIsDebug(true), + m_defaultConfigIsDebugAndRelease(true), + m_versionInfoUpToDate(false), + m_notInstalled(false), + m_hasExamples(false), + m_hasDemos(false), + m_hasDocumentation(false) +{ + ctor(QString()); +} + +void BaseQtVersion::ctor(const QString& qmakePath) +{ + m_qmakeCommand = QDir::fromNativeSeparators(qmakePath); +#ifdef Q_OS_WIN + m_qmakeCommand = m_qmakeCommand.toLower(); +#endif + m_designerCommand.clear(); + m_linguistCommand.clear(); + m_qmlviewerCommand.clear(); + m_uicCommand.clear(); + m_mkspecUpToDate = false; + m_mkspecReadUpToDate = false; + m_versionInfoUpToDate = false; + m_qtVersionString.clear(); + m_sourcePath.clear(); +} + + +BaseQtVersion::~BaseQtVersion() +{ + +} + +void BaseQtVersion::setId(int id) +{ + m_id = id; +} + +void BaseQtVersion::fromMap(const QVariantMap &map) +{ + m_id = map.value(QLatin1String(QTVERSIONID)).toInt(); + if (m_id == -1) // this happens on adding from installer, see updateFromInstaller => get a new unique id + m_id = QtVersionManager::instance()->getUniqueId(); + m_displayName = map.value(QLatin1String(QTVERSIONNAME)).toString(); + m_isAutodetected = map.value(QLatin1String(QTVERSIONAUTODETECTED)).toBool(); + if (m_isAutodetected) + m_autodetectionSource = map.value(QLatin1String(QTVERSIONAUTODETECTIONSOURCE)).toString(); + ctor(map.value(QLatin1String(QTVERSIONQMAKEPATH)).toString()); +} + +QVariantMap BaseQtVersion::toMap() const +{ + QVariantMap result; + result.insert(QLatin1String(QTVERSIONID), uniqueId()); + result.insert(QLatin1String(QTVERSIONNAME), displayName()); + result.insert(QLatin1String(QTVERSIONAUTODETECTED), isAutodetected()); + if (isAutodetected()) + result.insert(QLatin1String(QTVERSIONAUTODETECTIONSOURCE), autodetectionSource()); + result.insert(QLatin1String(QTVERSIONQMAKEPATH), qmakeCommand()); + return result; +} + +bool BaseQtVersion::isValid() const +{ + if(uniqueId() == -1 || displayName().isEmpty()) + return false; + updateVersionInfo(); + updateMkspec(); + + return !qmakeCommand().isEmpty() + && !m_notInstalled + && m_versionInfo.contains("QT_INSTALL_BINS") + && (!m_mkspecFullPath.isEmpty() || !m_mkspecUpToDate) + && m_qmakeIsExecutable; +} + +QString BaseQtVersion::invalidReason() const +{ + if (displayName().isEmpty()) + return QCoreApplication::translate("QtVersion", "Qt version has no name"); + if (qmakeCommand().isEmpty()) + return QCoreApplication::translate("QtVersion", "No qmake path set"); + if (!m_qmakeIsExecutable) + return QCoreApplication::translate("QtVersion", "qmake does not exist or is not executable"); + if (m_notInstalled) + return QCoreApplication::translate("QtVersion", "Qt version is not properly installed, please run make install"); + if (!m_versionInfo.contains("QT_INSTALL_BINS")) + return QCoreApplication::translate("QtVersion", + "Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?"); + if (m_mkspecUpToDate && m_mkspecFullPath.isEmpty()) + return QCoreApplication::translate("QtVersion", "The default mkspec symlink is broken."); + return QString(); +} + +QString BaseQtVersion::qmakeCommand() const +{ + return m_qmakeCommand; +} + +bool BaseQtVersion::toolChainAvailable(const QString &id) const +{ + Q_UNUSED(id) + if (!isValid()) + return false; + foreach (const ProjectExplorer::Abi &abi, qtAbis()) + if (!ProjectExplorer::ToolChainManager::instance()->findToolChains(abi).isEmpty()) + return true; + return false; +} + +bool BaseQtVersion::equals(BaseQtVersion *other) +{ + if (type() != other->type()) + return false; + if (uniqueId() != other->uniqueId()) + return false; + if (displayName() != other->displayName()) + return false; + + return true; +} + +int BaseQtVersion::uniqueId() const +{ + return m_id; +} + +bool BaseQtVersion::isAutodetected() const +{ + return m_isAutodetected; +} + +QString BaseQtVersion::autodetectionSource() const +{ + return m_autodetectionSource; +} + +QString BaseQtVersion::displayName() const +{ + return m_displayName; +} + +void BaseQtVersion::setDisplayName(const QString &name) +{ + m_displayName = name; +} + +QString BaseQtVersion::toHtml(bool verbose) const +{ + QString rc; + QTextStream str(&rc); + str << "<html><body><table>"; + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "Name:") + << "</b></td><td>" << displayName() << "</td></tr>"; + if (!isValid()) { + str << "<tr><td colspan=2><b>" + QCoreApplication::translate("BaseQtVersion", "Invalid Qt version") +"</b></td></tr>"; + } else { + QString prefix = QLatin1String("<tr><td><b>") + QCoreApplication::translate("BaseQtVersion", "ABI:") + QLatin1String("</b></td>"); + foreach (const ProjectExplorer::Abi &abi, qtAbis()) { + str << prefix << "<td>" << abi.toString() << "</td></tr>"; + prefix = QLatin1String("<tr><td></td>"); + } + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "Source:") + << "</b></td><td>" << sourcePath() << "</td></tr>"; + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "mkspec:") + << "</b></td><td>" << mkspec() << "</td></tr>"; + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "qmake:") + << "</b></td><td>" << m_qmakeCommand << "</td></tr>"; + ensureMkSpecParsed(); + if (!mkspecPath().isEmpty()) { + if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) { + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "Default:") << "</b></td><td>" + << (m_defaultConfigIsDebug ? "debug" : "release"); + if (m_defaultConfigIsDebugAndRelease) + str << " debug_and_release"; + str << "</td></tr>"; + } // default config. + } + str << "<tr><td><b>" << QCoreApplication::translate("BaseQtVersion", "Version:") + << "</b></td><td>" << qtVersionString() << "</td></tr>"; + if (verbose) { + const QHash<QString,QString> vInfo = versionInfo(); + if (!vInfo.isEmpty()) { + const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd(); + for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it) + str << "<tr><td><pre>" << it.key() << "</pre></td><td>" << it.value() << "</td></tr>"; + } + } + } + str << "</table></body></html>"; + return rc; +} + +void BaseQtVersion::updateSourcePath() const +{ + if (!m_sourcePath.isEmpty()) + return; + updateVersionInfo(); + const QString installData = m_versionInfo["QT_INSTALL_DATA"]; + m_sourcePath = installData; + QFile qmakeCache(installData + QLatin1String("/.qmake.cache")); + if (qmakeCache.exists()) { + qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text); + QTextStream stream(&qmakeCache); + while (!stream.atEnd()) { + QString line = stream.readLine().trimmed(); + if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) { + m_sourcePath = line.split(QLatin1Char('=')).at(1).trimmed(); + if (m_sourcePath.startsWith(QLatin1String("$$quote("))) { + m_sourcePath.remove(0, 8); + m_sourcePath.chop(1); + } + break; + } + } + } + m_sourcePath = QDir::cleanPath(m_sourcePath); +#ifdef Q_OS_WIN + m_sourcePath = m_sourcePath.toLower(); +#endif +} + +QString BaseQtVersion::sourcePath() const +{ + updateSourcePath(); + return m_sourcePath; +} + +// Return a list of GUI binary names +// 'foo', 'foo.exe', 'Foo.app/Contents/MacOS/Foo' +static inline QStringList possibleGuiBinaries(const QString &name) +{ +#ifdef Q_OS_WIN + return QStringList(name + QLatin1String(".exe")); +#elif defined(Q_OS_MAC) // 'Foo.app/Contents/MacOS/Foo' + QString upCaseName = name; + upCaseName[0] = upCaseName.at(0).toUpper(); + QString macBinary = upCaseName; + macBinary += QLatin1String(".app/Contents/MacOS/"); + macBinary += upCaseName; + return QStringList(macBinary); +#else + return QStringList(name); +#endif +} + +QString BaseQtVersion::designerCommand() const +{ + if (!isValid()) + return QString(); + if (m_designerCommand.isNull()) + m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer"))); + return m_designerCommand; +} + +QString BaseQtVersion::linguistCommand() const +{ + if (!isValid()) + return QString(); + if (m_linguistCommand.isNull()) + m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist"))); + return m_linguistCommand; +} + +QString BaseQtVersion::qmlviewerCommand() const +{ + if (!isValid()) + return QString(); + + if (m_qmlviewerCommand.isNull()) { +#ifdef Q_OS_MAC + const QString qmlViewerName = QLatin1String("QMLViewer"); +#else + const QString qmlViewerName = QLatin1String("qmlviewer"); +#endif + + m_qmlviewerCommand = findQtBinary(possibleGuiBinaries(qmlViewerName)); + } + return m_qmlviewerCommand; +} + +QString BaseQtVersion::findQtBinary(const QStringList &possibleCommands) const +{ + QString qtdirbin = versionInfo().value(QLatin1String("QT_INSTALL_BINS")); + if (qtdirbin.isEmpty()) + return QString(); + qtdirbin += QLatin1Char('/'); + + foreach (const QString &possibleCommand, possibleCommands) { + const QString fullPath = qtdirbin + possibleCommand; + if (QFileInfo(fullPath).isFile()) + return QDir::cleanPath(fullPath); + } + return QString(); +} + +QString BaseQtVersion::uicCommand() const +{ + if (!isValid()) + return QString(); + if (!m_uicCommand.isNull()) + return m_uicCommand; +#ifdef Q_OS_WIN + const QStringList possibleCommands(QLatin1String("uic.exe")); +#else + QStringList possibleCommands; + possibleCommands << QLatin1String("uic-qt4") << QLatin1String("uic4") << QLatin1String("uic"); +#endif + m_uicCommand = findQtBinary(possibleCommands); + return m_uicCommand; +} + +QString BaseQtVersion::systemRoot() const +{ + return QString(); +} + +void BaseQtVersion::updateMkspec() const +{ + if (uniqueId() == -1 || m_mkspecUpToDate) + return; + + m_mkspecUpToDate = true; + m_mkspecFullPath = mkspecFromVersionInfo(versionInfo()); + + m_mkspec = m_mkspecFullPath; + if (m_mkspecFullPath.isEmpty()) + return; + + QString baseMkspecDir = versionInfo().value("QMAKE_MKSPECS"); + if (baseMkspecDir.isEmpty()) + baseMkspecDir = versionInfo().value("QT_INSTALL_DATA") + "/mkspecs"; + +#ifdef Q_OS_WIN + baseMkspecDir = baseMkspecDir.toLower(); +#endif + + if (m_mkspec.startsWith(baseMkspecDir)) { + m_mkspec = m_mkspec.mid(baseMkspecDir.length() + 1); +// qDebug() << "Setting mkspec to"<<mkspec; + } else { + QString sourceMkSpecPath = sourcePath() + "/mkspecs"; + if (m_mkspec.startsWith(sourceMkSpecPath)) { + m_mkspec = m_mkspec.mid(sourceMkSpecPath.length() + 1); + } else { + // Do nothing + } + } +} + +void BaseQtVersion::ensureMkSpecParsed() const +{ + if (m_mkspecReadUpToDate) + return; + m_mkspecReadUpToDate = true; + + if (mkspecPath().isEmpty()) + return; + + ProFileOption option; + option.properties = versionInfo(); + ProMessageHandler msgHandler(true); + ProFileCacheManager::instance()->incRefCount(); + ProFileParser parser(ProFileCacheManager::instance()->cache(), &msgHandler); + ProFileEvaluator evaluator(&option, &parser, &msgHandler); + if (ProFile *pro = parser.parsedProFile(mkspecPath() + "/qmake.conf")) { + evaluator.setCumulative(false); + evaluator.accept(pro, ProFileEvaluator::LoadProOnly); + pro->deref(); + } + + parseMkSpec(&evaluator); + + ProFileCacheManager::instance()->decRefCount(); +} + +void BaseQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const +{ + QStringList configValues = evaluator->values("CONFIG"); + m_defaultConfigIsDebugAndRelease = false; + foreach(const QString &value, configValues) { + if (value == "debug") + m_defaultConfigIsDebug = true; + else if (value == "release") + m_defaultConfigIsDebug = false; + else if (value == "build_all") + m_defaultConfigIsDebugAndRelease = true; + } +} + +QString BaseQtVersion::mkspec() const +{ + updateMkspec(); + return m_mkspec; +} + +QString BaseQtVersion::mkspecPath() const +{ + updateMkspec(); + return m_mkspecFullPath; +} + +BaseQtVersion::QmakeBuildConfigs BaseQtVersion::defaultBuildConfig() const +{ + ensureMkSpecParsed(); + BaseQtVersion::QmakeBuildConfigs result = BaseQtVersion::QmakeBuildConfig(0); + + if (m_defaultConfigIsDebugAndRelease) + result = BaseQtVersion::BuildAll; + if (m_defaultConfigIsDebug) + result = result | BaseQtVersion::DebugBuild; + return result; +} + +QString BaseQtVersion::qtVersionString() const +{ + if (m_qtVersionString.isNull()) { + QFileInfo qmake(m_qmakeCommand); + if (qmake.exists() && qmake.isExecutable()) + m_qtVersionString = ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath()); + else + m_qtVersionString = QLatin1String(""); + } + return m_qtVersionString; +} + +QtVersionNumber BaseQtVersion::qtVersion() const +{ + return QtVersionNumber(qtVersionString()); +} + +void BaseQtVersion::updateVersionInfo() const +{ + if (m_versionInfoUpToDate) + return; + + // extract data from qmake executable + m_versionInfo.clear(); + m_notInstalled = false; + m_hasExamples = false; + m_hasDocumentation = false; + m_hasDebuggingHelper = false; + m_hasQmlDump = false; + m_hasQmlDebuggingLibrary = false; + m_hasQmlObserver = false; + + m_qmakeIsExecutable = true; + + QFileInfo fi(qmakeCommand()); + if (!fi.exists() || !fi.isExecutable() || fi.isDir()) { + m_qmakeIsExecutable = false; + return; + } + + if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo)) + return; + + if (m_versionInfo.contains("QT_INSTALL_DATA")) { + QString qtInstallData = m_versionInfo.value("QT_INSTALL_DATA"); + QString qtHeaderData = m_versionInfo.value("QT_INSTALL_HEADERS"); + m_versionInfo.insert("QMAKE_MKSPECS", QDir::cleanPath(qtInstallData+"/mkspecs")); + + if (!qtInstallData.isEmpty()) { + m_hasDebuggingHelper = !ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty(); + m_hasQmlDump + = !QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, false).isEmpty() + || !QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, true).isEmpty(); + m_hasQmlDebuggingLibrary + = !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, false).isEmpty() + || !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, true).isEmpty(); + m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty(); + } + } + + // Now check for a qt that is configured with a prefix but not installed + if (m_versionInfo.contains("QT_INSTALL_BINS")) { + QFileInfo fi(m_versionInfo.value("QT_INSTALL_BINS")); + if (!fi.exists()) + m_notInstalled = true; + } + if (m_versionInfo.contains("QT_INSTALL_HEADERS")){ + QFileInfo fi(m_versionInfo.value("QT_INSTALL_HEADERS")); + if (!fi.exists()) + m_notInstalled = true; + } + if (m_versionInfo.contains("QT_INSTALL_DOCS")){ + QFileInfo fi(m_versionInfo.value("QT_INSTALL_DOCS")); + if (fi.exists()) + m_hasDocumentation = true; + } + if (m_versionInfo.contains("QT_INSTALL_EXAMPLES")){ + QFileInfo fi(m_versionInfo.value("QT_INSTALL_EXAMPLES")); + if (fi.exists()) + m_hasExamples = true; + } + if (m_versionInfo.contains("QT_INSTALL_DEMOS")){ + QFileInfo fi(m_versionInfo.value("QT_INSTALL_DEMOS")); + if (fi.exists()) + m_hasDemos = true; + } + + m_versionInfoUpToDate = true; +} + +QHash<QString,QString> BaseQtVersion::versionInfo() const +{ + updateVersionInfo(); + return m_versionInfo; +} + +bool BaseQtVersion::hasDocumentation() const +{ + updateVersionInfo(); + return m_hasDocumentation; +} + +QString BaseQtVersion::documentationPath() const +{ + updateVersionInfo(); + return m_versionInfo["QT_INSTALL_DOCS"]; +} + +bool BaseQtVersion::hasDemos() const +{ + updateVersionInfo(); + return m_hasDemos; +} + +QString BaseQtVersion::demosPath() const +{ + updateVersionInfo(); + return m_versionInfo["QT_INSTALL_DEMOS"]; +} + +QString BaseQtVersion::frameworkInstallPath() const +{ +#ifdef Q_OS_MAC + updateVersionInfo(); + return m_versionInfo["QT_INSTALL_LIBS"]; +#else + return QString(); +#endif +} + +bool BaseQtVersion::hasExamples() const +{ + updateVersionInfo(); + return m_hasExamples; +} + +QString BaseQtVersion::examplesPath() const +{ + updateVersionInfo(); + return m_versionInfo["QT_INSTALL_EXAMPLES"]; +} + +QList<ProjectExplorer::HeaderPath> BaseQtVersion::systemHeaderPathes() const +{ + QList<ProjectExplorer::HeaderPath> result; + result.append(ProjectExplorer::HeaderPath(mkspecPath(), ProjectExplorer::HeaderPath::GlobalHeaderPath)); + return result; +} + +void BaseQtVersion::addToEnvironment(Utils::Environment &env) const +{ + env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA"))); + env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS")); + env.prependOrSetLibrarySearchPath(versionInfo().value("QT_INSTALL_LIBS")); +} + +bool BaseQtVersion::hasGdbDebuggingHelper() const +{ + updateVersionInfo(); + return m_hasDebuggingHelper; +} + + +bool BaseQtVersion::hasQmlDump() const +{ + updateVersionInfo(); + return m_hasQmlDump; +} + +bool BaseQtVersion::hasQmlDebuggingLibrary() const +{ + updateVersionInfo(); + return m_hasQmlDebuggingLibrary; +} + +bool BaseQtVersion::hasQmlObserver() const +{ + updateVersionInfo(); + return m_hasQmlObserver; +} + +Utils::Environment BaseQtVersion::qmlToolsEnvironment() const +{ + // FIXME: This seems broken! + Utils::Environment environment = Utils::Environment::systemEnvironment(); + addToEnvironment(environment); + + // add preferred tool chain, as that is how the tools are built, compare QtVersion::buildDebuggingHelperLibrary + QList<ProjectExplorer::ToolChain *> alltc = + ProjectExplorer::ToolChainManager::instance()->findToolChains(qtAbis().at(0)); + if (!alltc.isEmpty()) + alltc.first()->addToEnvironment(environment); + + return environment; +} + +QString BaseQtVersion::gdbDebuggingHelperLibrary() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return ProjectExplorer::DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData); +} + +QString BaseQtVersion::qmlDumpTool(bool debugVersion) const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + QString qtHeaderData = versionInfo().value("QT_INSTALL_HEADERS"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, debugVersion); +} + +QString BaseQtVersion::qmlDebuggingHelperLibrary(bool debugVersion) const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlDebuggingLibrary::libraryByInstallData(qtInstallData, debugVersion); +} + +QString BaseQtVersion::qmlObserverTool() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlObserverTool::toolByInstallData(qtInstallData); +} + +QStringList BaseQtVersion::debuggingHelperLibraryLocations() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QStringList(); + return ProjectExplorer::DebuggingHelperLibrary::locationsByInstallData(qtInstallData); +} + +bool BaseQtVersion::supportsBinaryDebuggingHelper() const +{ + if (!isValid()) + return false; + return true; +} + +void BaseQtVersion::recheckDumper() +{ + m_versionInfoUpToDate = false; +} + +bool BaseQtVersion::supportsShadowBuilds() const +{ + return true; +} + +QList<ProjectExplorer::Task> BaseQtVersion::reportIssuesImpl(const QString &proFile, const QString &buildDir) +{ + QList<ProjectExplorer::Task> results; + + QString tmpBuildDir = QDir(buildDir).absolutePath(); + if (!tmpBuildDir.endsWith(QLatin1Char('/'))) + tmpBuildDir.append(QLatin1Char('/')); + + if (!isValid()) { + //: %1: Reason for being invalid + const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason()); + results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1, + QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + } + + QFileInfo qmakeInfo(qmakeCommand()); + if (!qmakeInfo.exists() || + !qmakeInfo.isExecutable()) { + //: %1: Path to qmake executable + const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", + "The qmake command \"%1\" was not found or is not executable.").arg(qmakeCommand()); + results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1, + QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + } + + QString sourcePath = QFileInfo(proFile).absolutePath(); + if (!sourcePath.endsWith(QLatin1Char('/'))) + sourcePath.append(QLatin1Char('/')); + if ((tmpBuildDir.startsWith(sourcePath)) && (tmpBuildDir != sourcePath)) { + const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", + "Qmake does not support build directories below the source directory."); + results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1, + QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + } else if (tmpBuildDir.count(QChar('/')) != sourcePath.count(QChar('/'))) { + const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", + "The build directory needs to be at the same level as the source directory."); + + results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1, + QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + } + + return results; +} + +QList<ProjectExplorer::Task> +BaseQtVersion::reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors) +{ + QList<ProjectExplorer::Task> results = reportIssuesImpl(proFile, buildDir); + if (includeTargetSpecificErrors) { + QList<Qt4BaseTargetFactory *> factories; + foreach (const QString &id, supportedTargetIds()) + if (Qt4BaseTargetFactory *factory = Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(id)) + factories << factory; + + qSort(factories); + QList<Qt4BaseTargetFactory *>::iterator newend = std::unique(factories.begin(), factories.end()); + QList<Qt4BaseTargetFactory *>::iterator it = factories.begin(); + for ( ; it != newend; ++it) + results.append((*it)->reportIssues(proFile)); + } + + qSort(results); + return results; +} + +ProjectExplorer::IOutputParser *BaseQtVersion::createOutputParser() const +{ + return new ProjectExplorer::GnuMakeParser; +} + +QtConfigWidget *BaseQtVersion::createConfigurationWidget() const +{ + return 0; +} + +bool BaseQtVersion::queryQMakeVariables(const QString &binary, QHash<QString, QString> *versionInfo) +{ + const int timeOutMS = 30000; // Might be slow on some machines. + QFileInfo qmake(binary); + if (!qmake.exists() || !qmake.isExecutable() || qmake.isDir()) + return false; + static const char * const variables[] = { + "QT_VERSION", + "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", + "QT_INSTALL_IMPORTS", + "QMAKEFEATURES" + }; + QStringList args; + for (uint i = 0; i < sizeof variables / sizeof variables[0]; ++i) + args << "-query" << variables[i]; + QProcess process; + process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly); + if (!process.waitForStarted()) { + qWarning("Cannot start '%s': %s", qPrintable(binary), qPrintable(process.errorString())); + return false; + } + if (!process.waitForFinished(timeOutMS)) { + Utils::SynchronousProcess::stopProcess(process); + qWarning("Timeout running '%s' (%dms).", qPrintable(binary), timeOutMS); + return false; + } + if (process.exitStatus() != QProcess::NormalExit) { + qWarning("'%s' crashed.", qPrintable(binary)); + return false; + } + QByteArray output = process.readAllStandardOutput(); + QTextStream stream(&output); + while (!stream.atEnd()) { + const QString line = stream.readLine(); + const int index = line.indexOf(QLatin1Char(':')); + if (index != -1) { + const QString value = QDir::fromNativeSeparators(line.mid(index+1)); + if (value != "**Unknown**") + versionInfo->insert(line.left(index), value); + } + } + return true; +} + +QString BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo) +{ + QString baseMkspecDir = versionInfo.value("QMAKE_MKSPECS"); + if (baseMkspecDir.isEmpty()) + baseMkspecDir = versionInfo.value("QT_INSTALL_DATA") + "/mkspecs"; + if (baseMkspecDir.isEmpty()) + return QString(); + +#ifdef Q_OS_WIN + baseMkspecDir = baseMkspecDir.toLower(); +#endif + + QString mkspecFullPath = baseMkspecDir + "/default"; + + // qDebug() << "default mkspec is located at" << mkspecFullPath; + +#ifdef Q_OS_WIN + QFile f2(mkspecFullPath + "/qmake.conf"); + if (f2.exists() && f2.open(QIODevice::ReadOnly)) { + while (!f2.atEnd()) { + QByteArray line = f2.readLine(); + if (line.startsWith("QMAKESPEC_ORIGINAL")) { + const QList<QByteArray> &temp = line.split('='); + if (temp.size() == 2) { + QString possibleFullPath = temp.at(1).trimmed(); + // We sometimes get a mix of different slash styles here... + possibleFullPath = possibleFullPath.replace('\\', '/'); + if (QFileInfo(possibleFullPath).exists()) // Only if the path exists + mkspecFullPath = possibleFullPath; + } + break; + } + } + f2.close(); + } +#elif defined(Q_OS_MAC) + QFile f2(mkspecFullPath + "/qmake.conf"); + if (f2.exists() && f2.open(QIODevice::ReadOnly)) { + while (!f2.atEnd()) { + QByteArray line = f2.readLine(); + if (line.startsWith("MAKEFILE_GENERATOR")) { + const QList<QByteArray> &temp = line.split('='); + if (temp.size() == 2) { + const QByteArray &value = temp.at(1); + if (value.contains("XCODE")) { + // we don't want to generate xcode projects... +// qDebug() << "default mkspec is xcode, falling back to g++"; + mkspecFullPath = baseMkspecDir + "/macx-g++"; + } + //resolve mkspec link + mkspecFullPath = QFileInfo(mkspecFullPath).canonicalFilePath(); + } + break; + } + } + f2.close(); + } +#else + mkspecFullPath = QFileInfo(mkspecFullPath).canonicalFilePath(); +#endif + +#ifdef Q_OS_WIN + mkspecFullPath = mkspecFullPath.toLower(); +#endif + return mkspecFullPath; +} + +QString BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString) +{ + QStringList dirs; + dirs << versionInfo.value(QLatin1String("QT_INSTALL_LIBS")) + << versionInfo.value(QLatin1String("QT_INSTALL_BINS")); + + QFileInfoList staticLibs; + foreach (const QString &dir, dirs) { + if (dir.isEmpty()) + continue; + QDir d(dir); + QFileInfoList infoList = d.entryInfoList(); + foreach (const QFileInfo &info, infoList) { + const QString file = info.fileName(); + if (info.isDir() + && file.startsWith(QLatin1String("QtCore")) + && file.endsWith(QLatin1String(".framework"))) { + // handle Framework + const QString libName = file.left(file.lastIndexOf('.')); + return info.absoluteFilePath() + '/' + libName; + } + if (info.isReadable()) { + if (file.startsWith(QLatin1String("libQtCore")) + || file.startsWith(QLatin1String("QtCore"))) { + // Only handle static libs if we can not find dynamic ones: + if (file.endsWith(".a") || file.endsWith(".lib")) + staticLibs.append(info); + else if (file.endsWith(QLatin1String(".dll")) + || file.endsWith(QString::fromLatin1(".so.") + versionString) + || file.endsWith(QLatin1Char('.') + versionString + QLatin1String(".dylib"))) + + return info.absoluteFilePath(); + } + } + } + } + // Return path to first static library found: + if (!staticLibs.isEmpty()) + return staticLibs.at(0).absoluteFilePath(); + return QString(); +} + +QList<ProjectExplorer::Abi> BaseQtVersion::qtAbisFromLibrary(const QString &coreLibrary, bool mingw) +{ + QList<ProjectExplorer::Abi> qtAbis = ProjectExplorer::Abi::abisOfBinary(coreLibrary); +#if defined (Q_OS_WIN) + if (mingw) { + QList<ProjectExplorer::Abi> tmp = qtAbis; + qtAbis.clear(); + foreach (const ProjectExplorer::Abi &abi, tmp) + qtAbis.append(ProjectExplorer::Abi(abi.architecture(), abi.os(), ProjectExplorer::Abi::WindowsMSysFlavor, + abi.binaryFormat(), abi.wordWidth())); + } +#else + Q_UNUSED(mingw) +#endif + if (qtAbis.isEmpty() && !coreLibrary.isEmpty()) { + qWarning("Warning: Could not find ABI for '%s'" + "Qt Creator does not know about the system includes, " + "nor the system defines.", qPrintable(coreLibrary)); + } + return qtAbis; +} diff --git a/src/plugins/qt4projectmanager/baseqtversion.h b/src/plugins/qt4projectmanager/baseqtversion.h new file mode 100644 index 0000000000..e53f4a0b45 --- /dev/null +++ b/src/plugins/qt4projectmanager/baseqtversion.h @@ -0,0 +1,245 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef BASEQTVERSION_H +#define BASEQTVERSION_H + +#include "qt4projectmanager_global.h" + +#include <projectexplorer/abi.h> +#include <projectexplorer/headerpath.h> +#include <projectexplorer/task.h> +#include <projectexplorer/ioutputparser.h> +#include <utils/environment.h> + +#include <QtCore/QVariantMap> + +QT_BEGIN_NAMESPACE +class ProFileEvaluator; +QT_END_NAMESPACE + +namespace Qt4ProjectManager { +class QT4PROJECTMANAGER_EXPORT QtVersionNumber +{ +public: + QtVersionNumber(int ma, int mi, int p); + QtVersionNumber(const QString &versionString); + QtVersionNumber(); + + int majorVersion; + int minorVersion; + int patchVersion; + bool operator <(const QtVersionNumber &b) const; + bool operator <=(const QtVersionNumber &b) const; + bool operator >(const QtVersionNumber &b) const; + bool operator >=(const QtVersionNumber &b) const; + bool operator !=(const QtVersionNumber &b) const; + bool operator ==(const QtVersionNumber &b) const; +private: + bool checkVersionString(const QString &version) const; +}; + +class QT4PROJECTMANAGER_EXPORT QtConfigWidget : public QWidget +{ + Q_OBJECT +public: + QtConfigWidget(); +signals: + void changed(); +}; + +class QT4PROJECTMANAGER_EXPORT BaseQtVersion +{ + friend class QtVersionManager; +public: + virtual ~BaseQtVersion(); + + virtual void fromMap(const QVariantMap &map); + virtual BaseQtVersion *clone() const = 0; + virtual bool equals(BaseQtVersion *other); + + bool isAutodetected() const; + QString autodetectionSource() const; + + QString displayName() const; + void setDisplayName(const QString &name); + + // All valid Ids are >= 0 + int uniqueId() const; + + virtual QString type() const = 0; + + virtual QVariantMap toMap() const; + virtual bool isValid() const; + virtual QString invalidReason() const; + + virtual bool toolChainAvailable(const QString &id) const; + + virtual QString description() const = 0; + virtual QString toHtml(bool verbose) const; + + virtual bool supportsTargetId(const QString &id) const = 0; + virtual QSet<QString> supportedTargetIds() const = 0; + virtual QList<ProjectExplorer::Abi> qtAbis() const = 0; + + // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information + virtual QHash<QString,QString> versionInfo() const; + virtual void addToEnvironment(Utils::Environment &env) const; + + virtual QString sourcePath() const; + // used by QtUiCodeModelSupport + virtual QString uicCommand() const; + virtual QString designerCommand() const; + virtual QString linguistCommand() const; + QString qmlviewerCommand() const; + + virtual QString qtVersionString() const; + virtual QtVersionNumber qtVersion() const; + + bool hasExamples() const; + QString examplesPath() const; + + bool hasDocumentation() const; + QString documentationPath() const; + + bool hasDemos() const; + QString demosPath() const; + + virtual QList<ProjectExplorer::HeaderPath> systemHeaderPathes() const; + virtual QString frameworkInstallPath() const; + + // former local functions + QString qmakeCommand() const; + virtual QString systemRoot() const; + + /// @returns the name of the mkspec + QString mkspec() const; + /// @returns the full path to the default directory + /// specifally not the directory the symlink/ORIGINAL_QMAKESPEC points to + QString mkspecPath() const; + + enum QmakeBuildConfig + { + NoBuild = 1, + DebugBuild = 2, + BuildAll = 8 + }; + + Q_DECLARE_FLAGS(QmakeBuildConfigs, QmakeBuildConfig) + + virtual QmakeBuildConfigs defaultBuildConfig() const; + virtual void recheckDumper(); + virtual bool supportsShadowBuilds() const; + + /// Check a .pro-file/Qt version combination on possible issues + /// @return a list of tasks, ordered on severity (errors first, then + /// warnings and finally info items. + QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors); + + virtual ProjectExplorer::IOutputParser *createOutputParser() const; + + static bool queryQMakeVariables(const QString &binary, QHash<QString, QString> *versionInfo); + static QString mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo); + + + virtual bool supportsBinaryDebuggingHelper() const; + virtual QString gdbDebuggingHelperLibrary() const; + virtual QString qmlDebuggingHelperLibrary(bool debugVersion) const; + virtual QString qmlDumpTool(bool debugVersion) const; + virtual QString qmlObserverTool() const; + virtual QStringList debuggingHelperLibraryLocations() const; + + virtual bool hasGdbDebuggingHelper() const; + virtual bool hasQmlDump() const; + virtual bool hasQmlDebuggingLibrary() const; + virtual bool hasQmlObserver() const; + Utils::Environment qmlToolsEnvironment() const; + + virtual QtConfigWidget *createConfigurationWidget() const; + +protected: + BaseQtVersion(); + BaseQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + + virtual QList<ProjectExplorer::Task> reportIssuesImpl(const QString &proFile, const QString &buildDir); + + // helper function for desktop and simulator to figure out the supported abis based on the libraries + static QString qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString); + static QList<ProjectExplorer::Abi> qtAbisFromLibrary(const QString &coreLibrary, bool mingw); + + void ensureMkSpecParsed() const; + virtual void parseMkSpec(ProFileEvaluator *) const; +private: + static int getUniqueId(); + void ctor(const QString &qmakePath); + void updateSourcePath() const; + void updateVersionInfo() const; + QString findQtBinary(const QStringList &possibleName) const; + void updateMkspec() const; + void setId(int id); // used by the qtversionmanager for legacy restore + QString m_displayName; + int m_id; + bool m_isAutodetected; + QString m_autodetectionSource; + + mutable QString m_sourcePath; + mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate + mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate + mutable bool m_hasQmlDebuggingLibrary; // controlled by m_versionInfoUpdate + mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate + + mutable bool m_mkspecUpToDate; + mutable QString m_mkspec; + mutable QString m_mkspecFullPath; + + mutable bool m_mkspecReadUpToDate; + mutable bool m_defaultConfigIsDebug; + mutable bool m_defaultConfigIsDebugAndRelease; + + mutable bool m_versionInfoUpToDate; + mutable QHash<QString,QString> m_versionInfo; + mutable bool m_notInstalled; + mutable bool m_hasExamples; + mutable bool m_hasDemos; + mutable bool m_hasDocumentation; + + mutable QString m_qmakeCommand; + mutable QString m_qtVersionString; + mutable QString m_uicCommand; + mutable QString m_designerCommand; + mutable QString m_linguistCommand; + mutable QString m_qmlviewerCommand; + + mutable bool m_qmakeIsExecutable; +}; +} +#endif // BASEQTVERSION_H diff --git a/src/plugins/qt4projectmanager/buildconfigurationinfo.h b/src/plugins/qt4projectmanager/buildconfigurationinfo.h index c24d84d023..57b81c5ffe 100644 --- a/src/plugins/qt4projectmanager/buildconfigurationinfo.h +++ b/src/plugins/qt4projectmanager/buildconfigurationinfo.h @@ -38,10 +38,10 @@ namespace Qt4ProjectManager { struct QT4PROJECTMANAGER_EXPORT BuildConfigurationInfo { explicit BuildConfigurationInfo() - : version(0), buildConfig(QtVersion::QmakeBuildConfig(0)), importing(false), temporaryQtVersion(false) + : version(0), buildConfig(BaseQtVersion::QmakeBuildConfig(0)), importing(false), temporaryQtVersion(false) {} - explicit BuildConfigurationInfo(QtVersion *v, QtVersion::QmakeBuildConfigs bc, + explicit BuildConfigurationInfo(BaseQtVersion *v, BaseQtVersion::QmakeBuildConfigs bc, const QString &aa, const QString &d, bool importing_ = false, bool temporaryQtVersion_ = false) : version(v), buildConfig(bc), additionalArguments(aa), directory(d), importing(importing_), temporaryQtVersion(temporaryQtVersion_) { } @@ -51,8 +51,8 @@ struct QT4PROJECTMANAGER_EXPORT BuildConfigurationInfo { return version != 0; } - QtVersion *version; - QtVersion::QmakeBuildConfigs buildConfig; + BaseQtVersion *version; + BaseQtVersion::QmakeBuildConfigs buildConfig; QString additionalArguments; QString directory; bool importing; diff --git a/src/plugins/qt4projectmanager/debugginghelperbuildtask.cpp b/src/plugins/qt4projectmanager/debugginghelperbuildtask.cpp index 40478322a7..8abdc40b1c 100644 --- a/src/plugins/qt4projectmanager/debugginghelperbuildtask.cpp +++ b/src/plugins/qt4projectmanager/debugginghelperbuildtask.cpp @@ -34,8 +34,8 @@ #include "qmldumptool.h" #include "qmlobservertool.h" #include "qmldebugginglibrary.h" +#include <qt4projectmanager/baseqtversion.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> -#include <qt4projectmanager/qtversionmanager.h> #include <projectexplorer/toolchainmanager.h> #include <projectexplorer/debugginghelper.h> #include <projectexplorer/abi.h> @@ -47,8 +47,7 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; using ProjectExplorer::DebuggingHelperLibrary; - -DebuggingHelperBuildTask::DebuggingHelperBuildTask(const QtVersion *version, Tools tools) : +DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools) : m_tools(tools & availableTools(version)) { if (!version || !version->isValid()) @@ -98,7 +97,7 @@ DebuggingHelperBuildTask::~DebuggingHelperBuildTask() { } -DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const QtVersion *version) +DebuggingHelperBuildTask::Tools DebuggingHelperBuildTask::availableTools(const BaseQtVersion *version) { QTC_ASSERT(version, return 0; ) // Check the build requirements of the tools diff --git a/src/plugins/qt4projectmanager/debugginghelperbuildtask.h b/src/plugins/qt4projectmanager/debugginghelperbuildtask.h index 23977d0eca..2c91adbb8b 100644 --- a/src/plugins/qt4projectmanager/debugginghelperbuildtask.h +++ b/src/plugins/qt4projectmanager/debugginghelperbuildtask.h @@ -40,7 +40,7 @@ #include <QtCore/QMetaType> namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { class DebuggingHelperBuildTask : public QObject { @@ -56,12 +56,12 @@ public: }; Q_DECLARE_FLAGS(Tools, DebuggingHelper) - explicit DebuggingHelperBuildTask(const QtVersion *version, Tools tools = AllTools); + explicit DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools = AllTools); virtual ~DebuggingHelperBuildTask(); void run(QFutureInterface<void> &future); - static Tools availableTools(const QtVersion *version); + static Tools availableTools(const BaseQtVersion *version); signals: void finished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools); diff --git a/src/plugins/qt4projectmanager/externaleditors.cpp b/src/plugins/qt4projectmanager/externaleditors.cpp index e3911d0f9c..7721dbe36f 100644 --- a/src/plugins/qt4projectmanager/externaleditors.cpp +++ b/src/plugins/qt4projectmanager/externaleditors.cpp @@ -146,7 +146,10 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName, !project->activeTarget()->activeBuildConfiguration()) return false; Qt4BuildConfiguration *qt4bc = project->activeTarget()->activeBuildConfiguration(); - const QtVersion *qtVersion = qt4bc->qtVersion(); + BaseQtVersion *qtVersion = qt4bc->qtVersion(); + if (!qtVersion) + return false; + data->binary = (qtVersion->*commandAccessor)(); data->workingDirectory = project->projectDirectory(); } else { @@ -195,7 +198,7 @@ LinguistExternalEditor::LinguistExternalEditor(QObject *parent) : bool LinguistExternalEditor::startEditor(const QString &fileName, QString *errorMessage) { EditorLaunchData data; - return getEditorLaunchData(fileName, &QtVersion::linguistCommand, + return getEditorLaunchData(fileName, &BaseQtVersion::linguistCommand, QLatin1String(linguistBinaryC), QStringList(), true, &data, errorMessage) && startEditorProcess(data, errorMessage); @@ -213,7 +216,7 @@ MacDesignerExternalEditor::MacDesignerExternalEditor(QObject *parent) : bool MacDesignerExternalEditor::startEditor(const QString &fileName, QString *errorMessage) { EditorLaunchData data; - return getEditorLaunchData(fileName, &QtVersion::designerCommand, + return getEditorLaunchData(fileName, &BaseQtVersion::designerCommand, QLatin1String(designerBinaryC), QStringList(), true, &data, errorMessage) && startEditorProcess(data, errorMessage); @@ -249,7 +252,7 @@ bool DesignerExternalEditor::startEditor(const QString &fileName, QString *error { EditorLaunchData data; // Find the editor binary - if (!getEditorLaunchData(fileName, &QtVersion::designerCommand, + if (!getEditorLaunchData(fileName, &BaseQtVersion::designerCommand, QLatin1String(designerBinaryC), QStringList(), false, &data, errorMessage)) { return false; diff --git a/src/plugins/qt4projectmanager/externaleditors.h b/src/plugins/qt4projectmanager/externaleditors.h index 652db33e13..9a4703c8d5 100644 --- a/src/plugins/qt4projectmanager/externaleditors.h +++ b/src/plugins/qt4projectmanager/externaleditors.h @@ -46,7 +46,7 @@ QT_END_NAMESPACE namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { @@ -66,7 +66,7 @@ public: protected: // Method pointer for a QtVersion method return a string (command) - typedef QString (QtVersion::*QtVersionCommandAccessor)() const; + typedef QString (BaseQtVersion::*QtVersionCommandAccessor)() const; // Data required to launch the editor struct EditorLaunchData { diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index c87190b9dc..b411b7864b 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -203,9 +203,13 @@ bool MakeStep::init() setEnabled(true); pp->setArguments(args); - ProjectExplorer::IOutputParser *parser = bc->qtVersion()->createOutputParser(); - Q_ASSERT(parser); - parser->appendOutputParser(new QtParser); + ProjectExplorer::IOutputParser *parser = 0; + if (bc->qtVersion()) + parser = bc->qtVersion()->createOutputParser(); + if (parser) + parser->appendOutputParser(new QtParser); + else + parser = new QtParser; if (toolchain) parser->appendOutputParser(toolchain->outputParser()); diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index af84ea0c07..6fefa1712c 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -133,7 +133,8 @@ QString QMakeStep::allArguments(bool shorted) for (Utils::QtcProcess::ArgIterator ait(&additonalArguments); ait.next(); ) if (ait.value() == QLatin1String("-spec")) goto haveSpec; - arguments << "-spec" << bc->qtVersion()->mkspec(); + if (bc->qtVersion()) + arguments << "-spec" << bc->qtVersion()->mkspec(); haveSpec: // Find out what flags we pass on to qmake @@ -163,7 +164,7 @@ QStringList QMakeStep::moreArguments() #endif if (m_linkQmlDebuggingLibrary - && !bc->qtVersion()->qmlDebuggingHelperLibrary(true).isEmpty()) { + && bc->qtVersion() && !bc->qtVersion()->qmlDebuggingHelperLibrary(true).isEmpty()) { // Do not turn debugger path into native path separators: Qmake does not like that! const QString debuggingHelperPath = QFileInfo(bc->qtVersion()->qmlDebuggingHelperLibrary(true)).dir().path(); @@ -172,7 +173,7 @@ QStringList QMakeStep::moreArguments() + QLatin1Char('=') + debuggingHelperPath; } - if (!bc->qtVersion()->supportsShadowBuilds()) { + if (bc->qtVersion() && !bc->qtVersion()->supportsShadowBuilds()) { // We have a target which does not allow shadow building. // But we really don't want to have the build artefacts in the source dir // so we try to hack around it, to make the common cases work. @@ -190,7 +191,10 @@ QStringList QMakeStep::moreArguments() bool QMakeStep::init() { Qt4BuildConfiguration *qt4bc = qt4BuildConfiguration(); - const QtVersion *qtVersion = qt4bc->qtVersion(); + const BaseQtVersion *qtVersion = qt4bc->qtVersion(); + + if (!qtVersion) + return false; QString args = allArguments(); QString workingDirectory; @@ -329,10 +333,16 @@ void QMakeStep::setUserArguments(const QString &arguments) bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const { - if (qt4BuildConfiguration()->qtVersion()->hasQmlDebuggingLibrary()) + BaseQtVersion *version = qt4BuildConfiguration()->qtVersion(); + if (!version) { + if (reason) + *reason = tr("No Qt version."); + return false; + } + if (version->hasQmlDebuggingLibrary()) return true; - if (!qt4BuildConfiguration()->qtVersion()->qtAbis().isEmpty()) { + if (!version->qtAbis().isEmpty()) { ProjectExplorer::Abi abi = qt4BuildConfiguration()->qtVersion()->qtAbis().first(); if (abi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor) { if (reason) @@ -342,13 +352,13 @@ bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const } } - if (!qt4BuildConfiguration()->qtVersion()->isValid()) { + if (!version->isValid()) { if (reason) *reason = tr("Invalid Qt version."); return false; } - if (qt4BuildConfiguration()->qtVersion()->qtVersion() < QtVersionNumber(4, 7, 1)) { + if (version->qtVersion() < QtVersionNumber(4, 7, 1)) { if (reason) *reason = tr("Requires Qt 4.7.1 or newer."); return false; @@ -467,9 +477,9 @@ void QMakeStepConfigWidget::qtVersionChanged() void QMakeStepConfigWidget::qmakeBuildConfigChanged() { Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration(); - bool debug = bc->qmakeBuildConfiguration() & QtVersion::DebugBuild; + bool debug = bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild; int index = debug ? 0 : 1; - if (bc->qmakeBuildConfiguration() & QtVersion::BuildAll) + if (bc->qmakeBuildConfiguration() & BaseQtVersion::BuildAll) index = 2; m_ignoreChange = true; m_ui.buildConfigurationComboBox->setCurrentIndex(index); @@ -515,16 +525,16 @@ void QMakeStepConfigWidget::buildConfigurationSelected() if (m_ignoreChange) return; Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration(); - QtVersion::QmakeBuildConfigs buildConfiguration = bc->qmakeBuildConfiguration(); + BaseQtVersion::QmakeBuildConfigs buildConfiguration = bc->qmakeBuildConfiguration(); switch (m_ui.buildConfigurationComboBox->currentIndex()) { case 0: - buildConfiguration = QtVersion::DebugBuild; + buildConfiguration = BaseQtVersion::DebugBuild; break; case 1: buildConfiguration = 0; break; case 2: - buildConfiguration = QtVersion::BuildAll; + buildConfiguration = BaseQtVersion::BuildAll; break; } @@ -552,7 +562,9 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) void QMakeStepConfigWidget::buildQmlDebuggingHelper() { - QtVersion *version = m_step->qt4BuildConfiguration()->qtVersion(); + BaseQtVersion *version = m_step->qt4BuildConfiguration()->qtVersion(); + if (!version) + return; DebuggingHelperBuildTask *buildTask = new DebuggingHelperBuildTask(version, DebuggingHelperBuildTask::QmlDebugging); @@ -568,10 +580,10 @@ void QMakeStepConfigWidget::buildQmlDebuggingHelper() void QMakeStepConfigWidget::debuggingHelperBuildFinished(int qtVersionId, const QString &output) { - QtVersion *version = QtVersionManager::instance()->version(qtVersionId); + BaseQtVersion *version = QtVersionManager::instance()->version(qtVersionId); if (!version) // qt version got deleted in between return; - version->invalidateCache(); + version->recheckDumper(); if (version == m_step->qt4BuildConfiguration()->qtVersion()) { m_ui.qmlDebuggingLibraryCheckBox->setChecked(m_step->linkQmlDebuggingLibrary()); @@ -591,7 +603,7 @@ void QMakeStepConfigWidget::debuggingHelperBuildFinished(int qtVersionId, const void QMakeStepConfigWidget::updateSummaryLabel() { Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration(); - const QtVersion *qtVersion = qt4bc->qtVersion(); + BaseQtVersion *qtVersion = qt4bc->qtVersion(); if (!qtVersion) { m_summaryText = tr("<b>qmake:</b> No Qt version set. Cannot run qmake."); emit updateSummary(); @@ -627,8 +639,10 @@ void QMakeStepConfigWidget::updateQmlDebuggingWarningsLabel() void QMakeStepConfigWidget::updateEffectiveQMakeCall() { Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration(); - const QtVersion *qtVersion = qt4bc->qtVersion(); - QString program = QFileInfo(qtVersion->qmakeCommand()).fileName(); + BaseQtVersion *qtVersion = qt4bc->qtVersion(); + QString program = tr("<No qtversion>"); + if (qtVersion) + program = QFileInfo(qtVersion->qmakeCommand()).fileName(); m_ui.qmakeArgumentsEdit->setPlainText(program + QLatin1Char(' ') + m_step->allArguments()); } diff --git a/src/plugins/qt4projectmanager/qmldebugginglibrary.cpp b/src/plugins/qt4projectmanager/qmldebugginglibrary.cpp index ae1d13e7b7..f296df8a0b 100644 --- a/src/plugins/qt4projectmanager/qmldebugginglibrary.cpp +++ b/src/plugins/qt4projectmanager/qmldebugginglibrary.cpp @@ -32,7 +32,7 @@ #include "qmldebugginglibrary.h" -#include "qt4project.h" +#include "baseqtversion.h" #include "qt4projectmanagerconstants.h" #include <coreplugin/icore.h> #include <utils/qtcassert.h> @@ -66,7 +66,7 @@ QString QmlDebuggingLibrary::libraryByInstallData(const QString &qtInstallData, return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames, false); } -bool QmlDebuggingLibrary::canBuild(const QtVersion *qtVersion) +bool QmlDebuggingLibrary::canBuild(const BaseQtVersion *qtVersion) { return qtVersion->qtVersion() >= QtVersionNumber(4, 7, 1); } diff --git a/src/plugins/qt4projectmanager/qmldebugginglibrary.h b/src/plugins/qt4projectmanager/qmldebugginglibrary.h index 41069d9b02..1710820583 100644 --- a/src/plugins/qt4projectmanager/qmldebugginglibrary.h +++ b/src/plugins/qt4projectmanager/qmldebugginglibrary.h @@ -48,15 +48,16 @@ namespace ProjectExplorer { namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; class QmlDebuggingLibrary : public Utils::BuildableHelperLibrary { public: static QString libraryByInstallData(const QString &qtInstallData, bool debugBuild); - static bool canBuild(const QtVersion *qtVersion); + static bool canBuild(const BaseQtVersion *qtVersion); static bool build(BuildHelperArguments arguments, QString *log, QString *errorMessage); + static QString copy(const QString &qtInstallData, QString *errorMessage); private: diff --git a/src/plugins/qt4projectmanager/qmldumptool.cpp b/src/plugins/qt4projectmanager/qmldumptool.cpp index 2b99c7c281..3cceedda5c 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.cpp +++ b/src/plugins/qt4projectmanager/qmldumptool.cpp @@ -35,6 +35,7 @@ #include "qt4projectmanagerconstants.h" #include "qtversionmanager.h" #include "debugginghelperbuildtask.h" + #include <coreplugin/icore.h> #include <coreplugin/progressmanager/progressmanager.h> @@ -66,7 +67,7 @@ class QmlDumpBuildTask : public QObject { Q_DISABLE_COPY(QmlDumpBuildTask) Q_OBJECT public: - explicit QmlDumpBuildTask(QtVersion *version) + explicit QmlDumpBuildTask(BaseQtVersion *version) : m_buildTask(new DebuggingHelperBuildTask(version, DebuggingHelperBuildTask::QmlDump)) , m_failed(false) { @@ -103,7 +104,7 @@ public: private slots: void finish(int qtId, const QString &output, DebuggingHelperBuildTask::Tools tools) { - QtVersion *version = QtVersionManager::instance()->version(qtId); + BaseQtVersion *version = QtVersionManager::instance()->version(qtId); QTC_ASSERT(tools == DebuggingHelperBuildTask::QmlDump, return); QString errorMessage; @@ -111,7 +112,7 @@ private slots: m_failed = true; errorMessage = QString::fromLatin1("Qt version became invalid"); } else { - version->invalidateCache(); + version->recheckDumper(); if (!version->hasQmlDump()) { m_failed = true; @@ -181,7 +182,7 @@ static bool hasPrivateHeaders(const QString &qtInstallHeaders) { return QFile::exists(header); } -bool QmlDumpTool::canBuild(const QtVersion *qtVersion) +bool QmlDumpTool::canBuild(const BaseQtVersion *qtVersion) { const QString installHeaders = qtVersion->versionInfo().value("QT_INSTALL_HEADERS"); @@ -191,14 +192,14 @@ bool QmlDumpTool::canBuild(const QtVersion *qtVersion) && hasPrivateHeaders(installHeaders); } -static QtVersion *qtVersionForProject(ProjectExplorer::Project *project) +static BaseQtVersion *qtVersionForProject(ProjectExplorer::Project *project) { if (project && project->id() == Qt4ProjectManager::Constants::QT4PROJECT_ID) { Qt4Project *qt4Project = static_cast<Qt4Project*>(project); if (qt4Project && qt4Project->activeTarget() && qt4Project->activeTarget()->activeBuildConfiguration()) { - QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); - if (version->isValid()) + BaseQtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); + if (version && version->isValid()) return version; } return 0; @@ -210,17 +211,18 @@ static QtVersion *qtVersionForProject(ProjectExplorer::Project *project) return 0; QVariant variant = project->activeTarget()->activeRunConfiguration()->property("qtVersionId"); QTC_ASSERT(variant.isValid() && variant.canConvert(QVariant::Int), return 0); - QtVersion *version = QtVersionManager::instance()->version(variant.toInt()); - if (version && version->isValid()) + BaseQtVersion *version = QtVersionManager::instance()->version(variant.toInt()); + if (version && version->isValid()) { return version; + } return 0; } // else, find any desktop or simulator Qt version that has qmldump, or // - if there isn't any - one that could build it - QtVersion *canBuildQmlDump = 0; + BaseQtVersion *canBuildQmlDump = 0; QtVersionManager *qtVersions = QtVersionManager::instance(); - foreach (QtVersion *version, qtVersions->validVersions()) { + foreach (BaseQtVersion *version, qtVersions->validVersions()) { if (version->supportsTargetId(Constants::DESKTOP_TARGET_ID) || version->supportsTargetId(Constants::QT_SIMULATOR_TARGET_ID)) { if (version->hasQmlDump()) @@ -237,7 +239,7 @@ static QtVersion *qtVersionForProject(ProjectExplorer::Project *project) QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project, bool debugDump) { - QtVersion *version = qtVersionForProject(project); + BaseQtVersion *version = qtVersionForProject(project); if (version) { QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); QString qtInstallHeaders = version->versionInfo().value("QT_INSTALL_HEADERS"); @@ -330,7 +332,7 @@ void QmlDumpTool::pathAndEnvironment(ProjectExplorer::Project *project, bool pre { QString path; - QtVersion *version = qtVersionForProject(project); + BaseQtVersion *version = qtVersionForProject(project); if (version && !version->hasQmlDump() && QmlDumpTool::canBuild(version)) { QmlDumpBuildTask *qmlDumpBuildTask = qmlDumpBuilds()->value(version->uniqueId()); if (qmlDumpBuildTask) { diff --git a/src/plugins/qt4projectmanager/qmldumptool.h b/src/plugins/qt4projectmanager/qmldumptool.h index 975d225c37..9d2e59ea29 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.h +++ b/src/plugins/qt4projectmanager/qmldumptool.h @@ -46,12 +46,12 @@ namespace ProjectExplorer { } namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrary { public: - static bool canBuild(const QtVersion *qtVersion); + static bool canBuild(const BaseQtVersion *qtVersion); static QString toolForProject(ProjectExplorer::Project *project, bool debugDump); static QString toolByInstallData(const QString &qtInstallData, const QString &qtInstallHeaders, bool debugDump); diff --git a/src/plugins/qt4projectmanager/qmlobservertool.cpp b/src/plugins/qt4projectmanager/qmlobservertool.cpp index 33c2314975..34268b85a4 100644 --- a/src/plugins/qt4projectmanager/qmlobservertool.cpp +++ b/src/plugins/qt4projectmanager/qmlobservertool.cpp @@ -34,6 +34,7 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" +#include "baseqtversion.h" #include <coreplugin/icore.h> #include <utils/qtcassert.h> @@ -54,7 +55,7 @@ static inline QStringList validBinaryFilenames() << QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver"); } -bool QmlObserverTool::canBuild(const QtVersion *qtVersion) +bool QmlObserverTool::canBuild(const BaseQtVersion *qtVersion) { return (qtVersion->supportsTargetId(Constants::DESKTOP_TARGET_ID) || qtVersion->supportsTargetId(Constants::QT_SIMULATOR_TARGET_ID)) @@ -67,8 +68,8 @@ QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project) Qt4Project *qt4Project = static_cast<Qt4Project*>(project); if (qt4Project && qt4Project->activeTarget() && qt4Project->activeTarget()->activeBuildConfiguration()) { - QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); - if (version->isValid()) { + BaseQtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); + if (version && version->isValid()) { QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); QString toolPath = toolByInstallData(qtInstallData); return toolPath; diff --git a/src/plugins/qt4projectmanager/qmlobservertool.h b/src/plugins/qt4projectmanager/qmlobservertool.h index 95a42eae13..78166bcb1f 100644 --- a/src/plugins/qt4projectmanager/qmlobservertool.h +++ b/src/plugins/qt4projectmanager/qmlobservertool.h @@ -48,12 +48,12 @@ namespace ProjectExplorer { namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary { public: - static bool canBuild(const QtVersion *qtVersion); + static bool canBuild(const BaseQtVersion *qtVersion); static QString toolForProject(ProjectExplorer::Project *project); static QString toolByInstallData(const QString &qtInstallData); static QStringList locationsByInstallData(const QString &qtInstallData); diff --git a/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.cpp b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.cpp new file mode 100644 index 0000000000..2c1d5c0a7b --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.cpp @@ -0,0 +1,119 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "desktopqtversion.h" +#include "qt4projectmanagerconstants.h" +#include "profileevaluator.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtCore/QFileInfoList> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +DesktopQtVersion::DesktopQtVersion() + : BaseQtVersion(), + m_qtAbisUpToDate(false) +{ + +} + +DesktopQtVersion::DesktopQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : BaseQtVersion(path, isAutodetected, autodetectionSource), + m_qtAbisUpToDate(false) +{ + +} + +DesktopQtVersion::~DesktopQtVersion() +{ + +} + +DesktopQtVersion *DesktopQtVersion::clone() const +{ + return new DesktopQtVersion(*this); +} + +QString DesktopQtVersion::type() const +{ + return Constants::DESKTOPQT; +} + +bool DesktopQtVersion::isValid() const +{ + if (!BaseQtVersion::isValid()) + return false; + if (qtAbis().isEmpty()) + return false; + return true; +} + +QString DesktopQtVersion::invalidReason() const +{ + QString tmp = BaseQtVersion::invalidReason(); + if (tmp.isEmpty() && qtAbis().isEmpty()) + return QCoreApplication::translate("QtVersion", "Failed to detect the ABI(s) used by the Qt version."); + return QString(); +} + +void DesktopQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const +{ + m_mingw = (evaluator->value("MAKEFILE_GENERATOR") == "MINGW"); + BaseQtVersion::parseMkSpec(evaluator); +} + +QList<ProjectExplorer::Abi> DesktopQtVersion::qtAbis() const +{ + if (!m_qtAbisUpToDate) { + m_qtAbisUpToDate = true; + ensureMkSpecParsed(); + m_qtAbis = qtAbisFromLibrary(qtCorePath(versionInfo(), qtVersionString()), m_mingw); + } + return m_qtAbis; +} + +bool DesktopQtVersion::supportsTargetId(const QString &id) const +{ + return id == QLatin1String(Constants::DESKTOP_TARGET_ID); +} + +QSet<QString> DesktopQtVersion::supportedTargetIds() const +{ + return QSet<QString>() << QLatin1String(Constants::DESKTOP_TARGET_ID); +} + +QString DesktopQtVersion::description() const +{ + return QCoreApplication::translate("QtVersion", "Desktop", "Qt Version is meant for the desktop"); +} diff --git a/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.h b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.h new file mode 100644 index 0000000000..86ba5d2fda --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversion.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef DESKTOPQTVERSION_H +#define DESKTOPQTVERSION_H + +#include "baseqtversion.h" + +namespace Qt4ProjectManager { + +namespace Internal { + +class DesktopQtVersion : public BaseQtVersion +{ +public: + DesktopQtVersion(); + DesktopQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + ~DesktopQtVersion(); + DesktopQtVersion *clone() const; + + virtual QString type() const; + + virtual bool isValid() const; + virtual QString invalidReason() const; + + virtual QList<ProjectExplorer::Abi> qtAbis() const; + + virtual bool supportsTargetId(const QString &id) const; + virtual QSet<QString> supportedTargetIds() const; + + QString description() const; +protected: + void parseMkSpec(ProFileEvaluator *) const; +private: + mutable bool m_qtAbisUpToDate; + mutable QList<ProjectExplorer::Abi> m_qtAbis; + mutable bool m_mingw; +}; + +} +} + +#endif // DESKTOPQTVERSION_H diff --git a/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.cpp new file mode 100644 index 0000000000..e8d5ab10c4 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.cpp @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#include "desktopqtversionfactory.h" +#include "qt4projectmanagerconstants.h" +#include "desktopqtversion.h" +#include "qtversionmanager.h" + +#include <projectexplorer/debugginghelper.h> + +#include <QtCore/QFileInfo> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +DesktopQtVersionFactory::DesktopQtVersionFactory(QObject *parent) + : QtVersionFactory(parent) +{ + +} + +DesktopQtVersionFactory::~DesktopQtVersionFactory() +{ + +} + +bool DesktopQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::DESKTOPQT); +} + +BaseQtVersion *DesktopQtVersionFactory::restore(const QVariantMap &data) +{ + DesktopQtVersion *v = new DesktopQtVersion; + v->fromMap(data); + return v; +} + +int DesktopQtVersionFactory::priority() const +{ + // Lowest of all, we want to be the fallback + return 0; +} + +BaseQtVersion *DesktopQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + Q_UNUSED(evaluator); + // we are the fallback :) so we don't care what kind of qt it is + QFileInfo fi(qmakePath); + if (fi.exists() && fi.isExecutable() && fi.isFile()) + return new DesktopQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + return 0; +} diff --git a/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.h b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.h new file mode 100644 index 0000000000..6a5bb746ae --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/desktopqtversionfactory.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef DESKTOPQTVERSIONFACTORY_H +#define DESKTOPQTVERSIONFACTORY_H + +#include "qtversionfactory.h" + +namespace Qt4ProjectManager{ +namespace Internal { + +class DesktopQtVersionFactory : public QtVersionFactory +{ +public: + explicit DesktopQtVersionFactory(QObject *parent = 0); + ~DesktopQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual BaseQtVersion *restore(const QVariantMap &data); + + virtual int priority() const; + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // Internal +} // Qt4ProjectManager + + +#endif // DESKTOPQTVERSIONFACTORY_H diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt-desktop.pri b/src/plugins/qt4projectmanager/qt-desktop/qt-desktop.pri index d002792d25..8f3fcfd8ef 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt-desktop.pri +++ b/src/plugins/qt4projectmanager/qt-desktop/qt-desktop.pri @@ -4,11 +4,19 @@ HEADERS += \ $$PWD/qt4desktoptargetfactory.h \ $$PWD/qt4simulatortargetfactory.h \ $$PWD/qt4desktoptarget.h \ - $$PWD/qt4simulatortarget.h + $$PWD/qt4simulatortarget.h \ + $$PWD/desktopqtversionfactory.h \ + $$PWD/simulatorqtversionfactory.h \ + $$PWD/desktopqtversion.h \ + $$PWD/simulatorqtversion.h SOURCES += \ $$PWD/qt4runconfiguration.cpp \ $$PWD/qt4desktoptargetfactory.cpp \ $$PWD/qt4simulatortargetfactory.cpp \ $$PWD/qt4desktoptarget.cpp \ - $$PWD/qt4simulatortarget.cpp + $$PWD/qt4simulatortarget.cpp \ + $$PWD/desktopqtversionfactory.cpp \ + $$PWD/simulatorqtversionfactory.cpp \ + $$PWD/desktopqtversion.cpp \ + $$PWD/simulatorqtversion.cpp diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp index 5c5101f413..f39540a61f 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4desktoptargetfactory.cpp @@ -142,16 +142,16 @@ ProjectExplorer::Target *Qt4DesktopTargetFactory::create(ProjectExplorer::Projec if (!canCreate(parent, id)) return 0; - QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); + QList<BaseQtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); if (knownVersions.isEmpty()) return 0; - QtVersion *qtVersion = knownVersions.first(); - QtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + BaseQtVersion *qtVersion = knownVersions.first(); + BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); QList<BuildConfigurationInfo> infos; infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtVersion::DebugBuild, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ BaseQtVersion::DebugBuild, QString(), QString())); return create(parent, id, infos); } diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp index 2ac8ff22b1..75eb37d6f6 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp @@ -42,6 +42,7 @@ #include "qtoutputformatter.h" #include "qt4desktoptarget.h" #include "qmakestep.h" +#include "baseqtversion.h" #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> @@ -660,7 +661,7 @@ QString Qt4RunConfiguration::proFilePath() const QString Qt4RunConfiguration::dumperLibrary() const { - QtVersion *version = qt4Target()->activeBuildConfiguration()->qtVersion(); + BaseQtVersion *version = qt4Target()->activeBuildConfiguration()->qtVersion(); if (version) return version->gdbDebuggingHelperLibrary(); return QString(); @@ -668,7 +669,7 @@ QString Qt4RunConfiguration::dumperLibrary() const QStringList Qt4RunConfiguration::dumperLibraryLocations() const { - QtVersion *version = qt4Target()->activeBuildConfiguration()->qtVersion(); + BaseQtVersion *version = qt4Target()->activeBuildConfiguration()->qtVersion(); if (version) return version->debuggingHelperLibraryLocations(); return QStringList(); diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp index 5c79b67cfe..266c09e287 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4simulatortargetfactory.cpp @@ -140,15 +140,15 @@ ProjectExplorer::Target *Qt4SimulatorTargetFactory::create(ProjectExplorer::Proj if (!canCreate(parent, id)) return 0; - QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); + QList<BaseQtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); if (knownVersions.isEmpty()) return 0; - QtVersion *qtVersion = knownVersions.first(); - QtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + BaseQtVersion *qtVersion = knownVersions.first(); + BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); QList<BuildConfigurationInfo> infos; infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtVersion::DebugBuild, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ BaseQtVersion::DebugBuild, QString(), QString())); return create(parent, id, infos); } diff --git a/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.cpp b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.cpp new file mode 100644 index 0000000000..9a69b47e0f --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.cpp @@ -0,0 +1,120 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "simulatorqtversion.h" +#include "qt4projectmanagerconstants.h" +#include "profileevaluator.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtCore/QFileInfoList> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +SimulatorQtVersion::SimulatorQtVersion() + : BaseQtVersion(), + m_qtAbisUpToDate(false) +{ + +} + +SimulatorQtVersion::SimulatorQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : BaseQtVersion(path, isAutodetected, autodetectionSource), + m_qtAbisUpToDate(false) +{ + +} + +SimulatorQtVersion::~SimulatorQtVersion() +{ + +} + +SimulatorQtVersion *SimulatorQtVersion::clone() const +{ + return new SimulatorQtVersion(*this); +} + +QString SimulatorQtVersion::type() const +{ + return Constants::SIMULATORQT; +} + +bool SimulatorQtVersion::isValid() const +{ + if (!BaseQtVersion::isValid()) + return false; + if (qtAbis().isEmpty()) + return false; + return true; +} + +QString SimulatorQtVersion::invalidReason() const +{ + QString tmp = BaseQtVersion::invalidReason(); + if (tmp.isEmpty() && qtAbis().isEmpty()) + return QCoreApplication::translate("QtVersion", "Failed to detect the ABI(s) used by the Qt version."); + return QString(); +} + +QList<ProjectExplorer::Abi> SimulatorQtVersion::qtAbis() const +{ + if (!m_qtAbisUpToDate) { + m_qtAbisUpToDate = true; + ensureMkSpecParsed(); + m_qtAbis = qtAbisFromLibrary(qtCorePath(versionInfo(), qtVersionString()), m_mingw); + } + return m_qtAbis; +} + +void SimulatorQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const +{ + m_mingw = (evaluator->value("MAKEFILE_GENERATOR") == "MINGW"); + BaseQtVersion::parseMkSpec(evaluator); +} + +bool SimulatorQtVersion::supportsTargetId(const QString &id) const +{ + return id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID); +} + +QSet<QString> SimulatorQtVersion::supportedTargetIds() const +{ + return QSet<QString>() << QLatin1String(Constants::QT_SIMULATOR_TARGET_ID); +} + +QString SimulatorQtVersion::description() const +{ + return QCoreApplication::translate("QtVersion", "Qt Simulator", "Qt Version is meant for Qt Simulator"); +} + diff --git a/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.h b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.h new file mode 100644 index 0000000000..3fafba7b6b --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversion.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef SIMULATORQTVERSION_H +#define SIMULATORQTVERSION_H + +#include "baseqtversion.h" + +namespace Qt4ProjectManager{ + +namespace Internal { + +class SimulatorQtVersion : public BaseQtVersion +{ +public: + SimulatorQtVersion(); + SimulatorQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + ~SimulatorQtVersion(); + SimulatorQtVersion *clone() const; + + virtual QString type() const; + + virtual bool isValid() const; + virtual QString invalidReason() const; + + virtual QList<ProjectExplorer::Abi> qtAbis() const; + + virtual bool supportsTargetId(const QString &id) const; + virtual QSet<QString> supportedTargetIds() const; + + QString description() const; +protected: + void parseMkSpec(ProFileEvaluator *evaluator) const; +private: + mutable bool m_qtAbisUpToDate; + mutable QList<ProjectExplorer::Abi> m_qtAbis; + mutable bool m_mingw; +}; + +} +} + +#endif // SIMULATORQTVERSION_H diff --git a/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.cpp b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.cpp new file mode 100644 index 0000000000..9d59066fbc --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.cpp @@ -0,0 +1,82 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "simulatorqtversionfactory.h" +#include "qt4projectmanagerconstants.h" +#include "simulatorqtversion.h" + +#include <QtCore/QFileInfo> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +SimulatorQtVersionFactory::SimulatorQtVersionFactory(QObject *parent) + : QtVersionFactory(parent) +{ + +} + +SimulatorQtVersionFactory::~SimulatorQtVersionFactory() +{ + +} + +bool SimulatorQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::SIMULATORQT); +} + +BaseQtVersion *SimulatorQtVersionFactory::restore(const QVariantMap &data) +{ + BaseQtVersion *v = new SimulatorQtVersion; + v->fromMap(data); + return v; +} + + +int SimulatorQtVersionFactory::priority() const +{ + return 50; +} + +BaseQtVersion *SimulatorQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + QFileInfo fi(qmakePath); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return 0; + + QStringList configValues = evaluator->values("CONFIG"); + if (!configValues.contains(QLatin1String("simulator"))) + return 0; + + return new SimulatorQtVersion(qmakePath, isAutoDetected, autoDetectionSource); +} diff --git a/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.h b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.h new file mode 100644 index 0000000000..d6685d33b3 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-desktop/simulatorqtversionfactory.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef SIMULATORQTVERSIONFACTORY_H +#define SIMULATORQTVERSIONFACTORY_H + +#include "qtversionfactory.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class SimulatorQtVersionFactory : public QtVersionFactory +{ +public: + explicit SimulatorQtVersionFactory(QObject *parent = 0); + ~SimulatorQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual BaseQtVersion *restore(const QVariantMap &data); + + virtual int priority() const; + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // Internal +} // Qt4ProjectManager + + +#endif // SIMULATORQTVERSIONFACTORY_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp index 5ea7f4732c..fb885f3bd1 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp @@ -68,7 +68,8 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC } if (debuggingType != MaemoRunConfiguration::DebugQmlOnly) { params.processArgs = runConfig->arguments(); - params.sysRoot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot(); + if (runConfig->activeQt4BuildConfiguration()->qtVersion()) + params.sysRoot = runConfig->activeQt4BuildConfiguration()->qtVersion()->systemRoot(); params.toolChainAbi = runConfig->abi(); if (runConfig->useRemoteGdb()) { params.startMode = StartRemoteGdb; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp index 2e5fe20c6d..9ea292f176 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.cpp @@ -41,6 +41,7 @@ #include <projectexplorer/session.h> #include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4target.h> +#include <qt4projectmanager/baseqtversion.h> #include <utils/qtcassert.h> #include <utils/fileutils.h> @@ -244,10 +245,10 @@ bool MaemoDeployableListModel::addDesktopFile() return false; } - const QtVersion * const version = qtVersion(); + const BaseQtVersion * const version = qtVersion(); QTC_ASSERT(version, return false); QString remoteDir = QLatin1String("/usr/share/applications"); - if (MaemoGlobal::version(version) == MaemoDeviceConfig::Maemo5) + if (MaemoGlobal::version(version->qmakeCommand()) == MaemoDeviceConfig::Maemo5) remoteDir += QLatin1String("/hildon"); const QLatin1String filesLine("desktopfile.files = $${TARGET}.desktop"); const QString pathLine = QLatin1String("desktopfile.path = ") + remoteDir; @@ -311,7 +312,7 @@ bool MaemoDeployableListModel::addLinesToProFile(const QStringList &lines) return saver.finalize(Core::ICore::instance()->mainWindow()); } -const QtVersion *MaemoDeployableListModel::qtVersion() const +const BaseQtVersion *MaemoDeployableListModel::qtVersion() const { const ProjectExplorer::Project *const activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->startupProject(); @@ -327,9 +328,9 @@ const QtVersion *MaemoDeployableListModel::qtVersion() const QString MaemoDeployableListModel::proFileScope() const { - const QtVersion *const qv = qtVersion(); + const BaseQtVersion *const qv = qtVersion(); QTC_ASSERT(qv, return QString()); - return QLatin1String(MaemoGlobal::version(qv) == MaemoDeviceConfig::Maemo5 + return QLatin1String(MaemoGlobal::version(qv->qmakeCommand()) == MaemoDeviceConfig::Maemo5 ? "maemo5" : "unix:!symbian:!maemo5"); } @@ -340,10 +341,10 @@ QString MaemoDeployableListModel::installPrefix() const QString MaemoDeployableListModel::remoteIconDir() const { - const QtVersion *const qv = qtVersion(); + const BaseQtVersion *const qv = qtVersion(); QTC_ASSERT(qv, return QString()); return QString::fromLocal8Bit("/usr/share/icons/hicolor/%1x%1/apps") - .arg(MaemoGlobal::applicationIconSize(MaemoGlobal::version(qv))); + .arg(MaemoGlobal::applicationIconSize(MaemoGlobal::version(qv->qmakeCommand()))); } } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h index 086bec5316..8d04026e77 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployablelistmodel.h @@ -44,7 +44,7 @@ #include <QtCore/QString> namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { class MaemoDeployableListModel : public QAbstractTableModel @@ -64,7 +64,7 @@ public: MaemoDeployable deployableAt(int row) const; bool isModified() const { return m_modified; } void setUnModified() { m_modified = false; } - const QtVersion *qtVersion() const; + const BaseQtVersion *qtVersion() const; QString localExecutableFilePath() const; QString remoteExecutableFilePath() const; QString projectName() const { return m_projectName; } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeployconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeployconfigurationwidget.cpp index eb3c3501ed..803e556789 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeployconfigurationwidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeployconfigurationwidget.cpp @@ -37,6 +37,7 @@ #include "maemodeployables.h" #include "qt4maemodeployconfiguration.h" +#include <qt4projectmanager/qtversionmanager.h> #include <utils/qtcassert.h> #include <QtGui/QFileDialog> @@ -137,7 +138,7 @@ void MaemoDeployConfigurationWidget::addIcon() MaemoDeployableListModel *const model = m_deployConfig->deployables()->modelAt(modelRow); - const int iconDim = MaemoGlobal::applicationIconSize(MaemoGlobal::version(model->qtVersion())); + const int iconDim = MaemoGlobal::applicationIconSize(MaemoGlobal::version(model->qtVersion()->qmakeCommand())); const QString origFilePath = QFileDialog::getOpenFileName(this, tr("Choose Icon (will be scaled to %1x%1 pixels, if necessary)").arg(iconDim), model->projectDir(), QLatin1String("(*.png)")); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.cpp index e908c6f4f2..70d5a270cf 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.cpp @@ -76,35 +76,35 @@ bool MaemoGlobal::isMeegoTargetId(const QString &id) return id == QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID); } -bool MaemoGlobal::isValidMaemo5QtVersion(const QtVersion *version) +bool MaemoGlobal::isValidMaemo5QtVersion(const QString &qmakePath) { - return isValidMaemoQtVersion(version, MaemoDeviceConfig::Maemo5); + return isValidMaemoQtVersion(qmakePath, MaemoDeviceConfig::Maemo5); } -bool MaemoGlobal::isValidHarmattanQtVersion(const QtVersion *version) +bool MaemoGlobal::isValidHarmattanQtVersion(const QString &qmakePath) { - return isValidMaemoQtVersion(version, MaemoDeviceConfig::Maemo6); + return isValidMaemoQtVersion(qmakePath, MaemoDeviceConfig::Maemo6); } -bool MaemoGlobal::isValidMeegoQtVersion(const Qt4ProjectManager::QtVersion *version) +bool MaemoGlobal::isValidMeegoQtVersion(const QString &qmakePath) { - return isValidMaemoQtVersion(version, MaemoDeviceConfig::Meego); + return isValidMaemoQtVersion(qmakePath, MaemoDeviceConfig::Meego); } -bool MaemoGlobal::isValidMaemoQtVersion(const QtVersion *qtVersion, +bool MaemoGlobal::isValidMaemoQtVersion(const QString &qmakePath, MaemoDeviceConfig::OsVersion maemoVersion) { - if (version(qtVersion) != maemoVersion) + if (version(qmakePath) != maemoVersion) return false; QProcess madAdminProc; const QStringList arguments(QLatin1String("list")); - if (!callMadAdmin(madAdminProc, arguments, qtVersion, false)) + if (!callMadAdmin(madAdminProc, arguments, qmakePath, false)) return false; if (!madAdminProc.waitForStarted() || !madAdminProc.waitForFinished()) return false; madAdminProc.setReadChannel(QProcess::StandardOutput); - const QByteArray tgtName = targetName(qtVersion).toAscii(); + const QByteArray tgtName = targetName(qmakePath).toAscii(); while (madAdminProc.canReadLine()) { const QByteArray &line = madAdminProc.readLine(); if (line.contains(tgtName) @@ -199,9 +199,9 @@ QString MaemoGlobal::deviceConfigurationName(const MaemoDeviceConfig::ConstPtr & } MaemoPortList MaemoGlobal::freePorts(const MaemoDeviceConfig::ConstPtr &devConf, - const QtVersion *qtVersion) + const BaseQtVersion *qtVersion) { - if (!devConf) + if (!devConf || !qtVersion) return MaemoPortList(); if (devConf->type() == MaemoDeviceConfig::Emulator) { MaemoQemuRuntime rt; @@ -212,31 +212,31 @@ MaemoPortList MaemoGlobal::freePorts(const MaemoDeviceConfig::ConstPtr &devConf, return devConf->freePorts(); } -QString MaemoGlobal::maddeRoot(const QtVersion *qtVersion) +QString MaemoGlobal::maddeRoot(const QString &qmakePath) { - QDir dir(targetRoot(qtVersion)); + QDir dir(targetRoot(qmakePath)); dir.cdUp(); dir.cdUp(); return dir.absolutePath(); } -QString MaemoGlobal::targetRoot(const QtVersion *qtVersion) +QString MaemoGlobal::targetRoot(const QString &qmakePath) { - return QDir::cleanPath(qtVersion->qmakeCommand()).remove(binQmake); + return QDir::cleanPath(qmakePath).remove(binQmake); } -QString MaemoGlobal::targetName(const QtVersion *qtVersion) +QString MaemoGlobal::targetName(const QString &qmakePath) { - return QDir(targetRoot(qtVersion)).dirName(); + return QDir(targetRoot(qmakePath)).dirName(); } -QString MaemoGlobal::madAdminCommand(const QtVersion *qtVersion) +QString MaemoGlobal::madAdminCommand(const QString &qmakePath) { - return maddeRoot(qtVersion) + QLatin1String("/bin/mad-admin"); + return maddeRoot(qmakePath) + QLatin1String("/bin/mad-admin"); } -QString MaemoGlobal::madCommand(const QtVersion *qtVersion) +QString MaemoGlobal::madCommand(const QString &qmakePath) { - return maddeRoot(qtVersion) + QLatin1String("/bin/mad"); + return maddeRoot(qmakePath) + QLatin1String("/bin/mad"); } QString MaemoGlobal::madDeveloperUiName(MaemoDeviceConfig::OsVersion osVersion) @@ -245,9 +245,9 @@ QString MaemoGlobal::madDeveloperUiName(MaemoDeviceConfig::OsVersion osVersion) ? tr("SDK Connectivity") : tr("Mad Developer"); } -MaemoDeviceConfig::OsVersion MaemoGlobal::version(const QtVersion *qtVersion) +MaemoDeviceConfig::OsVersion MaemoGlobal::version(const QString &qmakePath) { - const QString &name = targetName(qtVersion); + const QString &name = targetName(qmakePath); if (name.startsWith(QLatin1String("fremantle"))) return MaemoDeviceConfig::Maemo5; if (name.startsWith(QLatin1String("harmattan"))) @@ -257,12 +257,12 @@ MaemoDeviceConfig::OsVersion MaemoGlobal::version(const QtVersion *qtVersion) return static_cast<MaemoDeviceConfig::OsVersion>(-1); } -QString MaemoGlobal::architecture(const QtVersion *qtVersion) +QString MaemoGlobal::architecture(const QString &qmakePath) { QProcess proc; const QStringList args = QStringList() << QLatin1String("uname") << QLatin1String("-m"); - if (!callMad(proc, args, qtVersion, true)) + if (!callMad(proc, args, qmakePath, true)) return QString(); if (!proc.waitForFinished()) return QString(); @@ -359,30 +359,30 @@ bool MaemoGlobal::isFileNewerThan(const QString &filePath, } bool MaemoGlobal::callMad(QProcess &proc, const QStringList &args, - const QtVersion *qtVersion, bool useTarget) + const QString &qmakePath, bool useTarget) { - return callMaddeShellScript(proc, qtVersion, madCommand(qtVersion), args, + return callMaddeShellScript(proc, qmakePath, madCommand(qmakePath), args, useTarget); } bool MaemoGlobal::callMadAdmin(QProcess &proc, const QStringList &args, - const QtVersion *qtVersion, bool useTarget) + const QString &qmakePath, bool useTarget) { - return callMaddeShellScript(proc, qtVersion, madAdminCommand(qtVersion), + return callMaddeShellScript(proc, qmakePath, madAdminCommand(qmakePath), args, useTarget); } bool MaemoGlobal::callMaddeShellScript(QProcess &proc, - const QtVersion *qtVersion, const QString &command, const QStringList &args, + const QString &qmakePath, const QString &command, const QStringList &args, bool useTarget) { if (!QFileInfo(command).exists()) return false; QString actualCommand = command; - QStringList actualArgs = targetArgs(qtVersion, useTarget) + args; + QStringList actualArgs = targetArgs(qmakePath, useTarget) + args; #ifdef Q_OS_WIN Utils::Environment env(proc.systemEnvironment()); - const QString root = maddeRoot(qtVersion); + const QString root = maddeRoot(qmakePath); env.prependOrSetPath(root + QLatin1String("/bin")); env.prependOrSet(QLatin1String("HOME"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); @@ -394,11 +394,11 @@ bool MaemoGlobal::callMaddeShellScript(QProcess &proc, return true; } -QStringList MaemoGlobal::targetArgs(const QtVersion *qtVersion, bool useTarget) +QStringList MaemoGlobal::targetArgs(const QString &qmakePath, bool useTarget) { QStringList args; if (useTarget) { - args << QLatin1String("-t") << targetName(qtVersion); + args << QLatin1String("-t") << targetName(qmakePath); } return args; } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h index c98e7a67e0..6f229bdb98 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h @@ -56,7 +56,7 @@ QT_END_NAMESPACE namespace Utils { class SshConnection; } namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { class MaemoGlobal @@ -69,9 +69,9 @@ public: static bool isFremantleTargetId(const QString &id); static bool isHarmattanTargetId(const QString &id); static bool isMeegoTargetId(const QString &id); - static bool isValidMaemo5QtVersion(const Qt4ProjectManager::QtVersion *version); - static bool isValidHarmattanQtVersion(const Qt4ProjectManager::QtVersion *version); - static bool isValidMeegoQtVersion(const Qt4ProjectManager::QtVersion *version); + static bool isValidMaemo5QtVersion(const QString &qmakePath); + static bool isValidHarmattanQtVersion(const QString &qmakePath); + static bool isValidMeegoQtVersion(const QString &qmakePath); static QString homeDirOnDevice(const QString &uname); static QString devrootshPath(); @@ -86,22 +86,22 @@ public: const QSharedPointer<const MaemoDeviceConfig> &deviceConfig); static QString deviceConfigurationName(const QSharedPointer<const MaemoDeviceConfig> &devConf); static MaemoPortList freePorts(const QSharedPointer<const MaemoDeviceConfig> &devConf, - const QtVersion *qtVersion); + const BaseQtVersion *qtVersion); - static QString maddeRoot(const QtVersion *qtVersion); - static QString targetRoot(const QtVersion *qtVersion); - static QString targetName(const QtVersion *qtVersion); - static QString madCommand(const QtVersion *qtVersion); + static QString maddeRoot(const QString &qmakePath); + static QString targetRoot(const QString &qmakePath); + static QString targetName(const QString &qmakePath); + static QString madCommand(const QString &qmakePath); static QString madDeveloperUiName(MaemoDeviceConfig::OsVersion maemoVersion); - static MaemoDeviceConfig::OsVersion version(const QtVersion *qtVersion); + static MaemoDeviceConfig::OsVersion version(const QString &qmakePath); // TODO: IS this still needed with Qt Version having an Abi? - static QString architecture(const QtVersion *version); + static QString architecture(const QString &qmakePath); static bool callMad(QProcess &proc, const QStringList &args, - const QtVersion *qtVersion, bool useTarget); + const QString &qmakePath, bool useTarget); static bool callMadAdmin(QProcess &proc, const QStringList &args, - const QtVersion *qtVersion, bool useTarget); + const QString &qmakePath, bool useTarget); static QString osVersionToString(MaemoDeviceConfig::OsVersion version); @@ -146,12 +146,12 @@ public: } private: - static bool isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *qtVersion, + static bool isValidMaemoQtVersion(const QString &qmakePath, MaemoDeviceConfig::OsVersion maemoVersion); - static QString madAdminCommand(const QtVersion *qtVersion); - static bool callMaddeShellScript(QProcess &proc, const QtVersion *qtVersion, + static QString madAdminCommand(const QString &qmakePath); + static bool callMaddeShellScript(QProcess &proc, const QString &qmakePath, const QString &command, const QStringList &args, bool useTarget); - static QStringList targetArgs(const QtVersion *qtVersion, bool useTarget); + static QStringList targetArgs(const QString &qmakePath, bool useTarget); }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoinstalltosysrootstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoinstalltosysrootstep.cpp index a43e4181b5..c0ad0dcfcb 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoinstalltosysrootstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoinstalltosysrootstep.cpp @@ -37,6 +37,7 @@ #include "maemopackagecreationstep.h" #include "maemotoolchain.h" #include "qt4maemodeployconfiguration.h" +#include "baseqtversion.h" #include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4target.h> @@ -166,6 +167,13 @@ void AbstractMaemoInstallPackageToSysrootStep::run(QFutureInterface<bool> &fi) return; } + if (!bc->qtVersion()) { + addOutput(tr("Can't install package to sysroot without a qt version."), + ErrorMessageOutput); + fi.reportResult(false); + return; + } + m_installerProcess = new QProcess; connect(m_installerProcess, SIGNAL(readyReadStandardOutput()), SLOT(handleInstallerStdout())); @@ -173,11 +181,11 @@ void AbstractMaemoInstallPackageToSysrootStep::run(QFutureInterface<bool> &fi) SLOT(handleInstallerStderr())); emit addOutput(tr("Installing package to sysroot ..."), MessageOutput); - const QtVersion * const qtVersion = bc->qtVersion(); + const BaseQtVersion * const qtVersion = bc->qtVersion(); const QString packageFilePath = pStep->packageFilePath(); const int packageFileSize = QFileInfo(packageFilePath).size() / (1024*1024); const QStringList args = madArguments() << packageFilePath; - MaemoGlobal::callMadAdmin(*m_installerProcess, args, qtVersion, true); + MaemoGlobal::callMadAdmin(*m_installerProcess, args, qtVersion->qmakeCommand(), true); if (!m_installerProcess->waitForFinished((2*packageFileSize + 10)*1000) || m_installerProcess->exitStatus() != QProcess::NormalExit || m_installerProcess->exitCode() != 0) { @@ -362,16 +370,16 @@ bool MaemoMakeInstallToSysrootStep::init() ErrorMessageOutput); return false; } - const QtVersion * const qtVersion = bc->qtVersion(); + const BaseQtVersion * const qtVersion = bc->qtVersion(); if (!qtVersion) { addOutput("Can't deploy: Unusable build configuration.", ErrorMessageOutput); return false; } - processParameters()->setCommand(MaemoGlobal::madCommand(qtVersion)); + processParameters()->setCommand(MaemoGlobal::madCommand(qtVersion->qmakeCommand())); const QStringList args = QStringList() << QLatin1String("-t") - << MaemoGlobal::targetName(qtVersion) << QLatin1String("make") + << MaemoGlobal::targetName(qtVersion->qmakeCommand()) << QLatin1String("make") << QLatin1String("install") << (QLatin1String("INSTALL_ROOT=") + qtVersion->systemRoot()); processParameters()->setArguments(args.join(QLatin1String(" "))); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp index 69f9cbf992..313262dab1 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp @@ -44,6 +44,7 @@ #include "maemosettingspages.h" #include "maemotoolchain.h" #include "qt4maemodeployconfiguration.h" +#include "maemoqtversionfactory.h" #include "qt4maemotargetfactory.h" #include "qt4projectmanager/qtversionmanager.h" #include "qt4projectmanager/qt4projectmanagerconstants.h" @@ -74,6 +75,7 @@ MaemoManager::MaemoManager() , m_publishingFactoryFremantleFree(new MaemoPublishingWizardFactoryFremantleFree(this)) , m_maemoTargetFactory(new Qt4MaemoTargetFactory(this)) , m_toolChainFactory(new MaemoToolChainFactory) + , m_maemoQtVersionFactory(new MaemoQtVersionFactory(this)) { Q_ASSERT(!m_instance); @@ -92,6 +94,7 @@ MaemoManager::MaemoManager() pluginManager->addObject(m_qemuSettingsPage); pluginManager->addObject(m_publishingFactoryFremantleFree); pluginManager->addObject(m_maemoTargetFactory); + pluginManager->addObject(m_maemoQtVersionFactory); qRegisterMetaType<MaemoDeployable>("MaemoDeployable"); } @@ -99,6 +102,7 @@ MaemoManager::MaemoManager() MaemoManager::~MaemoManager() { PluginManager *pluginManager = PluginManager::instance(); + pluginManager->removeObject(m_maemoQtVersionFactory); pluginManager->removeObject(m_maemoTargetFactory); pluginManager->removeObject(m_publishingFactoryFremantleFree); pluginManager->removeObject(m_qemuSettingsPage); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h index 7ede720919..0c14f04094 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h @@ -36,7 +36,6 @@ #include <QtCore/QObject> namespace Qt4ProjectManager { - class QtVersion; namespace Internal { class MaemoDeployStepFactory; @@ -50,6 +49,7 @@ class MaemoQemuSettingsPage; class Qt4MaemoDeployConfigurationFactory; class Qt4MaemoTargetFactory; class MaemoToolChainFactory; +class MaemoQtVersionFactory; class MaemoManager : public QObject { @@ -77,6 +77,7 @@ private: MaemoPublishingWizardFactoryFremantleFree *m_publishingFactoryFremantleFree; Qt4MaemoTargetFactory *m_maemoTargetFactory; MaemoToolChainFactory *m_toolChainFactory; + MaemoQtVersionFactory *m_maemoQtVersionFactory; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index 1c679962a9..3a3853e002 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -255,13 +255,17 @@ bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc, const QStringList &arguments) { preparePackagingProcess(proc, qt4BuildConfiguration(), buildDirectory()); - const QtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion(); - const QString madCommand = MaemoGlobal::madCommand(qtVersion); + const BaseQtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion(); + if (!qtVersion) { + raiseError(tr("Packaging failed."), tr("Packaging error: No qt version.")); + return false; + } + const QString madCommand = MaemoGlobal::madCommand(qtVersion->qmakeCommand()); const QString cmdLine = madCommand + QLatin1Char(' ') + arguments.join(QLatin1String(" ")); emit addOutput(tr("Package Creation: Running command '%1'.").arg(cmdLine), BuildStep::MessageOutput); - MaemoGlobal::callMad(*proc, arguments, qtVersion, true); + MaemoGlobal::callMad(*proc, arguments, qtVersion->qmakeCommand(), true); if (!proc->waitForStarted()) { raiseError(tr("Packaging failed."), tr("Packaging error: Could not start command '%1'. Reason: %2") @@ -287,7 +291,7 @@ void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc, const Qt4BuildConfiguration *bc, const QString &workingDir) { Utils::Environment env = bc->environment(); - if (bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) { + if (bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) { env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"), QLatin1String("nostrip"), QLatin1String(" ")); } @@ -466,7 +470,8 @@ QString MaemoDebianPackageCreationStep::packagingCommand(const Qt4BuildConfigura const QString &commandName) { QString perl; - const QString maddeRoot = MaemoGlobal::maddeRoot(bc->qtVersion()); + BaseQtVersion *v = bc->qtVersion(); + const QString maddeRoot = MaemoGlobal::maddeRoot(v->qmakeCommand()); #ifdef Q_OS_WIN perl = maddeRoot + QLatin1String("/bin/perl.exe "); #endif @@ -504,8 +509,12 @@ bool MaemoDebianPackageCreationStep::adaptRulesFile( + QLatin1Char('/') + maemoTarget()->packageName() + QLatin1String("/usr/share/applications/"); const Qt4BuildConfiguration * const bc = qt4BuildConfiguration(); + + const BaseQtVersion *const lqt = bc->qtVersion(); + if (!lqt) + return false; const MaemoDeviceConfig::OsVersion version - = MaemoGlobal::version(bc->qtVersion()); + = MaemoGlobal::version(lqt->qmakeCommand()); if (version == MaemoDeviceConfig::Maemo5) desktopFileDir += QLatin1String("hildon/"); #ifdef Q_OS_WIN @@ -537,7 +546,7 @@ bool MaemoDebianPackageCreationStep::adaptRulesFile( } // Always check for dependencies in release builds. - if (!(bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)) + if (!(bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild)) ensureShlibdeps(content); Utils::FileSaver saver(rulesFilePath); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopublisherfremantlefree.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopublisherfremantlefree.cpp index 94a828c1c7..42757776b5 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopublisherfremantlefree.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopublisherfremantlefree.cpp @@ -37,6 +37,7 @@ #include "maemopublishingfileselectiondialog.h" #include "qt4maemodeployconfiguration.h" #include "qt4maemotarget.h" +#include "baseqtversion.h" #include <coreplugin/ifile.h> #include <projectexplorer/project.h> @@ -363,13 +364,17 @@ void MaemoPublisherFremantleFree::runDpkgBuildPackage() } } + BaseQtVersion *lqt = m_buildConfig->qtVersion(); + if (!lqt) + finishWithFailure(QString(), tr("No qt version set")); + if (m_state == Inactive) return; setState(BuildingPackage); emit progressReport(tr("Building source package...")); const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage") << QLatin1String("-S") << QLatin1String("-us") << QLatin1String("-uc"); - MaemoGlobal::callMad(*m_process, args, m_buildConfig->qtVersion(), true); + MaemoGlobal::callMad(*m_process, args, lqt->qmakeCommand(), true); } // We have to implement the SCP protocol, because the maemo.org diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopublishingbuildsettingspagefremantlefree.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopublishingbuildsettingspagefremantlefree.cpp index 8481645a70..ce144a460d 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopublishingbuildsettingspagefremantlefree.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopublishingbuildsettingspagefremantlefree.cpp @@ -39,6 +39,7 @@ #include <projectexplorer/target.h> #include <qt4projectmanager/qt4buildconfiguration.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> +#include <qt4projectmanager/baseqtversion.h> #include <utils/qtcassert.h> using namespace ProjectExplorer; @@ -79,7 +80,11 @@ void MaemoPublishingBuildSettingsPageFremantleFree::collectBuildConfigurations(c = qobject_cast<Qt4BuildConfiguration *>(bc); if (!qt4Bc) continue; - if (MaemoGlobal::version(qt4Bc->qtVersion()) == MaemoDeviceConfig::Maemo5) + + BaseQtVersion *lqt = qt4Bc->qtVersion(); + if (!lqt) + continue; + if (MaemoGlobal::version(lqt->qmakeCommand()) == MaemoDeviceConfig::Maemo5) m_buildConfigs << qt4Bc; } break; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopublishingwizardfactories.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopublishingwizardfactories.cpp index 4d75ab204e..fc86d22c73 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopublishingwizardfactories.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopublishingwizardfactories.cpp @@ -33,6 +33,7 @@ #include "maemoglobal.h" #include "maemopublishingwizardfremantlefree.h" +#include "baseqtversion.h" #include <projectexplorer/target.h> #include <qt4projectmanager/qmakestep.h> @@ -76,7 +77,11 @@ bool MaemoPublishingWizardFactoryFremantleFree::canCreateWizard(const Project *p = qobject_cast<const Qt4BuildConfiguration *>(bc); if (!qt4Bc) continue; - if (MaemoGlobal::version(qt4Bc->qtVersion()) == MaemoDeviceConfig::Maemo5) + + BaseQtVersion *qt = qt4Bc->qtVersion(); + if (!qt) + continue; + if (MaemoGlobal::version(qt->qmakeCommand()) == MaemoDeviceConfig::Maemo5) return true; } break; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.cpp index ca38b74ad6..bdbf41a8be 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.cpp @@ -41,6 +41,7 @@ #include "qt4project.h" #include "qt4projectmanagerconstants.h" #include "qt4maemotarget.h" +#include "maemoqtversion.h" #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> @@ -180,10 +181,9 @@ void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds) QtVersionManager *manager = QtVersionManager::instance(); foreach (int uniqueId, uniqueIds) { if (manager->isValidId(uniqueId)) { - QtVersion *version = manager->version(uniqueId); - if (version->supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) - || version->supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID) - || version->supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) { + MaemoQtVersion *version = dynamic_cast<MaemoQtVersion *>(manager->version(uniqueId)); + + if (version) { MaemoQemuRuntime runtime = MaemoQemuRuntimeParser::parseRuntime(version); if (runtime.isValid()) { @@ -370,7 +370,7 @@ void MaemoQemuManager::startRuntime() Project *p = ProjectExplorerPlugin::instance()->session()->startupProject(); if (!p) return; - QtVersion *version; + BaseQtVersion *version; if (!targetUsesMatchingRuntimeConfig(p->activeTarget(), &version)) { qWarning("Strange: Qemu button was enabled, but target does not match."); return; @@ -530,7 +530,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target) if (target) { if (AbstractQt4MaemoTarget *qt4Target = qobject_cast<AbstractQt4MaemoTarget*>(target)) { if (Qt4BuildConfiguration *bc = qt4Target->activeBuildConfiguration()) { - if (QtVersion *version = bc->qtVersion()) + if (BaseQtVersion *version = bc->qtVersion()) uniqueId = version->uniqueId(); } } @@ -567,7 +567,7 @@ bool MaemoQemuManager::sessionHasMaemoTarget() const } bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target, - QtVersion **qtVersion) + BaseQtVersion **qtVersion) { if (!target) return false; @@ -582,7 +582,7 @@ bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target, = qobject_cast<Qt4BuildConfiguration *>(target->activeBuildConfiguration()); if (!bc) return false; - QtVersion *version = bc->qtVersion(); + BaseQtVersion *version = bc->qtVersion(); if (!version || !m_runtimes.value(version->uniqueId(), MaemoQemuRuntime()).isValid()) return false; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.h b/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.h index 9ee4c02b14..b4e9214549 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqemumanager.h @@ -57,7 +57,7 @@ namespace ProjectExplorer { } namespace Qt4ProjectManager { - class QtVersion; + class BaseQtVersion; namespace Internal { class MaemoRunConfiguration; @@ -117,7 +117,7 @@ private: void updateStarterIcon(bool running); void toggleStarterButton(ProjectExplorer::Target *target); bool targetUsesMatchingRuntimeConfig(ProjectExplorer::Target *target, - QtVersion **qtVersion = 0); + BaseQtVersion **qtVersion = 0); void notify(const QList<int> uniqueIds); void toggleDeviceConnections(MaemoRunConfiguration *mrc, bool connect); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp index 09e415f25e..c66f3d38bc 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.cpp @@ -33,6 +33,7 @@ #include "maemoglobal.h" #include "maemoqemusettings.h" +#include "baseqtversion.h" #include <qt4projectmanager/qtversionmanager.h> #include <utils/qtcassert.h> @@ -88,17 +89,17 @@ MaemoQemuRuntimeParser::MaemoQemuRuntimeParser(const QString &madInfoOutput, { } -MaemoQemuRuntime MaemoQemuRuntimeParser::parseRuntime(const QtVersion *qtVersion) +MaemoQemuRuntime MaemoQemuRuntimeParser::parseRuntime(const BaseQtVersion *qtVersion) { MaemoQemuRuntime runtime; - const QString maddeRootPath = MaemoGlobal::maddeRoot(qtVersion); + const QString maddeRootPath = MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()); QProcess madProc; - if (!MaemoGlobal::callMad(madProc, QStringList() << QLatin1String("info"), qtVersion, false)) + if (!MaemoGlobal::callMad(madProc, QStringList() << QLatin1String("info"), qtVersion->qmakeCommand(), false)) return runtime; if (!madProc.waitForStarted() || !madProc.waitForFinished()) return runtime; const QByteArray &madInfoOutput = madProc.readAllStandardOutput(); - const QString &targetName = MaemoGlobal::targetName(qtVersion); + const QString &targetName = MaemoGlobal::targetName(qtVersion->qmakeCommand()); runtime = MaemoQemuRuntimeParserV2(madInfoOutput, targetName, maddeRootPath) .parseRuntime(); if (!runtime.m_name.isEmpty()) { diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.h b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.h index 829480a2d0..780ebc4818 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqemuruntimeparser.h @@ -38,13 +38,13 @@ #include <QtXml/QXmlStreamReader> namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { class MaemoQemuRuntimeParser { public: - static MaemoQemuRuntime parseRuntime(const QtVersion *qtVersion); + static MaemoQemuRuntime parseRuntime(const BaseQtVersion *qtVersion); protected: MaemoQemuRuntimeParser(const QString &madInfoOutput, diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.cpp new file mode 100644 index 0000000000..652acfe504 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.cpp @@ -0,0 +1,148 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqtversion.h" +#include "qt4projectmanagerconstants.h" +#include "qt-maemo/maemoglobal.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QFile> +#include <QtCore/QDir> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +MaemoQtVersion::MaemoQtVersion() + : BaseQtVersion() +{ + +} + +MaemoQtVersion::MaemoQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : BaseQtVersion(path, isAutodetected, autodetectionSource) +{ + +} + +MaemoQtVersion::~MaemoQtVersion() +{ + +} + +QString MaemoQtVersion::type() const +{ + return Constants::MAEMOQT; +} + +MaemoQtVersion *MaemoQtVersion::clone() const +{ + return new MaemoQtVersion(*this); +} + +QString MaemoQtVersion::systemRoot() const +{ + if (m_systemRoot.isNull()) { + QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(qmakeCommand())) + + QLatin1String("/information")); + if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream stream(&file); + while (!stream.atEnd()) { + const QString &line = stream.readLine().trimmed(); + const QStringList &list = line.split(QLatin1Char(' ')); + if (list.count() <= 1) + continue; + if (list.at(0) == QLatin1String("sysroot")) { + m_systemRoot = MaemoGlobal::maddeRoot(qmakeCommand()) + + QLatin1String("/sysroots/") + list.at(1); + } + } + } + } + return m_systemRoot; +} + +QList<ProjectExplorer::Abi> MaemoQtVersion::qtAbis() const +{ + QList<ProjectExplorer::Abi> result; + if (MaemoGlobal::isValidMaemo5QtVersion(qmakeCommand())) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat, + 32)); + } else if (MaemoGlobal::isValidHarmattanQtVersion(qmakeCommand())) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::HarmattanLinuxFlavor, + ProjectExplorer::Abi::ElfFormat, + 32)); + } else if (MaemoGlobal::isValidMeegoQtVersion(qmakeCommand())) { + result.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, + ProjectExplorer::Abi::MeegoLinuxFlavor, + ProjectExplorer::Abi::ElfFormat, 32)); + } + return result; +} + +bool MaemoQtVersion::supportsTargetId(const QString &id) const +{ + return supportedTargetIds().contains(id); +} + +QSet<QString> MaemoQtVersion::supportedTargetIds() const +{ + QSet<QString> result; + if (MaemoGlobal::isValidMaemo5QtVersion(qmakeCommand())) { + result.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)); + } else if (MaemoGlobal::isValidHarmattanQtVersion(qmakeCommand())) { + result.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID)); + } else if (MaemoGlobal::isValidMeegoQtVersion(qmakeCommand())) { + result.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID)); + } + return result; +} + +QString MaemoQtVersion::description() const +{ + if (MaemoGlobal::isValidMaemo5QtVersion(qmakeCommand())) + return QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5"); + else if (MaemoGlobal::isValidHarmattanQtVersion(qmakeCommand())) + return QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan"); + else if (MaemoGlobal::isValidMeegoQtVersion(qmakeCommand())) + return QCoreApplication::translate("QtVersion", "Meego", "Qt Version is meant for Meego"); + return QString(); +} + +bool MaemoQtVersion::supportsShadowBuilds() const +{ +#ifdef Q_OS_WIN + return false; +#endif + return true; +} diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.h b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.h new file mode 100644 index 0000000000..184b2add6d --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversion.h @@ -0,0 +1,67 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef MAEMOQTVERSION_H +#define MAEMOQTVERSION_H + +#include "baseqtversion.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class MaemoQtVersion : public BaseQtVersion +{ +public: + MaemoQtVersion(); + MaemoQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + ~MaemoQtVersion(); + MaemoQtVersion *clone() const; + + virtual QString type() const; + + virtual QString systemRoot() const; + virtual QList<ProjectExplorer::Abi> qtAbis() const; + + virtual bool supportsTargetId(const QString &id) const; + virtual QSet<QString> supportedTargetIds() const; + + virtual QString description() const; + + virtual bool supportsShadowBuilds() const; +private: + mutable QString m_systemRoot; +}; + +} +} + + +#endif // MAEMOQTVERSION_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.cpp new file mode 100644 index 0000000000..a7c3c7c6a8 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.cpp @@ -0,0 +1,84 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "maemoqtversionfactory.h" +#include "maemoglobal.h" +#include "qt4projectmanagerconstants.h" +#include "maemoqtversion.h" + +#include <QtCore/QFileInfo> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +MaemoQtVersionFactory::MaemoQtVersionFactory(QObject *parent) + : QtVersionFactory(parent) +{ + +} + +MaemoQtVersionFactory::~MaemoQtVersionFactory() +{ + +} + +bool MaemoQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::MAEMOQT); +} + +BaseQtVersion *MaemoQtVersionFactory::restore(const QVariantMap &data) +{ + MaemoQtVersion *v = new MaemoQtVersion; + v->fromMap(data); + return v; +} + +int MaemoQtVersionFactory::priority() const +{ + return 50; +} + +BaseQtVersion *MaemoQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + Q_UNUSED(evaluator); + // we are the fallback :) so we don't care what kinf of qt it is + QFileInfo fi(qmakePath); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return 0; + + if (MaemoGlobal::isValidMaemo5QtVersion(qmakePath) + || MaemoGlobal::isValidHarmattanQtVersion(qmakePath) + || MaemoGlobal::isValidMeegoQtVersion(qmakePath)) + return new MaemoQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + return 0; +} diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.h b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.h new file mode 100644 index 0000000000..c49ff60fb7 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoqtversionfactory.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef MAEMOQTVERSIONFACTORY_H +#define MAEMOQTVERSIONFACTORY_H + +#include "qtversionfactory.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class MaemoQtVersionFactory : public QtVersionFactory +{ +public: + explicit MaemoQtVersionFactory(QObject *parent = 0); + ~MaemoQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual BaseQtVersion *restore(const QVariantMap &data); + + virtual int priority() const; + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // Internal +} // Qt4ProjectManager + + +#endif // MAEMOQTVERSIONFACTORY_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp index 36140ce544..b4ddf410d2 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp @@ -35,6 +35,7 @@ #include "maemoglobal.h" #include "maemousedportsgatherer.h" #include "qt4maemotarget.h" +#include "baseqtversion.h" #include <utils/ssh/sshconnection.h> #include <utils/ssh/sshremoteprocess.h> @@ -74,10 +75,10 @@ void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection, void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc) { ASSERT_STATE(Inactive); - const QtVersion * const qtVersion = bc->qtVersion(); + const BaseQtVersion * const qtVersion = bc->qtVersion(); m_remoteMountsAllowed = qobject_cast<AbstractQt4MaemoTarget *>(bc->target())->allowsRemoteMounts(); - m_maddeRoot = MaemoGlobal::maddeRoot(qtVersion); + m_maddeRoot = qtVersion ? MaemoGlobal::maddeRoot(qtVersion->qmakeCommand()) : ""; } void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp index 4cc7b50935..33618c686d 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp @@ -42,6 +42,7 @@ #include "qt4maemodeployconfiguration.h" #include "qt4maemotarget.h" #include "qtoutputformatter.h" +#include "maemoqtversion.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -235,7 +236,10 @@ AbstractLinuxDeviceDeployStep *MaemoRunConfiguration::deployStep() const const QString MaemoRunConfiguration::targetRoot() const { QTC_ASSERT(activeQt4BuildConfiguration(), return QString()); - return MaemoGlobal::targetRoot(activeQt4BuildConfiguration()->qtVersion()); + BaseQtVersion *v = activeQt4BuildConfiguration()->qtVersion(); + if (!v) + return QString(); + return MaemoGlobal::targetRoot(v->qmakeCommand()); } const QString MaemoRunConfiguration::arguments() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.cpp index fd3202d4ce..6fb5eef449 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.cpp @@ -34,6 +34,7 @@ #include "maemoglobal.h" #include "maemomanager.h" +#include "maemoqtversion.h" #include "qt4projectmanagerconstants.h" #include "qtversionmanager.h" @@ -93,8 +94,10 @@ bool MaemoToolChain::canClone() const void MaemoToolChain::addToEnvironment(Utils::Environment &env) const { - QtVersion *v = QtVersionManager::instance()->version(m_qtVersionId); - const QString maddeRoot = MaemoGlobal::maddeRoot(v); + BaseQtVersion *v = QtVersionManager::instance()->version(m_qtVersionId); + if (!v) + return; + const QString maddeRoot = MaemoGlobal::maddeRoot(v->qmakeCommand()); // put this into environment to make pkg-config stuff work env.prependOrSet(QLatin1String("SYSROOT_DIR"), QDir::toNativeSeparators(sysroot())); @@ -107,7 +110,7 @@ void MaemoToolChain::addToEnvironment(Utils::Environment &env) const env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin").arg(maddeRoot))); env.prependOrSetPath(QDir::toNativeSeparators(QString("%1/bin") - .arg(MaemoGlobal::targetRoot(v)))); + .arg(MaemoGlobal::targetRoot(v->qmakeCommand())))); const QString manglePathsKey = QLatin1String("GCCWRAPPER_PATHMANGLE"); if (!env.hasKey(manglePathsKey)) { @@ -121,19 +124,19 @@ void MaemoToolChain::addToEnvironment(Utils::Environment &env) const QString MaemoToolChain::sysroot() const { - QtVersion *v = QtVersionManager::instance()->version(m_qtVersionId); + BaseQtVersion *v = QtVersionManager::instance()->version(m_qtVersionId); if (!v) return QString(); if (m_sysroot.isEmpty()) { - QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(v)) + QLatin1String("/information")); + QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(v->qmakeCommand())) + QLatin1String("/information")); if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); while (!stream.atEnd()) { const QString &line = stream.readLine().trimmed(); const QStringList &list = line.split(QLatin1Char(' ')); if (list.count() > 1 && list.at(0) == QLatin1String("sysroot")) - m_sysroot = MaemoGlobal::maddeRoot(v) + QLatin1String("/sysroots/") + list.at(1); + m_sysroot = MaemoGlobal::maddeRoot(v->qmakeCommand()) + QLatin1String("/sysroots/") + list.at(1); } } } @@ -180,14 +183,14 @@ void MaemoToolChain::setQtVersionId(int id) return; } - QtVersion *version = QtVersionManager::instance()->version(id); + BaseQtVersion *version = QtVersionManager::instance()->version(id); Q_ASSERT(version); ProjectExplorer::Abi::OSFlavor flavour = ProjectExplorer::Abi::HarmattanLinuxFlavor; - if (MaemoGlobal::isValidMaemo5QtVersion(version)) + if (MaemoGlobal::isValidMaemo5QtVersion(version->qmakeCommand())) flavour = ProjectExplorer::Abi::MaemoLinuxFlavor; - else if (MaemoGlobal::isValidHarmattanQtVersion(version)) + else if (MaemoGlobal::isValidHarmattanQtVersion(version->qmakeCommand())) flavour = ProjectExplorer::Abi::HarmattanLinuxFlavor; - else if (MaemoGlobal::isValidMeegoQtVersion(version)) + else if (MaemoGlobal::isValidMeegoQtVersion(version->qmakeCommand())) flavour = ProjectExplorer::Abi::MeegoLinuxFlavor; else return; @@ -221,14 +224,14 @@ MaemoToolChainConfigWidget::MaemoToolChainConfigWidget(MaemoToolChain *tc) : { QVBoxLayout *layout = new QVBoxLayout(this); QLabel *label = new QLabel; - QtVersion *v = QtVersionManager::instance()->version(tc->qtVersionId()); + BaseQtVersion *v = QtVersionManager::instance()->version(tc->qtVersionId()); Q_ASSERT(v); label->setText(tr("<html><head/><body><table>" "<tr><td>Path to MADDE:</td><td>%1</td></tr>" "<tr><td>Path to MADDE target:</td><td>%2</td></tr>" "<tr><td>Debugger:</td/><td>%3</td></tr></body></html>") - .arg(QDir::toNativeSeparators(MaemoGlobal::maddeRoot(v)), - QDir::toNativeSeparators(MaemoGlobal::targetRoot(v)), + .arg(QDir::toNativeSeparators(MaemoGlobal::maddeRoot(v->qmakeCommand())), + QDir::toNativeSeparators(MaemoGlobal::targetRoot(v->qmakeCommand())), QDir::toNativeSeparators(tc->debuggerCommand()))); layout->addWidget(label); } @@ -268,14 +271,12 @@ QString MaemoToolChainFactory::id() const QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::autoDetect() { - QList<ProjectExplorer::ToolChain *> result; - QtVersionManager *vm = QtVersionManager::instance(); connect(vm, SIGNAL(qtVersionsChanged(QList<int>)), this, SLOT(handleQtVersionChanges(QList<int>))); QList<int> versionList; - foreach (QtVersion *v, vm->versions()) + foreach (BaseQtVersion *v, vm->versions()) versionList.append(v->uniqueId()); return createToolChainList(versionList); @@ -296,7 +297,7 @@ QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::createToolChainList(c QList<ProjectExplorer::ToolChain *> result; foreach (int i, changes) { - QtVersion *v = vm->version(i); + BaseQtVersion *v = vm->version(i); if (!v) { // remove tool chain: QList<ProjectExplorer::ToolChain *> toRemove; @@ -309,9 +310,7 @@ QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::createToolChainList(c } foreach (ProjectExplorer::ToolChain *tc, toRemove) tcm->deregisterToolChain(tc); - } else if (v->supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) - || v->supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID) - || v->supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) { + } else if (MaemoQtVersion *mqv = dynamic_cast<MaemoQtVersion *>(v)) { // add tool chain: MaemoToolChain *mTc = new MaemoToolChain(true); mTc->setQtVersionId(i); @@ -320,11 +319,11 @@ QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::createToolChainList(c target = "Maemo 6"; else if (v->supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) target = "Meego"; - mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(v))); - mTc->setCompilerPath(MaemoGlobal::targetRoot(v) + QLatin1String("/bin/gcc")); - mTc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(v->qtAbis().at(0))); + mTc->setDisplayName(tr("%1 GCC (%2)").arg(target).arg(MaemoGlobal::maddeRoot(mqv->qmakeCommand()))); + mTc->setCompilerPath(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gcc")); + mTc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(mqv->qtAbis().at(0))); if (mTc->debuggerCommand().isEmpty()) - mTc->setDebuggerCommand(MaemoGlobal::targetRoot(v) + QLatin1String("/bin/gdb")); + mTc->setDebuggerCommand(MaemoGlobal::targetRoot(mqv->qmakeCommand()) + QLatin1String("/bin/gdb")); result.append(mTc); } } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.h b/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.h index 8249ea2318..6f4a796706 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemotoolchain.h @@ -37,7 +37,6 @@ #include <projectexplorer/toolchainconfigwidget.h> namespace Qt4ProjectManager { -class QtVersion; namespace Internal { diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 24893a582a..66a552bc87 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -60,7 +60,9 @@ HEADERS += \ $$PWD/maemodeploybymountstep.h \ $$PWD/maemouploadandinstalldeploystep.h \ $$PWD/maemodirectdeviceuploadstep.h \ - $$PWD/abstractlinuxdevicedeploystep.h + $$PWD/abstractlinuxdevicedeploystep.h \ + $$PWD/maemoqtversionfactory.h \ + $$PWD/maemoqtversion.h SOURCES += \ $$PWD/maemoconfigtestdialog.cpp \ @@ -121,7 +123,9 @@ SOURCES += \ $$PWD/maemodeploybymountstep.cpp \ $$PWD/maemouploadandinstalldeploystep.cpp \ $$PWD/maemodirectdeviceuploadstep.cpp \ - $$PWD/abstractlinuxdevicedeploystep.cpp + $$PWD/abstractlinuxdevicedeploystep.cpp \ + $$PWD/maemoqtversionfactory.cpp \ + $$PWD/maemoqtversion.cpp FORMS += \ $$PWD/maemoconfigtestdialog.ui \ diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp b/src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp index 1009f5d319..c5b5a26963 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/qt4maemotarget.cpp @@ -49,9 +49,9 @@ #include <projectexplorer/toolchain.h> #include <qt4projectmanager/qt4project.h> #include <utils/fileutils.h> - #include <utils/filesystemwatcher.h> -#include <utils/fileutils.h> +#include <qt4projectmanager/baseqtversion.h> + #include <QtGui/QApplication> #include <QtGui/QMainWindow> @@ -153,7 +153,7 @@ QList<ProjectExplorer::ToolChain *> AbstractQt4MaemoTarget::possibleToolChains(P QList<ProjectExplorer::ToolChain *> candidates = Qt4BaseTarget::possibleToolChains(bc); foreach (ProjectExplorer::ToolChain *i, candidates) { MaemoToolChain *tc = dynamic_cast<MaemoToolChain *>(i); - if (!tc) + if (!tc || !qt4Bc->qtVersion()) continue; if (tc->qtVersionId() == qt4Bc->qtVersion()->uniqueId()) result.append(tc); @@ -692,7 +692,8 @@ bool AbstractDebBasedQt4MaemoTarget::targetCanBeRemoved() const void AbstractDebBasedQt4MaemoTarget::removeTarget() { QString error; - MaemoGlobal::removeRecursively(debianDirPath(), error); + if (!MaemoGlobal::removeRecursively(debianDirPath(), error)) + qDebug("%s", qPrintable(error)); } void AbstractDebBasedQt4MaemoTarget::handleDebianFileChanged(const QString &filePath) @@ -725,7 +726,12 @@ AbstractQt4MaemoTarget::ActionStatus AbstractDebBasedQt4MaemoTarget::createSpeci << QLatin1String("-s") << QLatin1String("-n") << QLatin1String("-p") << (defaultPackageFileName() + QLatin1Char('_') + AbstractMaemoPackageCreationStep::DefaultVersionNumber); - if (!MaemoGlobal::callMad(dh_makeProc, dh_makeArgs, activeBuildConfiguration()->qtVersion(), true) + BaseQtVersion *lqt = activeBuildConfiguration()->qtVersion(); + if (!lqt) { + raiseError(tr("Unable to create Debian templates: No qt version set")); + return ActionFailed; + } + if (!MaemoGlobal::callMad(dh_makeProc, dh_makeArgs, lqt->qmakeCommand(), true) || !dh_makeProc.waitForStarted()) { raiseError(tr("Unable to create Debian templates: dh_make failed (%1)") .arg(dh_makeProc.errorString())); @@ -924,9 +930,12 @@ QString AbstractRpmBasedQt4MaemoTarget::shortDescription() const QString AbstractRpmBasedQt4MaemoTarget::packageFileName() const { + BaseQtVersion *lqt = activeBuildConfiguration()->qtVersion(); + if (!lqt) + return QString(); return packageName() + QLatin1Char('-') + projectVersion() + QLatin1Char('-') + QString::fromUtf8(getValueForTag(ReleaseTag, 0)) + QLatin1Char('.') - + MaemoGlobal::architecture(activeBuildConfiguration()->qtVersion()) + + MaemoGlobal::architecture(lqt->qmakeCommand()) + QLatin1String(".rpm"); } diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt4maemotargetfactory.cpp b/src/plugins/qt4projectmanager/qt-maemo/qt4maemotargetfactory.cpp index 3c9003d79f..f0f118d137 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt4maemotargetfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/qt4maemotargetfactory.cpp @@ -73,11 +73,11 @@ QStringList Qt4MaemoTargetFactory::supportedTargetIds(ProjectExplorer::Project * QStringList targetIds; if (parent && !qobject_cast<Qt4Project *>(parent)) return targetIds; - if (QtVersionManager::instance()->supportsTargetId(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID))) + if (!QtVersionManager::instance()->versionsForTargetId(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)).isEmpty()) targetIds << QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID); - if (QtVersionManager::instance()->supportsTargetId(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID))) + if (!QtVersionManager::instance()->versionsForTargetId(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID)).isEmpty()) targetIds << QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID); - if (QtVersionManager::instance()->supportsTargetId(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID))) + if (!QtVersionManager::instance()->versionsForTargetId(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID)).isEmpty()) targetIds << QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID); return targetIds; } @@ -176,16 +176,16 @@ ProjectExplorer::Target *Qt4MaemoTargetFactory::create(ProjectExplorer::Project if (!canCreate(parent, id)) return 0; - QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); + QList<BaseQtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); if (knownVersions.isEmpty()) return 0; - QtVersion *qtVersion = knownVersions.first(); - QtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + BaseQtVersion *qtVersion = knownVersions.first(); + BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); QList<BuildConfigurationInfo> infos; infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtVersion::DebugBuild, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ BaseQtVersion::DebugBuild, QString(), QString())); return create(parent, id, infos); } diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri index d38f46b4b2..ab1c6c6e3c 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri +++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60.pri @@ -31,7 +31,9 @@ SOURCES += $$PWD/s60manager.cpp \ $$PWD/s60publishingsissettingspageovi.cpp \ $$PWD/s60publisherovi.cpp \ $$PWD/s60publishingbuildsettingspageovi.cpp \ - $$PWD/s60publishingresultspageovi.cpp + $$PWD/s60publishingresultspageovi.cpp \ + $$PWD/symbianqtversionfactory.cpp \ + $$PWD/symbianqtversion.cpp HEADERS += $$PWD/s60manager.h \ $$PWD/sbsv2parser.h \ @@ -66,7 +68,9 @@ HEADERS += $$PWD/s60manager.h \ $$PWD/s60publishingsissettingspageovi.h \ $$PWD/s60publisherovi.h \ $$PWD/s60publishingbuildsettingspageovi.h \ - $$PWD/s60publishingresultspageovi.h + $$PWD/s60publishingresultspageovi.h \ + $$PWD/symbianqtversionfactory.h \ + $$PWD/symbianqtversion.h FORMS += $$PWD/s60createpackagestep.ui \ $$PWD/s60certificatedetailsdialog.ui \ diff --git a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp index db861d14d5..ee7adcd860 100644 --- a/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/qt4symbiantargetfactory.cpp @@ -170,7 +170,7 @@ QList<BuildConfigurationInfo> Qt4SymbianTargetFactory::availableBuildConfigurati // For emulator filter out all non debug builds QList<BuildConfigurationInfo> tmp; foreach (const BuildConfigurationInfo &info, infos) - if (info.buildConfig & QtVersion::DebugBuild) + if (info.buildConfig & BaseQtVersion::DebugBuild) tmp << info; return tmp; } @@ -192,22 +192,22 @@ ProjectExplorer::Target *Qt4SymbianTargetFactory::create(ProjectExplorer::Projec if (!canCreate(parent, id)) return 0; - QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); + QList<BaseQtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id); if (knownVersions.isEmpty()) return 0; - QtVersion *qtVersion = knownVersions.first(); - QtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); + BaseQtVersion *qtVersion = knownVersions.first(); + BaseQtVersion::QmakeBuildConfigs config = qtVersion->defaultBuildConfig(); QList<BuildConfigurationInfo> infos; if (id != Constants::S60_EMULATOR_TARGET_ID) { infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtVersion::DebugBuild, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ BaseQtVersion::DebugBuild, QString(), QString())); } else { - if(config & QtVersion::DebugBuild) + if(config & BaseQtVersion::DebugBuild) infos.append(BuildConfigurationInfo(qtVersion, config, QString(), QString())); else - infos.append(BuildConfigurationInfo(qtVersion, config ^ QtVersion::DebugBuild, QString(), QString())); + infos.append(BuildConfigurationInfo(qtVersion, config ^ BaseQtVersion::DebugBuild, QString(), QString())); } return create(parent, id, infos); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp index 6686eee706..915ead9373 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp @@ -42,6 +42,7 @@ #include "passphraseforkeydialog.h" #include "s60certificateinfo.h" #include "s60certificatedetailsdialog.h" +#include "symbianqtversion.h" #include <coreplugin/coreconstants.h> @@ -183,6 +184,11 @@ bool S60CreatePackageStep::init() QList<Qt4ProFileNode *> nodes = pro->allProFiles(); + SymbianQtVersion *sqv = dynamic_cast<SymbianQtVersion *>(qt4BuildConfiguration()->qtVersion()); + if (!sqv) + return false; + m_isBuildWithSymbianSbsV2 = sqv->isBuildWithSymbianSbsV2(); + m_workingDirectories.clear(); QStringList projectCapabilities; foreach (Qt4ProFileNode *node, nodes) { @@ -408,7 +414,7 @@ bool S60CreatePackageStep::createOnePackage() // Setup parsers: Q_ASSERT(!m_outputParserChain); - if (!qt4BuildConfiguration()->qtVersion()->isBuildWithSymbianSbsV2()) { + if (!m_isBuildWithSymbianSbsV2) { m_outputParserChain = new Qt4ProjectManager::AbldParser; m_outputParserChain->appendOutputParser(new ProjectExplorer::GnuMakeParser); } else { diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h index 505ad75ef6..3465933015 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h @@ -182,6 +182,7 @@ private: bool m_suppressPatchWarningDialog; Utils::CheckableMessageBox *m_patchWarningDialog; + bool m_isBuildWithSymbianSbsV2; }; class S60CreatePackageStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp index bf778e5bc9..d3f7997a91 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.cpp @@ -267,7 +267,7 @@ ProjectExplorer::ToolChain *S60DeployConfiguration::toolChain() const bool S60DeployConfiguration::isDebug() const { const Qt4BuildConfiguration *qt4bc = qt4Target()->activeBuildConfiguration(); - return (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild); + return (qt4bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild); } QString S60DeployConfiguration::symbianTarget() const @@ -275,7 +275,7 @@ QString S60DeployConfiguration::symbianTarget() const return isDebug() ? QLatin1String("udeb") : QLatin1String("urel"); } -const QtVersion *S60DeployConfiguration::qtVersion() const +const BaseQtVersion *S60DeployConfiguration::qtVersion() const { if (const Qt4BuildConfiguration *qt4bc = qt4Target()->activeBuildConfiguration()) return qt4bc->qtVersion(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h index 2f4ea63868..93c6496f47 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60deployconfiguration.h @@ -42,7 +42,7 @@ class ToolChain; } namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; namespace Internal { class Qt4SymbianTarget; @@ -71,7 +71,7 @@ public: ProjectExplorer::DeployConfigurationWidget *configurationWidget() const; - const QtVersion *qtVersion() const; + const BaseQtVersion *qtVersion() const; Qt4SymbianTarget *qt4Target() const; ProjectExplorer::ToolChain *toolChain() const; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index eac01d3b6c..4c710c1a59 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -41,6 +41,8 @@ #include "qtoutputformatter.h" #include "qt4symbiantarget.h" #include "codaruncontrol.h" +#include "baseqtversion.h" +#include "symbianqtversion.h" #include <utils/qtcassert.h> @@ -223,18 +225,18 @@ QString S60DeviceRunConfiguration::targetName() const return ti.target; } -const QtVersion *S60DeviceRunConfiguration::qtVersion() const +SymbianQtVersion *S60DeviceRunConfiguration::qtVersion() const { if (const BuildConfiguration *bc = target()->activeBuildConfiguration()) if (const Qt4BuildConfiguration *qt4bc = qobject_cast<const Qt4BuildConfiguration *>(bc)) - return qt4bc->qtVersion(); + return dynamic_cast<SymbianQtVersion *>(qt4bc->qtVersion()); return 0; } bool S60DeviceRunConfiguration::isDebug() const { const Qt4BuildConfiguration *qt4bc = qt4Target()->activeBuildConfiguration(); - return (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild); + return (qt4bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild); } QString S60DeviceRunConfiguration::symbianTarget() const @@ -243,7 +245,7 @@ QString S60DeviceRunConfiguration::symbianTarget() const } // ABLD/Raptor: Return executable from device/EPOC -static inline QString localExecutableFromVersion(const QtVersion *qtv, +static inline QString localExecutableFromVersion(const SymbianQtVersion *qtv, const QString &symbianTarget, /* udeb/urel */ const QString &targetName, const ProjectExplorer::ToolChain *tc) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h index 3b98bf61f4..9484e156ea 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h @@ -46,10 +46,10 @@ class QWidget; QT_END_NAMESPACE namespace Qt4ProjectManager { -class QtVersion; class Qt4BaseTarget; namespace Internal { +class SymbianQtVersion; class Qt4SymbianTarget; class Qt4ProFileNode; class S60DeviceRunConfigurationFactory; @@ -65,7 +65,7 @@ public: virtual ~S60DeviceRunConfiguration(); Qt4SymbianTarget *qt4Target() const; - const QtVersion *qtVersion() const; + SymbianQtVersion *qtVersion() const; using ProjectExplorer::RunConfiguration::isEnabled; bool isEnabled(ProjectExplorer::BuildConfiguration *configuration) const; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp index e52135cadf..ad0c4a190f 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp @@ -38,6 +38,7 @@ #include "qt4symbiantarget.h" #include "qt4projectmanagerconstants.h" #include "qtoutputformatter.h" +#include "baseqtversion.h" #include <projectexplorer/projectexplorerconstants.h> @@ -187,10 +188,10 @@ bool S60EmulatorRunConfiguration::fromMap(const QVariantMap &map) QString S60EmulatorRunConfiguration::executable() const { Qt4BuildConfiguration *qt4bc = qt4Target()->activeBuildConfiguration(); - QtVersion *qtVersion = qt4bc->qtVersion(); + BaseQtVersion *qtVersion = qt4bc->qtVersion(); QString baseDir = qtVersion->systemRoot(); QString qmakeBuildConfig = "urel"; - if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) + if (qt4bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) qmakeBuildConfig = "udeb"; baseDir += "/epoc32/release/winscw/" + qmakeBuildConfig; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp index 312d03906d..870c1f87a9 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp @@ -47,6 +47,7 @@ #include "gccetoolchain.h" #include "rvcttoolchain.h" #include "winscwtoolchain.h" +#include "symbianqtversionfactory.h" #include <symbianutils/symbiandevicemanager.h> @@ -128,6 +129,7 @@ S60Manager::S60Manager(QObject *parent) : QObject(parent) addAutoReleasedObject(new S60DeployConfigurationFactory); addAutoReleasedObject(new S60PublishingWizardFactoryOvi); + addAutoReleasedObject(new SymbianQtVersionFactory); connect(Core::ICore::instance()->mainWindow(), SIGNAL(deviceChange()), SymbianUtils::SymbianDeviceManager::instance(), SLOT(update())); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp b/src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp index 4118f76cc2..dca47e6cab 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60publisherovi.cpp @@ -248,6 +248,8 @@ bool S60PublisherOvi::isVendorNameValid(const QString &vendorName) const QString S60PublisherOvi::qtVersion() const { + if (!m_qt4bc->qtVersion()) + return QString(); return m_qt4bc->qtVersion()->displayName(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.cpp b/src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.cpp index f8490d30bd..d9490ce5e9 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.cpp @@ -74,7 +74,7 @@ S60PublishingBuildSettingsPageOvi::S60PublishingBuildSettingsPageOvi(S60Publishe // todo more intelligent selection? prefer newer versions? foreach (Qt4BuildConfiguration *qt4bc, list) - if (!m_bc && !(qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)) + if (!m_bc && !(qt4bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild)) m_bc = qt4bc; if (!m_bc && !list.isEmpty()) diff --git a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp index c58f05736c..0e4d78a60c 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60runcontrolbase.cpp @@ -93,10 +93,11 @@ S60RunControlBase::S60RunControlBase(RunConfiguration *runConfiguration, const Q m_commandLineArguments.prepend(' '); m_commandLineArguments.prepend(qmlArgs); } - m_qtDir = activeBuildConf->qtVersion()->versionInfo().value("QT_INSTALL_DATA"); - m_installationDrive = activeDeployConf->installationDrive(); - if (const QtVersion *qtv = activeDeployConf->qtVersion()) + if (const BaseQtVersion *qtv = activeBuildConf->qtVersion()) { + m_qtDir = qtv->versionInfo().value("QT_INSTALL_DATA"); m_qtBinPath = qtv->versionInfo().value(QLatin1String("QT_INSTALL_BINS")); + } + m_installationDrive = activeDeployConf->installationDrive(); QTC_ASSERT(!m_qtBinPath.isEmpty(), return); m_executableFileName = s60runConfig->localExecutableFileName(); m_runSmartInstaller = activeDeployConf->runSmartInstaller(); diff --git a/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp new file mode 100644 index 0000000000..10f2f742e1 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.cpp @@ -0,0 +1,390 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "qt4projectmanagerconstants.h" +#include "symbianqtversion.h" +#include "qt-s60/sbsv2parser.h" +#include "qt-s60/abldparser.h" +#include "profileevaluator.h" + +#include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/toolchain.h> +#include <projectexplorer/toolchainmanager.h> +#include <utils/pathchooser.h> + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtGui/QLabel> +#include <QtGui/QFormLayout> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +SymbianQtVersion::SymbianQtVersion() + : BaseQtVersion(), + m_validSystemRoot(false) +{ +} + +SymbianQtVersion::SymbianQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : BaseQtVersion(path, isAutodetected, autodetectionSource), + m_validSystemRoot(false) +{ + +} + +SymbianQtVersion::~SymbianQtVersion() +{ + +} + +SymbianQtVersion *SymbianQtVersion::clone() const +{ + return new SymbianQtVersion(*this); +} + +bool SymbianQtVersion::equals(BaseQtVersion *other) +{ + if (!BaseQtVersion::equals(other)) + return false; + SymbianQtVersion *o = static_cast<SymbianQtVersion *>(other); + return m_sbsV2Directory == o->m_sbsV2Directory + && m_systemRoot == o->m_systemRoot; +} + +QString SymbianQtVersion::type() const +{ + return QLatin1String(Constants::SYMBIANQT); +} + +bool SymbianQtVersion::isValid() const +{ + if (!BaseQtVersion::isValid()) + return false; + if (!m_validSystemRoot) + return false; + if(isBuildWithSymbianSbsV2() && (m_sbsV2Directory.isEmpty() || !QFileInfo(m_sbsV2Directory + QLatin1String("/sbs")).exists())) + return false; + return true; +} + +QString SymbianQtVersion::invalidReason() const +{ + QString tmp = BaseQtVersion::invalidReason(); + if (tmp.isEmpty() && !m_validSystemRoot) + return QCoreApplication::translate("QtVersion", "The \"Open C/C++ plugin\" is not installed in the Symbian SDK or the Symbian SDK path is misconfigured"); + if (isBuildWithSymbianSbsV2() + && (m_sbsV2Directory.isEmpty() || !QFileInfo(m_sbsV2Directory + QLatin1String("/sbs")).exists())) + return QCoreApplication::translate("QtVersion", "SBS was not found."); + + return QString(); +} + +bool SymbianQtVersion::toolChainAvailable(const QString &id) const +{ + if (!isValid()) + return false; + if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) { + QList<ProjectExplorer::ToolChain *> tcList = + ProjectExplorer::ToolChainManager::instance()->toolChains(); + foreach (ProjectExplorer::ToolChain *tc, tcList) { + if (tc->id().startsWith(QLatin1String(Constants::WINSCW_TOOLCHAIN_ID))) + return true; + } + return false; + } else if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) { + QList<ProjectExplorer::ToolChain *> tcList = + ProjectExplorer::ToolChainManager::instance()->toolChains(); + foreach (ProjectExplorer::ToolChain *tc, tcList) { + if (!tc->id().startsWith(Qt4ProjectManager::Constants::WINSCW_TOOLCHAIN_ID)) + return true; + } + return false; + } + return false; +} + +void SymbianQtVersion::fromMap(const QVariantMap &map) +{ + BaseQtVersion::fromMap(map); + setSbsV2Directory(map.value(QLatin1String("SBSv2Directory")).toString()); + setSystemRoot(map.value(QLatin1String("SystemRoot")).toString()); +} + +QVariantMap SymbianQtVersion::toMap() const +{ + QVariantMap result = BaseQtVersion::toMap(); + result.insert(QLatin1String("SBSv2Directory"), sbsV2Directory()); + result.insert(QLatin1String("SystemRoot"), systemRoot()); + return result; +} + +QList<ProjectExplorer::Abi> SymbianQtVersion::qtAbis() const +{ + return QList<ProjectExplorer::Abi>() + << ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::SymbianOS, + ProjectExplorer::Abi::UnknownFlavor, + ProjectExplorer::Abi::ElfFormat, + 32); +} + +bool SymbianQtVersion::supportsTargetId(const QString &id) const +{ + return supportedTargetIds().contains(id); +} + +QSet<QString> SymbianQtVersion::supportedTargetIds() const +{ + return QSet<QString>() << QLatin1String(Constants::S60_DEVICE_TARGET_ID) + << QLatin1String(Constants::S60_EMULATOR_TARGET_ID); +} + +QString SymbianQtVersion::description() const +{ + return QCoreApplication::translate("QtVersion", "Symbian", "Qt Version is meant for Symbian"); +} + + +bool SymbianQtVersion::supportsShadowBuilds() const +{ + return false; +} + +bool SymbianQtVersion::supportsBinaryDebuggingHelper() const +{ + return false; +} + +static const char *S60_EPOC_HEADERS[] = { + "include", "mkspecs/common/symbian", "epoc32/include", + "epoc32/include/osextensions/stdapis", "epoc32/include/osextensions/stdapis/sys", + "epoc32/include/stdapis", "epoc32/include/stdapis/sys", + "epoc32/include/osextensions/stdapis/stlport", "epoc32/include/stdapis/stlport", + "epoc32/include/oem", "epoc32/include/middleware", "epoc32/include/domain/middleware", + "epoc32/include/osextensions", "epoc32/include/domain/osextensions", + "epoc32/include/domain/osextensions/loc", "epoc32/include/domain/middleware/loc", + "epoc32/include/domain/osextensions/loc/sc", "epoc32/include/domain/middleware/loc/sc" +}; + +void SymbianQtVersion::addToEnvironment(Utils::Environment &env) const +{ + BaseQtVersion::addToEnvironment(env); + // Generic Symbian environment: + QString epocRootPath = systemRoot(); + QDir epocDir(epocRootPath); + + // Clean up epoc root path for the environment: + if (!epocRootPath.endsWith(QLatin1Char('/'))) + epocRootPath.append(QLatin1Char('/')); + if (!isBuildWithSymbianSbsV2()) { +#ifdef Q_OS_WIN + if (epocRootPath.count() > 2 + && epocRootPath.at(0).toLower() >= QLatin1Char('a') + && epocRootPath.at(0).toLower() <= QLatin1Char('z') + && epocRootPath.at(1) == QLatin1Char(':')) { + epocRootPath = epocRootPath.mid(2); + } +#endif + } + env.set(QLatin1String("EPOCROOT"), QDir::toNativeSeparators(epocRootPath)); + + env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/tools"))); // e.g. make.exe + // Windows only: + if (ProjectExplorer::Abi::hostAbi().os() == ProjectExplorer::Abi::WindowsOS) { + QString winDir = QLatin1String(qgetenv("WINDIR")); + if (!winDir.isEmpty()) + env.prependOrSetPath(QDir(winDir).filePath(QLatin1String("system32"))); + + if (epocDir.exists(QLatin1String("epoc32/gcc/bin"))) + env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/gcc/bin"))); // e.g. cpp.exe, *NOT* gcc.exe + // Find perl in the special Symbian flavour: + if (epocDir.exists(QLatin1String("../../tools/perl/bin"))) { + epocDir.cd(QLatin1String("../../tools/perl/bin")); + env.prependOrSetPath(epocDir.absolutePath()); + } else { + env.prependOrSetPath(epocDir.filePath(QLatin1String("perl/bin"))); + } + } + + // SBSv2: + if (isBuildWithSymbianSbsV2()) { + QString sbsHome(env.value(QLatin1String("SBS_HOME"))); + QString sbsConfig = sbsV2Directory(); + if (!sbsConfig.isEmpty()) { + env.prependOrSetPath(sbsConfig); + // SBS_HOME is the path minus the trailing /bin: + env.set(QLatin1String("SBS_HOME"), + QDir::toNativeSeparators(sbsConfig.left(sbsConfig.count() - 4))); // We need this for Qt 4.6.3 compatibility + } else if (!sbsHome.isEmpty()) { + env.prependOrSetPath(sbsHome + QLatin1String("/bin")); + } + } +} + +QList<ProjectExplorer::HeaderPath> SymbianQtVersion::systemHeaderPathes() const +{ + QList<ProjectExplorer::HeaderPath> result; + QString root = systemRoot() + QLatin1Char('/'); + const int count = sizeof(S60_EPOC_HEADERS) / sizeof(const char *); + for (int i = 0; i < count; ++i) { + const QDir dir(root + QLatin1String(S60_EPOC_HEADERS[i])); + if (dir.exists()) + result.append(ProjectExplorer::HeaderPath(dir.absolutePath(), + ProjectExplorer::HeaderPath::GlobalHeaderPath)); + } + result.append(BaseQtVersion::systemHeaderPathes()); + return result; +} + +ProjectExplorer::IOutputParser *SymbianQtVersion::createOutputParser() const +{ + if (isBuildWithSymbianSbsV2()) { + return new SbsV2Parser; + } else { + ProjectExplorer::IOutputParser *parser = new AbldParser; + parser->appendOutputParser(new ProjectExplorer::GnuMakeParser); + return parser; + } +} + +QString SymbianQtVersion::sbsV2Directory() const +{ + return m_sbsV2Directory; +} + +void SymbianQtVersion::setSbsV2Directory(const QString &directory) +{ + QDir dir(directory); + if (dir.exists(QLatin1String("sbs"))) { + m_sbsV2Directory = dir.absolutePath(); + return; + } + dir.cd("bin"); + if (dir.exists(QLatin1String("sbs"))) { + m_sbsV2Directory = dir.absolutePath(); + return; + } + m_sbsV2Directory = directory; +} + +bool SymbianQtVersion::isBuildWithSymbianSbsV2() const +{ + ensureMkSpecParsed(); + return m_isBuildUsingSbsV2; +} + +void SymbianQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const +{ + QString makefileGenerator = evaluator->value("MAKEFILE_GENERATOR"); + m_isBuildUsingSbsV2 = (makefileGenerator == QLatin1String("SYMBIAN_SBSV2")); + BaseQtVersion::parseMkSpec(evaluator); +} + +QList<ProjectExplorer::Task> SymbianQtVersion::reportIssuesImpl(const QString &proFile, const QString &buildDir) +{ + QList<ProjectExplorer::Task> results = BaseQtVersion::reportIssuesImpl(proFile, buildDir); + const QString epocRootDir = systemRoot(); + // Report an error if project- and epoc directory are on different drives: + if (!epocRootDir.startsWith(proFile.left(3), Qt::CaseInsensitive) && !isBuildWithSymbianSbsV2()) { + results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, + QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker", + "The Symbian SDK and the project sources must reside on the same drive."), + QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + } + return results; +} + +void SymbianQtVersion::setSystemRoot(const QString &root) +{ + if (root == m_systemRoot) + return; + m_systemRoot = root; + + m_validSystemRoot = false; + if (!m_systemRoot.isEmpty()) { + if (!m_systemRoot.endsWith(QLatin1Char('/'))) + m_systemRoot.append(QLatin1Char('/')); + QFileInfo cppheader(m_systemRoot + QLatin1String("epoc32/include/stdapis/string.h")); + m_validSystemRoot = cppheader.exists(); + } +} + +QString SymbianQtVersion::systemRoot() const +{ + return m_systemRoot; +} + +QtConfigWidget *SymbianQtVersion::createConfigurationWidget() const +{ + return new SymbianQtConfigWidget(const_cast<SymbianQtVersion *>(this)); +} + +SymbianQtConfigWidget::SymbianQtConfigWidget(SymbianQtVersion *version) + : m_version(version) +{ + QFormLayout *fl = new QFormLayout(); + fl->setMargin(0); + setLayout(fl); + + Utils::PathChooser *s60sdkPath = new Utils::PathChooser; + s60sdkPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); + + fl->addRow(tr("S60 SDK:"), s60sdkPath); + + s60sdkPath->setPath(QDir::toNativeSeparators(version->systemRoot())); + + connect(s60sdkPath, SIGNAL(changed(QString)), + this, SLOT(updateCurrentS60SDKDirectory(QString))); + + if (version->isBuildWithSymbianSbsV2()) { + Utils::PathChooser *sbsV2Path = new Utils::PathChooser; + sbsV2Path->setExpectedKind(Utils::PathChooser::ExistingDirectory); + fl->addRow(tr("SBS v2 directory:"), sbsV2Path); + sbsV2Path->setPath(QDir::toNativeSeparators(version->sbsV2Directory())); + sbsV2Path->setEnabled(version->isBuildWithSymbianSbsV2()); + connect(sbsV2Path, SIGNAL(changed(QString)), + this, SLOT(updateCurrentSbsV2Directory(QString))); + } +} + +void SymbianQtConfigWidget::updateCurrentS60SDKDirectory(const QString &path) +{ + m_version->setSystemRoot(QDir::fromNativeSeparators(path)); + emit changed(); +} + +void SymbianQtConfigWidget::updateCurrentSbsV2Directory(const QString &path) +{ + m_version->setSbsV2Directory(QDir::fromNativeSeparators(path)); + emit changed(); +} diff --git a/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.h b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.h new file mode 100644 index 0000000000..67001234df --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/symbianqtversion.h @@ -0,0 +1,110 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef SYMBIANQTVERSION_H +#define SYMBIANQTVERSION_H + +#include "baseqtversion.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class SymbianQtVersion : public BaseQtVersion +{ +public: + SymbianQtVersion(); + SymbianQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + SymbianQtVersion *clone() const; + ~SymbianQtVersion(); + + virtual bool equals(BaseQtVersion *other); + + QString type() const; + + virtual bool isValid() const; + virtual QString invalidReason() const; + + virtual bool toolChainAvailable(const QString &id) const; + + virtual void fromMap(const QVariantMap &map); + virtual QVariantMap toMap() const; + + virtual QList<ProjectExplorer::Abi> qtAbis() const; + + virtual bool supportsTargetId(const QString &id) const; + virtual QSet<QString> supportedTargetIds() const; + + virtual QString description() const; + + virtual bool supportsShadowBuilds() const; + virtual bool supportsBinaryDebuggingHelper() const; + virtual void addToEnvironment(Utils::Environment &env) const; + virtual QList<ProjectExplorer::HeaderPath> systemHeaderPathes() const; + + virtual ProjectExplorer::IOutputParser *createOutputParser() const; + + virtual QString systemRoot() const; + void setSystemRoot(const QString &); + + bool isBuildWithSymbianSbsV2() const; + + QString sbsV2Directory() const; + void setSbsV2Directory(const QString &directory); + + virtual QtConfigWidget *createConfigurationWidget() const; + +protected: + QList<ProjectExplorer::Task> reportIssuesImpl(const QString &proFile, const QString &buildDir); + void parseMkSpec(ProFileEvaluator *) const; +private: + QString m_sbsV2Directory; + QString m_systemRoot; + mutable bool m_validSystemRoot; + mutable bool m_isBuildUsingSbsV2; +}; + +class SymbianQtConfigWidget : public QtConfigWidget +{ + Q_OBJECT +public: + SymbianQtConfigWidget(SymbianQtVersion *version); +public slots: + void updateCurrentSbsV2Directory(const QString &path); + void updateCurrentS60SDKDirectory(const QString &path); +private: + SymbianQtVersion *m_version; +}; + +} +} + +#endif // SYMBIANQTVERSION_H diff --git a/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.cpp b/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.cpp new file mode 100644 index 0000000000..8777d8d69e --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.cpp @@ -0,0 +1,85 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "symbianqtversionfactory.h" + +#include "qt4projectmanagerconstants.h" +#include "symbianqtversion.h" + +#include <QtCore/QFileInfo> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +SymbianQtVersionFactory::SymbianQtVersionFactory(QObject *parent) + : QtVersionFactory(parent) +{ + +} + +SymbianQtVersionFactory::~SymbianQtVersionFactory() +{ + +} + +bool SymbianQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::SYMBIANQT); +} + +BaseQtVersion *SymbianQtVersionFactory::restore(const QVariantMap &data) +{ + SymbianQtVersion *v = new SymbianQtVersion; + v->fromMap(data); + return v; +} + +int SymbianQtVersionFactory::priority() const +{ + return 50; +} + +BaseQtVersion *SymbianQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + QFileInfo fi(qmakePath); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return 0; + + QString makefileGenerator = evaluator->value("MAKEFILE_GENERATOR"); + if (makefileGenerator == QLatin1String("SYMBIAN_ABLD") || + makefileGenerator == QLatin1String("SYMBIAN_SBSV2") || + makefileGenerator == QLatin1String("SYMBIAN_UNIX")) { + return new SymbianQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + } + + return 0; +} diff --git a/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.h b/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.h new file mode 100644 index 0000000000..49959e0b27 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-s60/symbianqtversionfactory.h @@ -0,0 +1,57 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef SYMBIANQTVERSIONFACTORY_H +#define SYMBIANQTVERSIONFACTORY_H + +#include "qtversionfactory.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class SymbianQtVersionFactory : public QtVersionFactory +{ +public: + explicit SymbianQtVersionFactory(QObject *parent = 0); + ~SymbianQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual BaseQtVersion *restore(const QVariantMap &data); + + virtual int priority() const; + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // Internal +} // Qt4ProjectManager + +#endif // SYMBIANQTVERSION_H diff --git a/src/plugins/qt4projectmanager/qt4basetargetfactory.h b/src/plugins/qt4projectmanager/qt4basetargetfactory.h index 24b92f0fb7..c697187100 100644 --- a/src/plugins/qt4projectmanager/qt4basetargetfactory.h +++ b/src/plugins/qt4projectmanager/qt4basetargetfactory.h @@ -43,7 +43,6 @@ namespace Qt4ProjectManager { class Qt4TargetSetupWidget; class QtVersionNumber; -class QtVersion; struct BuildConfigurationInfo; class QT4PROJECTMANAGER_EXPORT Qt4BaseTargetFactory : public ProjectExplorer::ITargetFactory diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp index 9d40a5cb86..384ec721e4 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp @@ -38,6 +38,9 @@ #include "qt4nodes.h" #include "qmakestep.h" #include "makestep.h" +#include "qtversionfactory.h" +#include "baseqtversion.h" +#include "qt4basetargetfactory.h" #include <utils/qtcassert.h> #include <utils/qtcprocess.h> @@ -115,15 +118,13 @@ QVariantMap Qt4BuildConfiguration::toMap() const return map; } -static inline QString msgBuildConfigNotApplicable(const QString &d, const QtVersion *qtVersion, +static inline QString msgBuildConfigNotApplicable(const QString &d, const BaseQtVersion *qtVersion, const Target *target) { return QString::fromLatin1("Warning: Buildconfiguration '%1' : Qt '%2' from %3 not supported by target '%4'"). arg(d, qtVersion->displayName(), qtVersion->qmakeCommand(), target->id()); } -#include "qt4basetargetfactory.h" - bool Qt4BuildConfiguration::fromMap(const QVariantMap &map) { if (!BuildConfiguration::fromMap(map)) @@ -132,49 +133,42 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map) m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY), true).toBool(); m_qtVersionId = map.value(QLatin1String(QT_VERSION_ID_KEY)).toInt(); ProjectExplorer::ToolChain *tc = toolChain(); - m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt()); + m_qmakeBuildConfiguration = BaseQtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt()); m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY), defaultShadowBuildDirectory()).toString(); - m_lastEmmitedBuildDirectory = buildDirectory(); - // Pick a Qt version if the default version is used: // We assume that the default Qt version was used in earlier versions of Qt creator. - // Pick a Qt version that is supporting a desktop. + // Pick a Qt version that supports this target (usually desktop) if (m_qtVersionId == 0) { - QList<QtVersion *> versions = QtVersionManager::instance()->versions(); - foreach (QtVersion *v, versions) { - if (v->isValid() && v->supportsTargetId(QLatin1String(Constants::DESKTOP_TARGET_ID))) { + QList<BaseQtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(target()->id()); + foreach (BaseQtVersion *v, versions) { + if (v->isValid()) { m_qtVersionId = v->uniqueId(); break; } } if (m_qtVersionId == 0) - m_qtVersionId = versions.at(0)->uniqueId(); + m_qtVersionId = -1; } - QtVersion *version = qtVersion(); - if (!map.contains(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.NeedsV0Update"))) { // we are not upgrading from pre-targets! - if (version->isValid() && !version->supportedTargetIds().contains(target()->id())) { - qWarning("%s", qPrintable(msgBuildConfigNotApplicable(displayName(), version, target()))); - return false; - } - } else { - if (!version->isValid() || !version->supportedTargetIds().contains(target()->id())) { - qWarning("%s", qPrintable(msgBuildConfigNotApplicable(displayName(), version, target()))); - return false; - } + BaseQtVersion *version = QtVersionManager::instance()->version(m_qtVersionId); + if (!version || !version->supportsTargetId(target()->id())) { + m_qtVersionId = -1; + version = 0; } - if (version->isValid()) { - if (!tc) + m_lastEmmitedBuildDirectory = buildDirectory(); + + if (version && version->isValid()) { + if (tc && !qt4Target()->possibleToolChains(this).contains(tc)) + setToolChain(0); + if (!toolChain()) tc = qt4Target()->preferredToolChain(this); - if (tc && qt4Target()->possibleToolChains(this).contains(tc)) - setToolChain(tc); m_shadowBuild = (m_shadowBuild && version->supportsShadowBuilds()); } if (!toolChain()) { - if (version->isValid()) { + if (version && version->isValid()) { qWarning("Warning: No tool chain available for '%s' from %s used in '%s'.", qPrintable(version->displayName()), qPrintable(version->qmakeCommand()), qPrintable(target()->id())); @@ -182,7 +176,6 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map) qWarning("Warning: No tool chain available for invalid Qt version used in '%s'.", qPrintable(target()->id())); } - return false; } return true; @@ -208,15 +201,6 @@ void Qt4BuildConfiguration::emitBuildDirectoryChanged() } } -void Qt4BuildConfiguration::pickValidQtVersion() -{ - QList<QtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(qt4Target()->id()); - if (!versions.isEmpty()) - setQtVersion(versions.at(0)); - else - setQtVersion(QtVersionManager::instance()->emptyVersion()); -} - Qt4BaseTarget *Qt4BuildConfiguration::qt4Target() const { return static_cast<Qt4BaseTarget *>(target()); @@ -225,7 +209,8 @@ Qt4BaseTarget *Qt4BuildConfiguration::qt4Target() const Utils::Environment Qt4BuildConfiguration::baseEnvironment() const { Utils::Environment env = BuildConfiguration::baseEnvironment(); - qtVersion()->addToEnvironment(env); + if (qtVersion()) + qtVersion()->addToEnvironment(env); ToolChain *tc = toolChain(); if (tc) @@ -300,9 +285,9 @@ QString Qt4BuildConfiguration::shadowBuildDirectory() const void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory) { - QtVersion *version = qtVersion(); + BaseQtVersion *version = qtVersion(); QString directoryToSet = buildDirectory; - bool toSet = (shadowBuild && version->isValid() && version->supportsShadowBuilds()); + bool toSet = (shadowBuild && version && version->isValid() && version->supportsShadowBuilds()); if (m_shadowBuild == toSet && m_buildDirectory == directoryToSet) return; @@ -320,10 +305,10 @@ QString Qt4BuildConfiguration::makeCommand() const return tc ? tc->makeCommand() : "make"; } -static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfigs buildConfig, +static inline QString symbianMakeTarget(BaseQtVersion::QmakeBuildConfigs buildConfig, const QString &type) { - QString rc = (buildConfig & QtVersion::DebugBuild) ? + QString rc = (buildConfig & BaseQtVersion::DebugBuild) ? QLatin1String("debug-") : QLatin1String("release-"); rc += type; return rc; @@ -334,7 +319,7 @@ QString Qt4BuildConfiguration::defaultMakeTarget() const ToolChain *tc = toolChain(); if (!tc || target()->id() != Constants::S60_DEVICE_TARGET_ID) return QString(); - const QtVersion::QmakeBuildConfigs buildConfig = qmakeBuildConfiguration(); + const BaseQtVersion::QmakeBuildConfigs buildConfig = qmakeBuildConfiguration(); return symbianMakeTarget(buildConfig, tc->defaultMakeTarget()); } @@ -344,18 +329,26 @@ QString Qt4BuildConfiguration::makefile() const return qt4Target()->qt4Project()->rootProjectNode()->makefile(); } -QtVersion *Qt4BuildConfiguration::qtVersion() const +BaseQtVersion *Qt4BuildConfiguration::qtVersion() const { QtVersionManager *vm = QtVersionManager::instance(); return vm->version(m_qtVersionId); } -void Qt4BuildConfiguration::setQtVersion(QtVersion *version) +void Qt4BuildConfiguration::setQtVersion(BaseQtVersion *version) { - Q_ASSERT(version); - - if (m_qtVersionId == version->uniqueId()) + if (version == 0) { + m_qtVersionId = -1; + m_shadowBuild = false; + setToolChain(0); + emit proFileEvaluateNeeded(this); + emit qtVersionChanged(); + emit environmentChanged(); + emitBuildDirectoryChanged(); return; + } + if (m_qtVersionId == version->uniqueId()) + return; m_qtVersionId = version->uniqueId(); @@ -371,23 +364,21 @@ void Qt4BuildConfiguration::setQtVersion(QtVersion *version) void Qt4BuildConfiguration::setToolChain(ProjectExplorer::ToolChain *tc) { - Q_ASSERT(qtVersion()); if (tc != 0 && !qt4Target()->possibleToolChains(this).contains(tc)) return; BuildConfiguration::setToolChain(tc); emit proFileEvaluateNeeded(this); - emit environmentChanged(); emitBuildDirectoryChanged(); } -QtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const +BaseQtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const { return m_qmakeBuildConfiguration; } -void Qt4BuildConfiguration::setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config) +void Qt4BuildConfiguration::setQMakeBuildConfiguration(BaseQtVersion::QmakeBuildConfigs config) { if (m_qmakeBuildConfiguration == config) return; @@ -422,20 +413,20 @@ void Qt4BuildConfiguration::emitS60CreatesSmartInstallerChanged() QStringList Qt4BuildConfiguration::configCommandLineArguments() const { QStringList result; - QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion()->defaultBuildConfig(); - QtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration; - if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(userBuildConfiguration & QtVersion::BuildAll)) + BaseQtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion() ? qtVersion()->defaultBuildConfig() : (BaseQtVersion::DebugBuild | BaseQtVersion::BuildAll); + BaseQtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration; + if ((defaultBuildConfiguration & BaseQtVersion::BuildAll) && !(userBuildConfiguration & BaseQtVersion::BuildAll)) result << "CONFIG-=debug_and_release"; - if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (userBuildConfiguration & QtVersion::BuildAll)) + if (!(defaultBuildConfiguration & BaseQtVersion::BuildAll) && (userBuildConfiguration & BaseQtVersion::BuildAll)) result << "CONFIG+=debug_and_release"; - if ((defaultBuildConfiguration & QtVersion::DebugBuild) - && !(userBuildConfiguration & QtVersion::DebugBuild) - && !(userBuildConfiguration & QtVersion::BuildAll)) + if ((defaultBuildConfiguration & BaseQtVersion::DebugBuild) + && !(userBuildConfiguration & BaseQtVersion::DebugBuild) + && !(userBuildConfiguration & BaseQtVersion::BuildAll)) result << "CONFIG+=release"; - if (!(defaultBuildConfiguration & QtVersion::DebugBuild) - && (userBuildConfiguration & QtVersion::DebugBuild) - && !(userBuildConfiguration & QtVersion::BuildAll)) + if (!(defaultBuildConfiguration & BaseQtVersion::DebugBuild) + && (userBuildConfiguration & BaseQtVersion::DebugBuild) + && !(userBuildConfiguration & BaseQtVersion::BuildAll)) result << "CONFIG+=debug"; return result; } @@ -466,8 +457,6 @@ void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &changedVersions) { if (!changedVersions.contains(m_qtVersionId)) return; - if (!qtVersion()->isValid()) - pickValidQtVersion(); emit environmentChanged(); // Our qt version changed, that might have changed the environment } @@ -477,10 +466,12 @@ bool Qt4BuildConfiguration::compareToImportFrom(const QString &makefile) QMakeStep *qs = qmakeStep(); if (QFileInfo(makefile).exists() && qs) { QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile); - QtVersion *version = qtVersion(); + BaseQtVersion *version = qtVersion(); + if (!version) + return false; if (version->qmakeCommand() == qmakePath) { // same qtversion - QPair<QtVersion::QmakeBuildConfigs, QString> result = + QPair<BaseQtVersion::QmakeBuildConfigs, QString> result = QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig()); if (qmakeBuildConfiguration() == result.first) { // The qmake Build Configuration are the same, @@ -552,7 +543,7 @@ void Qt4BuildConfiguration::removeQMLInspectorFromArguments(QString *args) } QString Qt4BuildConfiguration::extractSpecFromArguments(QString *args, - const QString &directory, const QtVersion *version, + const QString &directory, const BaseQtVersion *version, QStringList *outArgs) { QString parsedSpec; @@ -674,13 +665,11 @@ void Qt4BuildConfigurationFactory::update() { m_versions.clear(); QtVersionManager *vm = QtVersionManager::instance(); - foreach (const QtVersion *version, vm->versions()) { - if (version->isValid()) { - QString key = QString::fromLatin1(QT4_BC_ID_PREFIX) - + QString::fromLatin1("Qt%1").arg(version->uniqueId()); - VersionInfo info(tr("Using Qt Version \"%1\"").arg(version->displayName()), version->uniqueId()); - m_versions.insert(key, info); - } + foreach (BaseQtVersion *version, vm->validVersions()) { + QString key = QString::fromLatin1(QT4_BC_ID_PREFIX) + + QString::fromLatin1("Qt%1").arg(version->uniqueId()); + VersionInfo info(tr("Using Qt Version \"%1\"").arg(version->displayName()), version->uniqueId()); + m_versions.insert(key, info); } emit availableCreationIdsChanged(); } @@ -715,7 +704,7 @@ bool Qt4BuildConfigurationFactory::canCreate(ProjectExplorer::Target *parent, co if (!m_versions.contains(id)) return false; const VersionInfo &info = m_versions.value(id); - QtVersion *version = QtVersionManager::instance()->version(info.versionId); + BaseQtVersion *version = QtVersionManager::instance()->version(info.versionId); if (!version || !version->supportsTargetId(parent->id())) return false; @@ -728,7 +717,7 @@ BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Target return 0; const VersionInfo &info = m_versions.value(id); - QtVersion *version = QtVersionManager::instance()->version(info.versionId); + BaseQtVersion *version = QtVersionManager::instance()->version(info.versionId); Q_ASSERT(version); Qt4BaseTarget *qt4Target = static_cast<Qt4BaseTarget *>(parent); @@ -747,13 +736,14 @@ BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Target //: Debug build configuration. We recommend not translating it. BuildConfiguration *bc = qt4Target->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName), version, - (version->defaultBuildConfig() | QtVersion::DebugBuild), + (version->defaultBuildConfig() | BaseQtVersion::DebugBuild), QString(), QString()); + if (qt4Target->id() != Constants::S60_EMULATOR_TARGET_ID) { //: Release build configuration. We recommend not translating it. bc = qt4Target->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName), version, - (version->defaultBuildConfig() & ~QtVersion::DebugBuild), + (version->defaultBuildConfig() & ~BaseQtVersion::DebugBuild), QString(), QString()); } return bc; @@ -767,7 +757,7 @@ bool Qt4BuildConfigurationFactory::canClone(ProjectExplorer::Target *parent, Pro if (!qt4bc) return false; - QtVersion *version = qt4bc->qtVersion(); + BaseQtVersion *version = qt4bc->qtVersion(); if (!version || !version->supportsTargetId(parent->id())) return false; @@ -817,15 +807,15 @@ void Qt4BuildConfiguration::importFromBuildDirectory() QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(mkfile); if (!qmakePath.isEmpty()) { QtVersionManager *vm = QtVersionManager::instance(); - QtVersion *version = vm->qtVersionForQMakeBinary(qmakePath); + BaseQtVersion *version = vm->qtVersionForQMakeBinary(qmakePath); if (!version) { - version = new QtVersion(qmakePath); + version = QtVersionFactory::createQtVersionFromQMakePath(qmakePath); vm->addVersion(version); } - QPair<QtVersion::QmakeBuildConfigs, QString> result = + QPair<BaseQtVersion::QmakeBuildConfigs, QString> result = QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig()); - QtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first; + BaseQtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first; QString aa = result.second; QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArguments(&aa, directory, version); @@ -850,8 +840,8 @@ void Qt4BuildConfiguration::importFromBuildDirectory() // If we are switching to BuildAll we want "release" in there and no "debug" // or "debug" in there and no "release" // If we are switching to not BuildAl we want neither "release" nor "debug" in there - bool debug = qmakeBuildConfig & QtVersion::DebugBuild; - bool haveTag = !(qmakeBuildConfig & QtVersion::BuildAll); + bool debug = qmakeBuildConfig & BaseQtVersion::DebugBuild; + bool haveTag = !(qmakeBuildConfig & BaseQtVersion::BuildAll); QString makeCmdArguments = makeStep()->userArguments(); Utils::QtcProcess::ArgIterator ait(&makeCmdArguments); while (ait.next()) { @@ -876,7 +866,7 @@ void Qt4BuildConfiguration::importFromBuildDirectory() BuildConfiguration::BuildType Qt4BuildConfiguration::buildType() const { - if (qmakeBuildConfiguration() & QtVersion::DebugBuild) + if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) return Debug; else return Release; diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.h b/src/plugins/qt4projectmanager/qt4buildconfiguration.h index 3bf88ec4d4..18355a88d0 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfiguration.h +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.h @@ -75,13 +75,13 @@ public: Qt4ProjectManager::Internal::Qt4ProFileNode *subNodeBuild() const; // returns the qtVersion - QtVersion *qtVersion() const; - void setQtVersion(QtVersion *); + BaseQtVersion *qtVersion() const; + void setQtVersion(BaseQtVersion *); void setToolChain(ProjectExplorer::ToolChain *tc); - QtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const; - void setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config); + BaseQtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const; + void setQMakeBuildConfiguration(BaseQtVersion::QmakeBuildConfigs config); /// \internal for qmakestep // used by qmake step to notify that the qmake args have changed @@ -112,7 +112,7 @@ public: bool compareToImportFrom(const QString &makefile); static void removeQMLInspectorFromArguments(QString *args); static QString extractSpecFromArguments(QString *arguments, - const QString &directory, const QtVersion *version, + const QString &directory, const BaseQtVersion *version, QStringList *outArgs = 0); QVariantMap toMap() const; @@ -165,7 +165,7 @@ private: QString m_buildDirectory; QString m_lastEmmitedBuildDirectory; int m_qtVersionId; - QtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration; + BaseQtVersion::QmakeBuildConfigs m_qmakeBuildConfiguration; Qt4ProjectManager::Internal::Qt4ProFileNode *m_subNodeBuild; }; diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index e0998da4b8..3ae8cc2b22 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -2066,7 +2066,7 @@ TargetInformation Qt4ProFileNode::targetInformation(ProFileReader *reader) const // Hmm can we find out whether it's debug or release in a saner way? // Theoretically it's in CONFIG QString qmakeBuildConfig = "release"; - if (m_project->activeTarget()->activeBuildConfiguration()->qmakeBuildConfiguration() & QtVersion::DebugBuild) + if (m_project->activeTarget()->activeBuildConfiguration()->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) qmakeBuildConfig = "debug"; wd += QLatin1Char('/') + qmakeBuildConfig; } diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index a2f6674867..8c4b21600a 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -43,6 +43,7 @@ #include "qt4buildconfiguration.h" #include "findqt4profiles.h" #include "qmldumptool.h" +#include "baseqtversion.h" #include <coreplugin/icore.h> #include <coreplugin/icontext.h> @@ -433,7 +434,9 @@ void Qt4Project::updateCppCodeModel() QStringList predefinedFrameworkPaths; QByteArray predefinedMacros; - QString qtFrameworkPath = activeBC->qtVersion()->frameworkInstallPath(); + QString qtFrameworkPath; + if (activeBC->qtVersion()) + qtFrameworkPath = activeBC->qtVersion()->frameworkInstallPath(); if (!qtFrameworkPath.isEmpty()) predefinedFrameworkPaths.append(qtFrameworkPath); @@ -442,7 +445,8 @@ void Qt4Project::updateCppCodeModel() predefinedMacros = tc->predefinedMacros(); QList<HeaderPath> headers = tc->systemHeaderPaths(); - headers.append(activeBC->qtVersion()->systemHeaderPathes()); + if (activeBC->qtVersion()) + headers.append(activeBC->qtVersion()->systemHeaderPathes()); foreach (const HeaderPath &headerPath, headers) { if (headerPath.kind() == HeaderPath::FrameworkHeaderPath) predefinedFrameworkPaths.append(headerPath.path()); @@ -485,26 +489,11 @@ void Qt4Project::updateCppCodeModel() if (!allIncludePaths.contains(includePath)) allIncludePaths.append(includePath); } - -#if 0 // Experimental PKGCONFIG support - { // Pkg Config support - QStringList pkgConfig = pro->variableValue(PkgConfigVar); - if (!pkgConfig.isEmpty()) { - pkgConfig.prepend("--cflags-only-I"); - QProcess process; - process.start("pkg-config", pkgConfig); - process.waitForFinished(); - QString result = process.readAllStandardOutput(); - foreach(const QString &part, result.trimmed().split(' ', QString::SkipEmptyParts)) { - info.includes.append(part.mid(2)); // Chop off "-I" - } - } - } -#endif } // Add mkspec directory - allIncludePaths.append(activeBC->qtVersion()->mkspecPath()); + if (activeBC->qtVersion()) + allIncludePaths.append(activeBC->qtVersion()->mkspecPath()); allIncludePaths.append(predefinedIncludePaths); @@ -565,9 +554,9 @@ void Qt4Project::updateQmlJSCodeModel() } bool preferDebugDump = false; if (activeTarget() && activeTarget()->activeBuildConfiguration()) { - preferDebugDump = activeTarget()->activeBuildConfiguration()->qmakeBuildConfiguration() & QtVersion::DebugBuild; - const QtVersion *qtVersion = activeTarget()->activeBuildConfiguration()->qtVersion(); - if (qtVersion->isValid()) { + preferDebugDump = activeTarget()->activeBuildConfiguration()->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild; + BaseQtVersion *qtVersion = activeTarget()->activeBuildConfiguration()->qtVersion(); + if (qtVersion && qtVersion->isValid()) { const QString qtVersionImportPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS"); if (!qtVersionImportPath.isEmpty()) projectInfo.importPaths += qtVersionImportPath; @@ -885,8 +874,8 @@ ProFileReader *Qt4Project::createProFileReader(Qt4ProFileNode *qt4ProFileNode, Q bc = activeTarget()->activeBuildConfiguration(); if (bc) { - QtVersion *version = bc->qtVersion(); - if (version->isValid()) { + BaseQtVersion *version = bc->qtVersion(); + if (version && version->isValid()) { m_proFileOption->properties = version->versionInfo(); if (bc->toolChain()) m_proFileOption->sysroot = bc->qtVersion()->systemRoot(); diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 647e3bf2e0..6508b774a1 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -39,6 +39,8 @@ #include "qt4projectmanagerconstants.h" #include "qt4projectmanager.h" #include "qt4buildconfiguration.h" +#include "qtversionfactory.h" +#include "baseqtversion.h" #include "ui_qt4projectconfigwidget.h" #include <coreplugin/icore.h> @@ -125,10 +127,11 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget() void Qt4ProjectConfigWidget::updateDetails() { - QtVersion *version = m_buildConfiguration->qtVersion(); + BaseQtVersion *version = m_buildConfiguration->qtVersion(); QString versionString; - versionString = version->displayName(); + if (version) + versionString = version->displayName(); if (!version || !version->isValid()) { // Not a valid qt version @@ -157,10 +160,11 @@ void Qt4ProjectConfigWidget::environmentChanged() void Qt4ProjectConfigWidget::updateShadowBuildUi() { - m_ui->shadowBuildCheckBox->setEnabled(m_buildConfiguration->qtVersion()->supportsShadowBuilds()); + BaseQtVersion *version = m_buildConfiguration->qtVersion(); + m_ui->shadowBuildCheckBox->setEnabled(version && version->supportsShadowBuilds()); bool isShadowbuilding = m_buildConfiguration->shadowBuild(); - m_ui->shadowBuildDirEdit->setEnabled(isShadowbuilding && m_buildConfiguration->qtVersion()->supportsShadowBuilds()); - m_browseButton->setEnabled(isShadowbuilding && m_buildConfiguration->qtVersion()->supportsShadowBuilds()); + m_ui->shadowBuildDirEdit->setEnabled(isShadowbuilding && version && version->supportsShadowBuilds()); + m_browseButton->setEnabled(isShadowbuilding && version && version->supportsShadowBuilds()); m_ui->shadowBuildDirEdit->setPath(m_buildConfiguration->shadowBuildDirectory()); } @@ -218,7 +222,8 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc) bool shadowBuild = m_buildConfiguration->shadowBuild(); m_ui->shadowBuildCheckBox->setChecked(shadowBuild); - m_ui->shadowBuildCheckBox->setEnabled(m_buildConfiguration->qtVersion()->supportsShadowBuilds()); + m_ui->shadowBuildCheckBox->setEnabled(m_buildConfiguration->qtVersion() + && m_buildConfiguration->qtVersion()->supportsShadowBuilds()); updateShadowBuildUi(); updateImportLabel(); @@ -236,10 +241,11 @@ void Qt4ProjectConfigWidget::qtVersionChanged() if (m_ignoreChange) return; - int versionId = m_buildConfiguration->qtVersion()->uniqueId(); + int versionId = -1; + if (m_buildConfiguration->qtVersion()) + versionId = m_buildConfiguration->qtVersion()->uniqueId(); int comboBoxIndex = m_ui->qtVersionComboBox->findData(QVariant(versionId), Qt::UserRole); - if (comboBoxIndex > -1) - m_ui->qtVersionComboBox->setCurrentIndex(comboBoxIndex); + m_ui->qtVersionComboBox->setCurrentIndex(comboBoxIndex); updateShadowBuildUi(); updateImportLabel(); @@ -253,9 +259,9 @@ void Qt4ProjectConfigWidget::qtVersionsChanged() QtVersionManager *vm = QtVersionManager::instance(); m_ui->qtVersionComboBox->clear(); - QtVersion * qtVersion = m_buildConfiguration->qtVersion(); + BaseQtVersion *qtVersion = m_buildConfiguration->qtVersion(); - const QList<QtVersion *> validVersions(vm->versionsForTargetId(m_buildConfiguration->target()->id())); + QList<BaseQtVersion *> validVersions = vm->versionsForTargetId(m_buildConfiguration->target()->id()); if (!validVersions.isEmpty()) { for (int i = 0; i < validVersions.size(); ++i) { m_ui->qtVersionComboBox->addItem(validVersions.at(i)->displayName(), @@ -265,7 +271,7 @@ void Qt4ProjectConfigWidget::qtVersionsChanged() m_ui->qtVersionComboBox->setCurrentIndex(i); } } - if (!qtVersion->isValid()) { + if (!qtVersion || !qtVersion->isValid()) { m_ui->qtVersionComboBox->addItem(tr("Invalid Qt version"), -1); m_ui->qtVersionComboBox->setCurrentIndex(m_ui->qtVersionComboBox->count() - 1); } @@ -340,7 +346,7 @@ void Qt4ProjectConfigWidget::updateImportLabel() makefile.append(m_buildConfiguration->makefile()); QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(makefile); - QtVersion *version = m_buildConfiguration->qtVersion(); + BaseQtVersion *version = m_buildConfiguration->qtVersion(); // check that there's a makefile if (!qmakePath.isEmpty()) { // Is it from the same build? @@ -353,10 +359,10 @@ void Qt4ProjectConfigWidget::updateImportLabel() // and that the qmake path is different from the current version // import enable visible = true; - QtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath); + BaseQtVersion *newVersion = vm->qtVersionForQMakeBinary(qmakePath); bool mustDelete(false); if (!newVersion) { - newVersion = new QtVersion(qmakePath); + newVersion = QtVersionFactory::createQtVersionFromQMakePath(qmakePath); mustDelete = true; } targetMatches = newVersion->supportsTargetId(m_buildConfiguration->target()->id()); @@ -376,9 +382,11 @@ void Qt4ProjectConfigWidget::updateImportLabel() QString buildDirectory = m_buildConfiguration->target()->project()->projectDirectory();; if (m_buildConfiguration->shadowBuild()) buildDirectory = m_buildConfiguration->buildDirectory(); - QList<ProjectExplorer::Task> issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(), - buildDirectory, - true); + QList<ProjectExplorer::Task> issues; + if (m_buildConfiguration->qtVersion()) + issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(), + buildDirectory, + true); if (incompatibleBuild) { m_ui->problemLabel->setVisible(true); @@ -453,7 +461,7 @@ void Qt4ProjectConfigWidget::qtVersionSelected(const QString &) m_ui->qtVersionComboBox->removeItem(m_ui->qtVersionComboBox->count() - 1); QtVersionManager *vm = QtVersionManager::instance(); - QtVersion *newQtVersion = vm->version(newQtVersionId); + BaseQtVersion *newQtVersion = vm->version(newQtVersionId); m_ignoreChange = true; m_buildConfiguration->setQtVersion(newQtVersion); diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 5c5c7cfb76..9033891084 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -191,8 +191,10 @@ void Qt4Manager::updateVariable(const QString &variable) Core::VariableManager::instance()->remove(QLatin1String(kInstallBins)); return; } - QString value = qt4pro->activeTarget()->activeBuildConfiguration() - ->qtVersion()->versionInfo().value(QLatin1String("QT_INSTALL_BINS")); + QString value; + BaseQtVersion *qtv = qt4pro->activeTarget()->activeBuildConfiguration()->qtVersion(); + if (qtv) + value = qtv->versionInfo().value(QLatin1String("QT_INSTALL_BINS")); Core::VariableManager::instance()->insert(QLatin1String(kInstallBins), value); } } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 1609a3509c..436f4500e1 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -74,7 +74,12 @@ HEADERS += \ debugginghelperbuildtask.h \ qt4targetsetupwidget.h \ qt4basetargetfactory.h \ - buildconfigurationinfo.h + buildconfigurationinfo.h \ + qtversionfactory.h \ + winceqtversionfactory.h \ + baseqtversion.h \ + winceqtversion.h + SOURCES += qt4projectmanagerplugin.cpp \ qtparser.cpp \ qt4projectmanager.cpp \ @@ -139,7 +144,11 @@ SOURCES += qt4projectmanagerplugin.cpp \ qmldebugginglibrary.cpp \ profilecompletion.cpp \ profilekeywords.cpp \ - debugginghelperbuildtask.cpp + debugginghelperbuildtask.cpp \ + qtversionfactory.cpp \ + winceqtversionfactory.cpp \ + baseqtversion.cpp \ + winceqtversion.cpp FORMS += makestep.ui \ qmakestep.ui \ qt4projectconfigwidget.ui \ diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index b273b43640..2075d6be23 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -111,6 +111,13 @@ const char * const MAEMO_TOOLCHAIN_ID = "Qt4ProjectManager.ToolChain.Maemo"; const char * const RVCT_TOOLCHAIN_ID = "Qt4ProjectManager.ToolChain.RVCT"; const char * const WINSCW_TOOLCHAIN_ID = "Qt4ProjectManager.ToolChain.WINSCW"; +// QtVersions +const char * const SYMBIANQT = "Qt4ProjectManager.QtVersion.Symbian"; +const char * const MAEMOQT = "Qt4ProjectManager.QtVersion.Maemo"; +const char * const DESKTOPQT = "Qt4ProjectManager.QtVersion.Desktop"; +const char * const SIMULATORQT = "Qt4ProjectManager.QtVersion.Simulator"; +const char * const WINCEQT = "Qt4ProjectManager.QtVersion.WinCE"; + // ICONS const char * const ICON_QT_PROJECT = ":/qt4projectmanager/images/qt_project.png"; const char * const ICON_WINDOW = ":/qt4projectmanager/images/window.png"; diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index c35d4dcee4..feb220c2d7 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -61,6 +61,9 @@ #include "qt-desktop/qt4desktoptargetfactory.h" #include "qt-desktop/qt4simulatortargetfactory.h" #include "qt-desktop/qt4runconfiguration.h" +#include "qt-desktop/desktopqtversionfactory.h" +#include "qt-desktop/simulatorqtversionfactory.h" +#include "winceqtversionfactory.h" #include <coreplugin/uniqueidmanager.h> #include <coreplugin/icore.h> @@ -120,6 +123,8 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); Core::ActionManager *am = core->actionManager(); + new ProFileCacheManager(this); + QtVersionManager *mgr = new QtVersionManager; addAutoReleasedObject(mgr); addAutoReleasedObject(new QtOptionsPage); @@ -171,6 +176,10 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * addAutoReleasedObject(new Qt4DesktopTargetFactory); addAutoReleasedObject(new Qt4SimulatorTargetFactory); + addAutoReleasedObject(new DesktopQtVersionFactory); + addAutoReleasedObject(new SimulatorQtVersionFactory); + addAutoReleasedObject(new WinCeQtVersionFactory); + ProFileCompletion *completion = new ProFileCompletion; addAutoReleasedObject(completion); // Set completion settings and keep them up to date @@ -179,8 +188,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings))); - new ProFileCacheManager(this); - // TODO reenable //m_embeddedPropertiesPage = new EmbeddedPropertiesPage; //addObject(m_embeddedPropertiesPage); @@ -287,6 +294,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString * void Qt4ProjectManagerPlugin::extensionsInitialized() { m_qt4ProjectManager->init(); + QtVersionManager::instance()->extensionsInitialized(); } void Qt4ProjectManagerPlugin::updateContextMenu(Project *project, diff --git a/src/plugins/qt4projectmanager/qt4target.cpp b/src/plugins/qt4projectmanager/qt4target.cpp index 7ca0a325e3..a037bb7925 100644 --- a/src/plugins/qt4projectmanager/qt4target.cpp +++ b/src/plugins/qt4projectmanager/qt4target.cpp @@ -38,6 +38,8 @@ #include "qt4project.h" #include "qt4basetargetfactory.h" #include "qt4projectconfigwidget.h" +#include "qtversionfactory.h" +#include "baseqtversion.h" #include <coreplugin/icore.h> #include <extensionsystem/pluginmanager.h> @@ -104,17 +106,17 @@ ProjectExplorer::Target *Qt4BaseTargetFactory::create(ProjectExplorer::Project * QList<BuildConfigurationInfo> Qt4BaseTargetFactory::availableBuildConfigurations(const QString &id, const QString &proFilePath, const QtVersionNumber &minimumQtVersion) { QList<BuildConfigurationInfo> infoList; - QList<QtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id, minimumQtVersion); + QList<BaseQtVersion *> knownVersions = QtVersionManager::instance()->versionsForTargetId(id, minimumQtVersion); - foreach (QtVersion *version, knownVersions) { + foreach (BaseQtVersion *version, knownVersions) { if (!version->isValid() || !version->toolChainAvailable(id)) continue; - QtVersion::QmakeBuildConfigs config = version->defaultBuildConfig(); + BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig(); BuildConfigurationInfo info = BuildConfigurationInfo(version, config, QString(), QString()); info.directory = shadowBuildDirectory(proFilePath, id, msgBuildConfigurationName(info)); infoList.append(info); - info.buildConfig = config ^ QtVersion::DebugBuild; + info.buildConfig = config ^ BaseQtVersion::DebugBuild; info.directory = shadowBuildDirectory(proFilePath, id, msgBuildConfigurationName(info)); infoList.append(info); } @@ -176,7 +178,7 @@ Qt4BaseTargetFactory *Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(const QStr QString Qt4BaseTargetFactory::msgBuildConfigurationName(const BuildConfigurationInfo &info) { const QString qtVersionName = info.version->displayName(); - return (info.buildConfig & QtVersion::DebugBuild) ? + return (info.buildConfig & BaseQtVersion::DebugBuild) ? //: Name of a debug build configuration to created by a project wizard, %1 being the Qt version name. We recommend not translating it. tr("%1 Debug").arg(qtVersionName) : //: Name of a release build configuration to created by a project wizard, %1 being the Qt version name. We recommend not translating it. @@ -229,7 +231,7 @@ QList<ProjectExplorer::ToolChain *> Qt4BaseTarget::possibleToolChains(ProjectExp QList<ProjectExplorer::ToolChain *> result; Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(bc); - if (!qt4bc && !qt4bc->qtVersion()->isValid()) + if (!qt4bc || !qt4bc->qtVersion() || !qt4bc->qtVersion()->isValid()) return tmp; QList<ProjectExplorer::Abi> abiList = qt4bc->qtVersion()->qtAbis(); @@ -261,13 +263,13 @@ void Qt4BaseTarget::removeUnconfiguredCustomExectutableRunConfigurations() } } -Qt4BuildConfiguration *Qt4BaseTarget::addQt4BuildConfiguration(QString displayName, QtVersion *qtversion, - QtVersion::QmakeBuildConfigs qmakeBuildConfiguration, +Qt4BuildConfiguration *Qt4BaseTarget::addQt4BuildConfiguration(QString displayName, BaseQtVersion *qtversion, + BaseQtVersion::QmakeBuildConfigs qmakeBuildConfiguration, QString additionalArguments, QString directory) { Q_ASSERT(qtversion); - bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild; + bool debug = qmakeBuildConfiguration & BaseQtVersion::DebugBuild; // Add the buildconfiguration Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this); @@ -292,7 +294,7 @@ Qt4BuildConfiguration *Qt4BaseTarget::addQt4BuildConfiguration(QString displayNa qmakeStep->setUserArguments(additionalArguments); // set some options for qmake and make - if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets + if (qmakeBuildConfiguration & BaseQtVersion::BuildAll) // debug_and_release => explicit targets makeStep->setUserArguments(debug ? "debug" : "release"); bc->setQMakeBuildConfiguration(qmakeBuildConfiguration); @@ -582,8 +584,8 @@ void Qt4DefaultTargetSetupWidget::targetCheckBoxToggled(bool b) QString Qt4DefaultTargetSetupWidget::displayNameFrom(const BuildConfigurationInfo &info) { QString buildType; - if ((info.buildConfig & QtVersion::BuildAll) == 0) { - if (info.buildConfig & QtVersion::DebugBuild) + if ((info.buildConfig & BaseQtVersion::BuildAll) == 0) { + if (info.buildConfig & BaseQtVersion::DebugBuild) //: Debug build buildType = tr("debug"); else @@ -772,14 +774,14 @@ void Qt4DefaultTargetSetupWidget::setBuildConfigurationInfos(const QList<BuildCo int oldQtVersionId = -1; if (m_versionComboBox->currentIndex() != -1) oldQtVersionId = m_versionComboBox->itemData(m_versionComboBox->currentIndex()).toInt(); - QList<QtVersion *> list; + QList<BaseQtVersion *> list; foreach (const BuildConfigurationInfo &info, m_infos) { if (!list.contains(info.version)) list << info.version; } m_ignoreChange = true; m_versionComboBox->clear(); - foreach (QtVersion *v, list) { + foreach (BaseQtVersion *v, list) { m_versionComboBox->addItem(v->displayName(), v->uniqueId()); if (v->uniqueId() == oldQtVersionId) m_versionComboBox->setCurrentIndex(m_versionComboBox->count() - 1); @@ -1001,7 +1003,9 @@ QPair<ProjectExplorer::Task::TaskType, QString> Qt4DefaultTargetSetupWidget::fin return qMakePair(ProjectExplorer::Task::Unknown, QString()); QString buildDir = info.directory; - QtVersion *version = info.version; + if (!m_shadowBuildEnabled->isChecked()) + buildDir = QFileInfo(m_proFilePath).absolutePath(); + BaseQtVersion *version = info.version; QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath, buildDir, false); @@ -1083,13 +1087,15 @@ BuildConfigurationInfo BuildConfigurationInfo::checkForBuild(const QString &dire return BuildConfigurationInfo(); bool temporaryQtVersion = false; - QtVersion *version = QtVersionManager::instance()->qtVersionForQMakeBinary(qmakeBinary); + BaseQtVersion *version = QtVersionManager::instance()->qtVersionForQMakeBinary(qmakeBinary); if (!version) { - version = new QtVersion(qmakeBinary); + version = QtVersionFactory::createQtVersionFromQMakePath(qmakeBinary); temporaryQtVersion = true; + if (!version) + return BuildConfigurationInfo(); } - QPair<QtVersion::QmakeBuildConfigs, QString> makefileBuildConfig = + QPair<BaseQtVersion::QmakeBuildConfigs, QString> makefileBuildConfig = QtVersionManager::scanMakeFile(makefile, version->defaultBuildConfig()); QString additionalArguments = makefileBuildConfig.second; diff --git a/src/plugins/qt4projectmanager/qt4target.h b/src/plugins/qt4projectmanager/qt4target.h index add7a9c206..f98aa3332f 100644 --- a/src/plugins/qt4projectmanager/qt4target.h +++ b/src/plugins/qt4projectmanager/qt4target.h @@ -78,8 +78,8 @@ public: // This is the same for almost all Qt4Targets // so for now offer a convience function Qt4BuildConfiguration *addQt4BuildConfiguration(QString displayName, - QtVersion *qtversion, - QtVersion::QmakeBuildConfigs qmakeBuildConfiguration, + BaseQtVersion *qtversion, + BaseQtVersion::QmakeBuildConfigs qmakeBuildConfiguration, QString additionalArguments, QString directory); diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index 63ed90911a..c152ec81cb 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -36,30 +36,21 @@ #include "ui_qtversioninfo.h" #include "ui_debugginghelper.h" #include "qt4projectmanagerconstants.h" -#include "qt4target.h" #include "qtversionmanager.h" +#include "qtversionfactory.h" -#include <projectexplorer/abi.h> -#include <projectexplorer/debugginghelper.h> -#include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> #include <coreplugin/progressmanager/progressmanager.h> -#include <utils/detailsbutton.h> #include <utils/treewidgetcolumnstretcher.h> #include <utils/qtcassert.h> +#include <utils/buildablehelperlibrary.h> #include <qtconcurrent/runextensions.h> -#include <QtCore/QFuture> -#include <QtCore/QtConcurrentRun> -#include <QtCore/QDebug> #include <QtCore/QDir> -#include <QtCore/QSet> -#include <QtCore/QTextStream> -#include <QtCore/QDateTime> -#include <QtGui/QHelpEvent> #include <QtGui/QToolTip> -#include <QtGui/QMenu> #include <QtGui/QMessageBox> +#include <QtGui/QFileDialog> +#include <QtGui/QMainWindow> enum ModelRoles { VersionIdRole = Qt::UserRole, BuildLogRole, BuildRunningRole}; @@ -117,7 +108,6 @@ void QtOptionsPage::apply() QtVersionManager *vm = QtVersionManager::instance(); vm->setNewQtVersions(m_widget->versions()); - m_widget->updateState(); } bool QtOptionsPage::matches(const QString &s) const @@ -128,27 +118,22 @@ bool QtOptionsPage::matches(const QString &s) const //----------------------------------------------------- -QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> versions) +QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *> versions) : QWidget(parent) , m_specifyNameString(tr("<specify a name>")) - , m_specifyPathString(tr("<specify a qmake location>")) , m_ui(new Internal::Ui::QtVersionManager()) , m_versionUi(new Internal::Ui::QtVersionInfo()) , m_debuggingHelperUi(new Internal::Ui::DebuggingHelper()) , m_invalidVersionIcon(":/projectexplorer/images/compile_error.png") + , m_configurationWidget(0) { // Initialize m_versions - foreach(QtVersion *version, versions) - m_versions.push_back(new QtVersion(*version)); + foreach(BaseQtVersion *version, versions) + m_versions.push_back(version->clone()); QWidget *versionInfoWidget = new QWidget(); m_versionUi->setupUi(versionInfoWidget); - m_versionUi->qmakePath->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_versionUi->qmakePath->setPromptDialogTitle(tr("Select qmake Executable")); - m_versionUi->s60SDKPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); - m_versionUi->s60SDKPath->setPromptDialogTitle(tr("Select S60 SDK Root")); - QWidget *debuggingHelperDetailsWidget = new QWidget(); m_debuggingHelperUi->setupUi(debuggingHelperDetailsWidget); @@ -172,32 +157,23 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver manualItem->setFirstColumnSpanned(true); for (int i = 0; i < m_versions.count(); ++i) { - const QtVersion * const version = m_versions.at(i); + BaseQtVersion *version = m_versions.at(i); QTreeWidgetItem *item = new QTreeWidgetItem(version->isAutodetected()? autoItem : manualItem); item->setText(0, version->displayName()); item->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); item->setData(0, VersionIdRole, version->uniqueId()); + item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon); } m_ui->qtdirList->expandAll(); connect(m_versionUi->nameEdit, SIGNAL(textEdited(const QString &)), this, SLOT(updateCurrentQtName())); - connect(m_versionUi->qmakePath, SIGNAL(changed(QString)), - this, SLOT(updateCurrentQMakeLocation())); - connect(m_versionUi->s60SDKPath, SIGNAL(changed(QString)), - this, SLOT(updateCurrentS60SDKDirectory())); - connect(m_versionUi->sbsV2Path, SIGNAL(changed(QString)), - this, SLOT(updateCurrentSbsV2Directory())); - connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addQtDir())); connect(m_ui->delButton, SIGNAL(clicked()), this, SLOT(removeQtDir())); - connect(m_versionUi->qmakePath, SIGNAL(browsingFinished()), - this, SLOT(onQtBrowsed())); - connect(m_ui->qtdirList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(versionChanged(QTreeWidgetItem *, QTreeWidgetItem *))); @@ -216,8 +192,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver this, SLOT(slotShowDebuggingBuildLog())); connect(m_ui->cleanUpButton, SIGNAL(clicked()), this, SLOT(cleanUpQtVersions())); - showEnvironmentPage(0); - updateState(); + userChangedCurrentVersion(); + updateCleanUpButton(); } bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e) @@ -247,7 +223,7 @@ int QtOptionsPageWidget::currentIndex() const return -1; } -QtVersion *QtOptionsPageWidget::currentVersion() const +BaseQtVersion *QtOptionsPageWidget::currentVersion() const { const int currentItemIndex = currentIndex(); if (currentItemIndex >= 0 && currentItemIndex < m_versions.size()) @@ -255,7 +231,7 @@ QtVersion *QtOptionsPageWidget::currentVersion() const return 0; } -static inline int findVersionById(const QList<QtVersion *> &l, int id) +static inline int findVersionById(const QList<BaseQtVersion *> &l, int id) { const int size = l.size(); for (int i = 0; i < size; i++) @@ -271,7 +247,8 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, const QS if (index == -1) return; // Oops, somebody managed to delete the version - m_versions.at(index)->invalidateCache(); + BaseQtVersion *version = m_versions.at(index); + version->recheckDumper(); // Update item view QTreeWidgetItem *item = treeItemForIndex(index); @@ -282,17 +259,15 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, const QS item->setData(0, BuildRunningRole, QVariant::fromValue(buildFlags)); item->setData(0, BuildLogRole, output); - QtVersion *qtVersion = m_versions.at(index); - bool success = true; if (tools & DebuggingHelperBuildTask::GdbDebugging) - success &= qtVersion->hasGdbDebuggingHelper(); + success &= version->hasGdbDebuggingHelper(); if (tools & DebuggingHelperBuildTask::QmlDebugging) - success &= qtVersion->hasQmlDebuggingLibrary(); + success &= version->hasQmlDebuggingLibrary(); if (tools & DebuggingHelperBuildTask::QmlDump) - success &= qtVersion->hasQmlDump(); + success &= version->hasQmlDump(); if (tools & DebuggingHelperBuildTask::QmlObserver) - success &= qtVersion->hasQmlObserver(); + success &= version->hasQmlObserver(); // Update bottom control if the selection is still the same if (index == currentIndex()) { @@ -305,7 +280,7 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(int qtVersionId, const QS void QtOptionsPageWidget::cleanUpQtVersions() { QStringList toRemove; - foreach (const QtVersion *v, m_versions) { + foreach (const BaseQtVersion *v, m_versions) { if (!v->isValid() && !v->isAutodetected()) toRemove.append(v->displayName()); } @@ -329,7 +304,7 @@ void QtOptionsPageWidget::cleanUpQtVersions() m_versions.removeAt(i); } } - updateState(); + updateCleanUpButton(); } void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools) @@ -346,7 +321,7 @@ void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools t buildFlags |= tools; item->setData(0, BuildRunningRole, QVariant::fromValue(buildFlags)); - QtVersion *version = m_versions.at(index); + BaseQtVersion *version = m_versions.at(index); if (!version) return; @@ -431,25 +406,40 @@ QtOptionsPageWidget::~QtOptionsPageWidget() delete m_ui; delete m_versionUi; delete m_debuggingHelperUi; + delete m_configurationWidget; qDeleteAll(m_versions); } void QtOptionsPageWidget::addQtDir() { - QtVersion *newVersion = new QtVersion(m_specifyNameString, m_specifyPathString); - m_versions.append(newVersion); + QString filter("qmake ("); + foreach (const QString &s, Utils::BuildableHelperLibrary::possibleQMakeCommands()) { + filter += s + " "; + } + filter += ")"; - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList->topLevelItem(1)); - item->setText(0, newVersion->displayName()); - item->setText(1, QDir::toNativeSeparators(newVersion->qmakeCommand())); - item->setData(0, VersionIdRole, newVersion->uniqueId()); + QString qtVersion = QFileDialog::getOpenFileName(Core::ICore::instance()->mainWindow(), + tr("Select a qmake executable"), QString(), filter); + if (qtVersion.isNull()) + return; + if (QtVersionManager::instance()->qtVersionForQMakeBinary(qtVersion)) { + // Already exist + } - m_ui->qtdirList->setCurrentItem(item); + BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qtVersion); + if (version) { + m_versions.append(version); - m_versionUi->nameEdit->setText(newVersion->displayName()); - m_versionUi->qmakePath->setPath(newVersion->qmakeCommand()); - m_versionUi->nameEdit->setFocus(); - m_versionUi->nameEdit->selectAll(); + QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->qtdirList->topLevelItem(1)); + item->setText(0, version->displayName()); + item->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); + item->setData(0, VersionIdRole, version->uniqueId()); + item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon); + m_ui->qtdirList->setCurrentItem(item); // should update the rest of the ui + m_versionUi->nameEdit->setFocus(); + m_versionUi->nameEdit->selectAll(); + } + updateCleanUpButton(); } void QtOptionsPageWidget::removeQtDir() @@ -461,15 +451,15 @@ void QtOptionsPageWidget::removeQtDir() delete item; - QtVersion *version = m_versions.at(index); + BaseQtVersion *version = m_versions.at(index); m_versions.removeAt(index); delete version; - updateState(); + updateCleanUpButton(); } void QtOptionsPageWidget::updateDebuggingHelperUi() { - const QtVersion *version = currentVersion(); + BaseQtVersion *version = currentVersion(); const QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); if (!version || !version->isValid()) { @@ -619,84 +609,49 @@ void QtOptionsPageWidget::updateDebuggingHelperUi() m_ui->debuggingHelperWidget->setVisible(true); } - } -void QtOptionsPageWidget::updateState() +// To be called if a qt version was removed or added +void QtOptionsPageWidget::updateCleanUpButton() { bool hasInvalidVersion = false; for (int i = 0; i < m_versions.count(); ++i) { - QTreeWidgetItem *item = treeItemForIndex(i); if (!m_versions.at(i)->isValid()) { - if (item) - item->setIcon(0, m_invalidVersionIcon); hasInvalidVersion = true; - } else { - if (item) - item->setIcon(0, m_validVersionIcon); + break; } } - - const QtVersion *version = currentVersion(); - const bool enabled = version != 0; - const bool isAutodetected = enabled && version->isAutodetected(); - m_ui->delButton->setEnabled(enabled && !isAutodetected); m_ui->cleanUpButton->setEnabled(hasInvalidVersion); - m_versionUi->nameEdit->setEnabled(enabled && !isAutodetected); - m_versionUi->qmakePath->setEnabled(enabled && !isAutodetected); - bool s60SDKPathEnabled = enabled && - (isAutodetected ? version->systemRoot().isEmpty() : true); - m_versionUi->s60SDKPath->setEnabled(s60SDKPathEnabled); - - updateDebuggingHelperUi(); } -void QtOptionsPageWidget::makeS60Visible(bool visible) +void QtOptionsPageWidget::userChangedCurrentVersion() { - m_versionUi->s60SDKLabel->setVisible(visible); - m_versionUi->s60SDKPath->setVisible(visible); - m_versionUi->sbsV2Label->setVisible(visible); - m_versionUi->sbsV2Path->setVisible(visible); + updateWidgets(); + updateDescriptionLabel(); + updateDebuggingHelperUi(); } -void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item) +void QtOptionsPageWidget::qtVersionChanged() { - makeS60Visible(false); - m_versionUi->errorLabel->setText(""); - if (!item) - return; - - int index = indexForTreeItem(item); - - if (index < 0) - return; - - QtVersion *qtVersion = m_versions.at(index); - - QList<ProjectExplorer::Abi> abis = qtVersion->qtAbis(); - if (!abis.isEmpty()) { - ProjectExplorer::Abi qtAbi = qtVersion->qtAbis().at(0); - if (qtAbi.os() == ProjectExplorer::Abi::SymbianOS) { - makeS60Visible(true); - m_versionUi->s60SDKPath->setPath(QDir::toNativeSeparators(m_versions.at(index)->systemRoot())); - m_versionUi->sbsV2Path->setPath(m_versions.at(index)->sbsV2Directory()); - m_versionUi->sbsV2Path->setEnabled(m_versions.at(index)->isBuildWithSymbianSbsV2()); - } + QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); + if (item) { + BaseQtVersion *version = currentVersion(); + item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon); } updateDescriptionLabel(); + updateDebuggingHelperUi(); } void QtOptionsPageWidget::updateDescriptionLabel() { - QtVersion *version = currentVersion(); + BaseQtVersion *version = currentVersion(); if (!version) m_versionUi->errorLabel->setText(""); else if (version->isValid()) - m_versionUi->errorLabel->setText(version->description()); + m_versionUi->errorLabel->setText( tr("Qt version %1 for %2").arg(version->qtVersionString(), + version->description())); else m_versionUi->errorLabel->setText(version->invalidReason()); - - updateState(); } int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const @@ -726,32 +681,37 @@ QTreeWidgetItem *QtOptionsPageWidget::treeItemForIndex(int index) const return 0; } -void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old) +void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *old) { - if (old) { + Q_UNUSED(newItem) + if (old) fixQtVersionName(indexForTreeItem(old)); - } - int itemIndex = indexForTreeItem(item); - if (itemIndex >= 0) { - m_versionUi->nameEdit->setText(item->text(0)); - m_versionUi->qmakePath->setPath(item->text(1)); + userChangedCurrentVersion(); +} + +void QtOptionsPageWidget::updateWidgets() +{ + delete m_configurationWidget; + m_configurationWidget = 0; + BaseQtVersion *version = currentVersion(); + if (version) { + m_versionUi->nameEdit->setText(version->displayName()); + m_versionUi->qmakePath->setText(QDir::toNativeSeparators(version->qmakeCommand())); + m_configurationWidget = version->createConfigurationWidget(); + if (m_configurationWidget) { + m_versionUi->formLayout->addRow(m_configurationWidget); + connect(m_configurationWidget, SIGNAL(changed()), + this, SLOT(qtVersionChanged())); + } } else { m_versionUi->nameEdit->clear(); - m_versionUi->qmakePath->setPath(QString()); // clear() - + m_versionUi->qmakePath->setText(QString()); // clear() } - showEnvironmentPage(item); - updateState(); -} -void QtOptionsPageWidget::onQtBrowsed() -{ - const QString dir = m_versionUi->qmakePath->path(); - if (dir.isEmpty()) - return; - - updateCurrentQMakeLocation(); - updateState(); + const bool enabled = version != 0; + const bool isAutodetected = enabled && version->isAutodetected(); + m_ui->delButton->setEnabled(enabled && !isAutodetected); + m_versionUi->nameEdit->setEnabled(enabled && !isAutodetected); } void QtOptionsPageWidget::updateCurrentQtName() @@ -763,7 +723,6 @@ void QtOptionsPageWidget::updateCurrentQtName() return; m_versions[currentItemIndex]->setDisplayName(m_versionUi->nameEdit->text()); currentItem->setText(0, m_versions[currentItemIndex]->displayName()); - updateDescriptionLabel(); } @@ -808,58 +767,11 @@ void QtOptionsPageWidget::fixQtVersionName(int index) } } -void QtOptionsPageWidget::updateCurrentQMakeLocation() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = indexForTreeItem(currentItem); - if (currentItemIndex < 0) - return; - QtVersion *version = m_versions.at(currentItemIndex); - if (version->qmakeCommand() == m_versionUi->qmakePath->path()) - return; - version->setQMakeCommand(m_versionUi->qmakePath->path()); - currentItem->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); - showEnvironmentPage(currentItem); - - if (m_versionUi->nameEdit->text().isEmpty() || m_versionUi->nameEdit->text() == m_specifyNameString) { - QString name = ProjectExplorer::DebuggingHelperLibrary::qtVersionForQMake(version->qmakeCommand()); - if (!name.isEmpty()) - m_versionUi->nameEdit->setText(name); - updateCurrentQtName(); - } - - updateState(); -} - -void QtOptionsPageWidget::updateCurrentS60SDKDirectory() +QList<BaseQtVersion *> QtOptionsPageWidget::versions() const { - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = indexForTreeItem(currentItem); - if (currentItemIndex < 0) - return; - m_versions[currentItemIndex]->setSystemRoot(m_versionUi->s60SDKPath->path()); - updateDescriptionLabel(); -} - -void QtOptionsPageWidget::updateCurrentSbsV2Directory() -{ - QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - Q_ASSERT(currentItem); - int currentItemIndex = indexForTreeItem(currentItem); - if (currentItemIndex < 0) - return; - m_versions[currentItemIndex]->setSbsV2Directory(m_versionUi->sbsV2Path->path()); - updateDescriptionLabel(); -} - -QList<QtVersion *> QtOptionsPageWidget::versions() const -{ - QList<QtVersion *> result; + QList<BaseQtVersion *> result; for (int i = 0; i < m_versions.count(); ++i) - if (m_versions.at(i)->qmakeCommand() != m_specifyPathString) - result.append(new QtVersion(*(m_versions.at(i)))); + result.append(m_versions.at(i)->clone()); return result; } @@ -867,14 +779,20 @@ QString QtOptionsPageWidget::searchKeywords() const { QString rc; QLatin1Char sep(' '); - QTextStream(&rc) - << sep << m_versionUi->versionNameLabel->text() - << sep << m_versionUi->pathLabel->text() - << sep << m_versionUi->s60SDKLabel->text() - << sep << m_versionUi->sbsV2Label->text() - << sep << m_debuggingHelperUi->gdbHelperLabel->text() - << sep << m_debuggingHelperUi->qmlDumpLabel->text() - << sep << m_debuggingHelperUi->qmlObserverLabel->text(); + QTextStream ts(&rc); + ts << sep << m_versionUi->versionNameLabel->text() + << sep << m_versionUi->pathLabel->text() + << sep << m_debuggingHelperUi->gdbHelperLabel->text() + << sep << m_debuggingHelperUi->qmlDumpLabel->text() + << sep << m_debuggingHelperUi->qmlObserverLabel->text(); + + // Symbian specific, could be factored out to the factory + // checking m_configurationWidget is not enough, we want them to be a keyword + // regardless of which qt versions configuration widget is currently active + ts << sep << tr("S60 SDK:") + << sep << tr("SBS v2 directory:"); + + rc.remove(QLatin1Char('&')); return rc; } diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h index 07ba91090a..08fd4d79b1 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.h +++ b/src/plugins/qt4projectmanager/qtoptionspage.h @@ -34,12 +34,8 @@ #define QTOPTIONSPAGE_H #include "debugginghelperbuildtask.h" - #include <coreplugin/dialogs/ioptionspage.h> -#include <QtCore/QSharedPointer> -#include <QtCore/QFutureInterface> - #include <QtGui/QWidget> #include <QtGui/QIcon> @@ -49,7 +45,8 @@ QT_END_NAMESPACE namespace Qt4ProjectManager { -class QtVersion; +class BaseQtVersion; +class QtConfigWidget; namespace Internal { namespace Ui { @@ -63,47 +60,44 @@ class QtOptionsPageWidget : public QWidget Q_OBJECT Q_DISABLE_COPY(QtOptionsPageWidget) public: - QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> versions); + QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *> versions); ~QtOptionsPageWidget(); - QList<QtVersion *> versions() const; + QList<BaseQtVersion *> versions() const; void finish(); QString searchKeywords() const; virtual bool eventFilter(QObject *o, QEvent *e); private: - void showEnvironmentPage(QTreeWidgetItem * item); + void updateDescriptionLabel(); + void userChangedCurrentVersion(); + void updateWidgets(); + void updateDebuggingHelperUi(); void fixQtVersionName(int index); int indexForTreeItem(const QTreeWidgetItem *item) const; QTreeWidgetItem *treeItemForIndex(int index) const; - QtVersion *currentVersion() const; + BaseQtVersion *currentVersion() const; int currentIndex() const; + void showDebuggingBuildLog(const QTreeWidgetItem *currentItem); const QString m_specifyNameString; - const QString m_specifyPathString; Internal::Ui::QtVersionManager *m_ui; Internal::Ui::QtVersionInfo *m_versionUi; Internal::Ui::DebuggingHelper *m_debuggingHelperUi; - QList<QtVersion *> m_versions; + QList<BaseQtVersion *> m_versions; int m_defaultVersion; QIcon m_invalidVersionIcon; QIcon m_validVersionIcon; - -public slots: - void updateState(); + QtConfigWidget *m_configurationWidget; private slots: + void qtVersionChanged(); void versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old); void addQtDir(); void removeQtDir(); - void makeS60Visible(bool visible); - void onQtBrowsed(); + void updateCleanUpButton(); void updateCurrentQtName(); - void updateCurrentQMakeLocation(); - void updateCurrentS60SDKDirectory(); - void updateCurrentSbsV2Directory(); - void updateDebuggingHelperUi(); void buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools = DebuggingHelperBuildTask::AllTools); void buildGdbHelper(); @@ -113,10 +107,6 @@ private slots: void slotShowDebuggingBuildLog(); void debuggingHelperBuildFinished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools); void cleanUpQtVersions(); - -private: - void updateDescriptionLabel(); - void showDebuggingBuildLog(const QTreeWidgetItem *currentItem); }; class QtOptionsPage : public Core::IOptionsPage diff --git a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp index 6d0ec347ea..12265121d1 100644 --- a/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp +++ b/src/plugins/qt4projectmanager/qtuicodemodelsupport.cpp @@ -35,6 +35,7 @@ #include "qt4project.h" #include "qt4target.h" +#include "baseqtversion.h" using namespace Qt4ProjectManager; using namespace Internal; @@ -57,6 +58,8 @@ Qt4UiCodeModelSupport::~Qt4UiCodeModelSupport() QString Qt4UiCodeModelSupport::uicCommand() const { Qt4BuildConfiguration *qt4bc = m_project->activeTarget()->activeBuildConfiguration(); + if (!qt4bc->qtVersion()) + return QString(); return qt4bc->qtVersion()->uicCommand(); } diff --git a/src/plugins/qt4projectmanager/qtversionfactory.cpp b/src/plugins/qt4projectmanager/qtversionfactory.cpp new file mode 100644 index 0000000000..0d90cc4bae --- /dev/null +++ b/src/plugins/qt4projectmanager/qtversionfactory.cpp @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "qtversionfactory.h" +#include "profilereader.h" +#include "qtversionmanager.h" + +#include <extensionsystem/pluginmanager.h> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +QtVersionFactory::QtVersionFactory(QObject *parent) : + QObject(parent) +{ + +} + +QtVersionFactory::~QtVersionFactory() +{ + +} + +bool sortByPriority(QtVersionFactory *a, QtVersionFactory *b) +{ + return a->priority() > b->priority(); +} + +BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const QString &qmakePath, bool isAutoDetected, const QString &autoDetectionSource) +{ + QHash<QString, QString> versionInfo; + bool success = BaseQtVersion::queryQMakeVariables(qmakePath, &versionInfo); + if (!success) + return 0; + QString mkspec = BaseQtVersion::mkspecFromVersionInfo(versionInfo); + + ProFileOption option; + option.properties = versionInfo; + ProMessageHandler msgHandler(true); + ProFileCacheManager::instance()->incRefCount(); + ProFileParser parser(ProFileCacheManager::instance()->cache(), &msgHandler); + ProFileEvaluator evaluator(&option, &parser, &msgHandler); + if (ProFile *pro = parser.parsedProFile(mkspec + "/qmake.conf")) { + evaluator.setCumulative(false); + evaluator.accept(pro, ProFileEvaluator::LoadProOnly); + pro->deref(); + } + + QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<QtVersionFactory>(); + qSort(factories.begin(), factories.end(), &sortByPriority); + + foreach (QtVersionFactory *factory, factories) { + BaseQtVersion *ver = factory->create(qmakePath, &evaluator, isAutoDetected, autoDetectionSource); + if (ver) { + ProFileCacheManager::instance()->decRefCount(); + return ver; + } + } + ProFileCacheManager::instance()->decRefCount(); + return 0; +} diff --git a/src/plugins/qt4projectmanager/qtversionfactory.h b/src/plugins/qt4projectmanager/qtversionfactory.h new file mode 100644 index 0000000000..81e71e4aa2 --- /dev/null +++ b/src/plugins/qt4projectmanager/qtversionfactory.h @@ -0,0 +1,66 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef QTVERSIONFACTORY_H +#define QTVERSIONFACTORY_H + +#include "baseqtversion.h" +#include "qt4projectmanager_global.h" + +#include "profilereader.h" + +#include <QtCore/QObject> +#include <QtCore/QVariantMap> + +namespace Qt4ProjectManager { + +class QT4PROJECTMANAGER_EXPORT QtVersionFactory : public QObject +{ + Q_OBJECT +public: + explicit QtVersionFactory(QObject *parent = 0); + ~QtVersionFactory(); + + virtual bool canRestore(const QString &type) = 0; + virtual BaseQtVersion *restore(const QVariantMap &data) = 0; + + /// factories with higher priority are asked first to identify + /// a qtversion, the priority of the desktop factory is 0 and + /// the desktop factory claims to handle all paths + virtual int priority() const = 0; + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()) = 0; + + static BaseQtVersion *createQtVersionFromQMakePath(const QString &qmakePath, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} +#endif // QTVERSIONFACTORY_H diff --git a/src/plugins/qt4projectmanager/qtversioninfo.ui b/src/plugins/qt4projectmanager/qtversioninfo.ui index 6d77a10899..adcb1ed67c 100644 --- a/src/plugins/qt4projectmanager/qtversioninfo.ui +++ b/src/plugins/qt4projectmanager/qtversioninfo.ui @@ -6,55 +6,36 @@ <rect> <x>0</x> <y>0</y> - <width>404</width> - <height>105</height> + <width>222</width> + <height>62</height> </rect> </property> - <layout class="QGridLayout"> - <property name="margin"> - <number>0</number> - </property> - <item row="1" column="0"> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> <widget class="QLabel" name="versionNameLabel"> <property name="text"> <string>Version name:</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="0" column="1"> <widget class="QLineEdit" name="nameEdit"/> </item> - <item row="2" column="0"> + <item row="1" column="0"> <widget class="QLabel" name="pathLabel"> <property name="text"> <string>qmake location:</string> </property> </widget> </item> - <item row="2" column="1"> - <widget class="Utils::PathChooser" name="qmakePath" native="true"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="s60SDKLabel"> - <property name="text"> - <string>S60 SDK:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="Utils::PathChooser" name="s60SDKPath" native="true"/> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="sbsV2Label"> + <item row="1" column="1"> + <widget class="QLabel" name="qmakePath"> <property name="text"> - <string>SBS v2 directory:</string> + <string/> </property> </widget> </item> - <item row="5" column="1"> - <widget class="Utils::PathChooser" name="sbsV2Path" native="true"/> - </item> - <item row="6" column="0" colspan="2"> + <item row="2" column="0" colspan="2"> <widget class="QLabel" name="errorLabel"> <property name="text"> <string/> @@ -63,18 +44,6 @@ </item> </layout> </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - <slots> - <signal>editingFinished()</signal> - <signal>browsingFinished()</signal> - </slots> - </customwidget> - </customwidgets> <resources/> <connections/> </ui> diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index bdfe0c8cda..7a31e95148 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -33,56 +33,35 @@ #include "qtversionmanager.h" #include "qt4projectmanagerconstants.h" -#include "qt4target.h" -#include "profilereader.h" - -#include "qt-maemo/maemoglobal.h" -#include "qt-maemo/maemomanager.h" -#include "qt-s60/s60manager.h" -#include "qt-s60/abldparser.h" -#include "qt-s60/sbsv2parser.h" -#include "qt-s60/gccetoolchain.h" -#include "qt-s60/winscwtoolchain.h" -#include "qt4basetargetfactory.h" - -#include "qmlobservertool.h" -#include "qmldumptool.h" -#include "qmldebugginglibrary.h" +#include "qtversionfactory.h" + +// only for legay restore +#include "qt-desktop/desktopqtversion.h" +#include "qt-s60/symbianqtversion.h" #include <projectexplorer/debugginghelper.h> -#include <projectexplorer/gnumakeparser.h> -#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/persistentsettings.h> +// only for legay restore #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/toolchainmanager.h> -#include <projectexplorer/cesdkhandler.h> #include <projectexplorer/gcctoolchain.h> -#include <projectexplorer/toolchainmanager.h> -#include <projectexplorer/headerpath.h> -#include <projectexplorer/ioutputparser.h> -#include <projectexplorer/task.h> -#include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> #include <coreplugin/helpmanager.h> #include <extensionsystem/pluginmanager.h> -#include <utils/synchronousprocess.h> -#include <utils/qtcassert.h> #include <utils/qtcprocess.h> +#include <utils/qtcassert.h> #ifdef Q_OS_WIN # include <utils/winutils.h> #endif #include <QtCore/QFile> -#include <QtCore/QProcess> #include <QtCore/QSettings> -#include <QtCore/QTime> -#include <QtCore/QTimer> #include <QtCore/QTextStream> #include <QtCore/QDir> -#include <QtGui/QApplication> -#include <QtGui/QDesktopServices> +#include <QtGui/QMainWindow> #include <algorithm> @@ -91,9 +70,14 @@ using namespace Qt4ProjectManager::Internal; using ProjectExplorer::DebuggingHelperLibrary; +static const char QTVERSION_DATA_KEY[] = "QtVersion."; +static const char QTVERSION_TYPE_KEY[] = "QtVersion.Type"; +static const char QTVERSION_COUNT_KEY[] = "QtVersion.Count"; +static const char QTVERSION_FILE_VERSION_KEY[] = "Version"; +static const char QTVERSION_FILENAME[] = "/qtversion.xml"; + +// legacy settings static const char QtVersionsSectionName[] = "QtVersions"; -static const char newQtVersionsKey[] = "NewQtVersions"; -static const char PATH_AUTODETECTION_SOURCE[] = "PATH"; enum { debug = 0 }; @@ -111,9 +95,16 @@ static T *createToolChain(const QString &id) return 0; } +static QString settingsFileName() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + QFileInfo settingsLocation(pm->settings()->fileName()); + return settingsLocation.absolutePath() + QLatin1String(QTVERSION_FILENAME); +} + // prefer newer qts otherwise compare on id -bool qtVersionNumberCompare(QtVersion *a, QtVersion *b) +bool qtVersionNumberCompare(BaseQtVersion *a, BaseQtVersion *b) { return a->qtVersion() > b->qtVersion() || (a->qtVersion() == b->qtVersion() && a->uniqueId() < b->uniqueId()); } @@ -124,12 +115,132 @@ bool qtVersionNumberCompare(QtVersion *a, QtVersion *b) QtVersionManager *QtVersionManager::m_self = 0; QtVersionManager::QtVersionManager() - : m_emptyVersion(new QtVersion) { m_self = this; - QSettings *s = Core::ICore::instance()->settings(); - m_idcount = 1; +} + +void QtVersionManager::extensionsInitialized() +{ + bool success = restoreQtVersions(); + if (!success) + success = legacyRestore(); + updateFromInstaller(); + if (!success) { + // We did neither restore our settings or upgraded + // in that case figure out if there's a qt in path + // and add it to the qt versions + findSystemQt(); + } + updateDocumentation(); + + updateSettings(); + saveQtVersions(); +} + +QtVersionManager::~QtVersionManager() +{ + qDeleteAll(m_versions); + m_versions.clear(); +} + +QtVersionManager *QtVersionManager::instance() +{ + return m_self; +} + +bool QtVersionManager::restoreQtVersions() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + QList<QtVersionFactory *> factories = pm->getObjects<QtVersionFactory>(); + + ProjectExplorer::PersistentSettingsReader reader; + if (!reader.load(settingsFileName())) + return false; + QVariantMap data = reader.restoreValues(); + + // Check version: + int version = data.value(QLatin1String(QTVERSION_FILE_VERSION_KEY), 0).toInt(); + if (version < 1) + return false; + + + int count = data.value(QLatin1String(QTVERSION_COUNT_KEY), 0).toInt(); + for (int i = 0; i < count; ++i) { + const QString key = QString::fromLatin1(QTVERSION_DATA_KEY) + QString::number(i); + if (!data.contains(key)) + break; + + const QVariantMap qtversionMap = data.value(key).toMap(); + const QString type = qtversionMap.value(QTVERSION_TYPE_KEY).toString(); + + bool restored = false; + foreach (QtVersionFactory *f, factories) { + if (f->canRestore(type)) { + if (BaseQtVersion *qtv = f->restore(qtversionMap)) { + if (m_versions.contains(qtv->uniqueId())) { + // This shouldn't happen, we are restoring the same id multiple times? + qWarning() << "A qt version with id"<<qtv->uniqueId()<<"already exists"; + delete qtv; + } else { + m_versions.insert(qtv->uniqueId(), qtv); + m_idcount = qtv->uniqueId() > m_idcount ? qtv->uniqueId() : m_idcount; + restored = true; + break; + } + } + } + } + if (!restored) + qWarning("Warning: Unable to restore qtversion '%s' stored in %s.", + qPrintable(type), + qPrintable(QDir::toNativeSeparators(settingsFileName()))); + } + ++m_idcount; + return true; +} + +void QtVersionManager::updateFromInstaller() +{ + // TODO implement for the sdk + return; +} + +void QtVersionManager::saveQtVersions() +{ + ProjectExplorer::PersistentSettingsWriter writer; + writer.saveValue(QLatin1String(QTVERSION_FILE_VERSION_KEY), 1); + + int count = 0; + foreach (BaseQtVersion *qtv, m_versions) { + QVariantMap tmp = qtv->toMap(); + if (tmp.isEmpty()) + continue; + tmp.insert(QTVERSION_TYPE_KEY, qtv->type()); + writer.saveValue(QString::fromLatin1(QTVERSION_DATA_KEY) + QString::number(count), tmp); + ++count; + + } + writer.saveValue(QLatin1String(QTVERSION_COUNT_KEY), count); + writer.save(settingsFileName(), "QtCreatorQtVersions", Core::ICore::instance()->mainWindow()); +} + +void QtVersionManager::findSystemQt() +{ + QString systemQMakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment()); + if (systemQMakePath.isNull()) + return; + + BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath); + version->setDisplayName(tr("Qt in PATH (%1)").arg(version->qtVersionString())); + m_versions.insert(version->uniqueId(), version); +} + +bool QtVersionManager::legacyRestore() +{ + QSettings *s = Core::ICore::instance()->settings(); + if (!s->contains(QLatin1String(QtVersionsSectionName) + QLatin1String("/size"))) + return false; int size = s->beginReadArray(QtVersionsSectionName); for (int i = 0; i < size; ++i) { s->setArrayIndex(i); @@ -142,42 +253,30 @@ QtVersionManager::QtVersionManager() id = getUniqueId(); else if (m_idcount < id) m_idcount = id + 1; - bool isAutodetected; - QString autodetectionSource; - if (s->contains("isAutodetected")) { - isAutodetected = s->value("isAutodetected", false).toBool(); - autodetectionSource = s->value("autodetectionSource", QString()).toString(); - } else {// compatibility - isAutodetected = s->value("IsSystemVersion", false).toBool(); - if (isAutodetected) - autodetectionSource = QLatin1String(PATH_AUTODETECTION_SOURCE); - } + QString qmakePath = s->value("QMakePath").toString(); - if (qmakePath.isEmpty()) { - QString path = s->value("Path").toString(); - if (!path.isEmpty()) { - foreach(const QString& command, ProjectExplorer::DebuggingHelperLibrary::possibleQMakeCommands()) - { - QFileInfo fi(path + "/bin/" + command); - if (fi.exists()) - { - qmakePath = fi.filePath(); - break; - } - } - } + if (qmakePath.isEmpty()) + continue; //skip this version + + // autodetection = false, from now on only sdk versions are autodetected + BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qmakePath); + if (!version) // Likely to be a invalid version + continue; + version->setId(id); + version->setDisplayName(s->value("Name").toString()); + if (SymbianQtVersion *sqv = dynamic_cast<SymbianQtVersion *>(version)) { + sqv->setSystemRoot(QDir::fromNativeSeparators(s->value("S60SDKDirectory").toString())); + sqv->setSbsV2Directory(QDir::fromNativeSeparators(s->value(QLatin1String("SBSv2Directory")).toString())); + } + + if (m_versions.contains(version->uniqueId())) { + // oh uh; + delete version; + } else { + m_versions.insert(version->uniqueId(), version); } - QtVersion *version = new QtVersion(s->value("Name").toString(), - qmakePath, - id, - isAutodetected, - autodetectionSource); - // Make sure we do not import non-native separators from old Qt Creator versions: - version->setSystemRoot(QDir::fromNativeSeparators(s->value("S60SDKDirectory").toString())); - version->setSbsV2Directory(QDir::fromNativeSeparators(s->value(QLatin1String("SBSv2Directory")).toString())); - - // Update from pre-2.2: - const QString mingwDir = s->value(QLatin1String("MingwDirectory")).toString(); + // Update from 2.1 or earlier: + QString mingwDir = s->value(QLatin1String("MingwDirectory")).toString(); if (!mingwDir.isEmpty()) { QFileInfo fi(mingwDir + QLatin1String("/bin/g++.exe")); if (fi.exists() && fi.isExecutable()) { @@ -198,32 +297,14 @@ QtVersionManager::QtVersionManager() if (!gcceDir.isEmpty()) m_pendingGcceUpdates.append(gcceDir); - m_versions.insert(version->uniqueId(), version); } s->endArray(); - - ++m_idcount; - addNewVersionsFromInstaller(); - updateSystemVersion(); - - // cannot call from ctor, needs to get connected extenernally first - QTimer::singleShot(0, this, SLOT(updateSettings())); -} - -QtVersionManager::~QtVersionManager() -{ - qDeleteAll(m_versions); - m_versions.clear(); - delete m_emptyVersion; - m_emptyVersion = 0; -} - -QtVersionManager *QtVersionManager::instance() -{ - return m_self; + // TODO add removal of old settings + // s->remove(QtVersionsSectionName); + return true; } -void QtVersionManager::addVersion(QtVersion *version) +void QtVersionManager::addVersion(BaseQtVersion *version) { QTC_ASSERT(version != 0, return); if (m_versions.contains(version->uniqueId())) @@ -233,31 +314,31 @@ void QtVersionManager::addVersion(QtVersion *version) m_versions.insert(uniqueId, version); emit qtVersionsChanged(QList<int>() << uniqueId); - writeVersionsIntoSettings(); + saveQtVersions(); } -void QtVersionManager::removeVersion(QtVersion *version) +void QtVersionManager::removeVersion(BaseQtVersion *version) { QTC_ASSERT(version != 0, return); m_versions.remove(version->uniqueId()); emit qtVersionsChanged(QList<int>() << version->uniqueId()); - writeVersionsIntoSettings(); + saveQtVersions(); delete version; } bool QtVersionManager::supportsTargetId(const QString &id) const { - QList<QtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(id); - foreach (QtVersion *v, versions) + QList<BaseQtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(id); + foreach (BaseQtVersion *v, versions) if (v->isValid() && v->toolChainAvailable(id)) return true; return false; } -QList<QtVersion *> QtVersionManager::versionsForTargetId(const QString &id, const QtVersionNumber &minimumQtVersion) const +QList<BaseQtVersion *> QtVersionManager::versionsForTargetId(const QString &id, const QtVersionNumber &minimumQtVersion) const { - QList<QtVersion *> targetVersions; - foreach (QtVersion *version, m_versions) { + QList<BaseQtVersion *> targetVersions; + foreach (BaseQtVersion *version, m_versions) { if (version->supportsTargetId(id) && version->qtVersion() >= minimumQtVersion) targetVersions.append(version); } @@ -268,7 +349,7 @@ QList<QtVersion *> QtVersionManager::versionsForTargetId(const QString &id, cons QSet<QString> QtVersionManager::supportedTargetIds() const { QSet<QString> results; - foreach (QtVersion *version, m_versions) + foreach (BaseQtVersion *version, m_versions) results.unite(version->supportedTargetIds()); return results; } @@ -278,8 +359,8 @@ void QtVersionManager::updateDocumentation() Core::HelpManager *helpManager = Core::HelpManager::instance(); Q_ASSERT(helpManager); QStringList files; - foreach (QtVersion *version, m_versions) { - const QString docPath = version->documentationPath() + QLatin1String("/qch/"); + foreach (BaseQtVersion *v, m_versions) { + const QString docPath = v->documentationPath() + QLatin1String("/qch/"); const QDir versionHelpDir(docPath); foreach (const QString &helpFile, versionHelpDir.entryList(QStringList() << QLatin1String("*.qch"), QDir::Files)) @@ -291,17 +372,15 @@ void QtVersionManager::updateDocumentation() void QtVersionManager::updateSettings() { - writeVersionsIntoSettings(); - updateDocumentation(); - QtVersion *version = 0; - QList<QtVersion*> candidates; + BaseQtVersion *version = 0; + QList<BaseQtVersion *> candidates; // try to find a version which has both, demos and examples - foreach (version, m_versions) { - if (version->hasExamples() && version->hasDemos()) - candidates.append(version); + foreach (BaseQtVersion *version, m_versions) { + if (version && version->hasExamples() && version->hasDemos()) + candidates.append(version); } // in SDKs, we want to prefer the Qt version shipping with the SDK @@ -344,47 +423,19 @@ int QtVersionManager::getUniqueId() return m_idcount++; } -void QtVersionManager::writeVersionsIntoSettings() +QList<BaseQtVersion *> QtVersionManager::versions() const { - QSettings *s = Core::ICore::instance()->settings(); - s->beginWriteArray(QtVersionsSectionName); - QMap<int, QtVersion *>::const_iterator it = m_versions.constBegin(); - for (int i = 0; i < m_versions.size(); ++i) { - const QtVersion *version = it.value(); - s->setArrayIndex(i); - s->setValue("Name", version->displayName()); - // for downwards compat - s->setValue("Path", version->versionInfo().value("QT_INSTALL_DATA")); - s->setValue("QMakePath", version->qmakeCommand()); - s->setValue("Id", version->uniqueId()); - s->setValue("isAutodetected", version->isAutodetected()); - if (version->isAutodetected()) - s->setValue("autodetectionSource", version->autodetectionSource()); - s->setValue("S60SDKDirectory", version->systemRoot()); - s->setValue(QLatin1String("SBSv2Directory"), version->sbsV2Directory()); - // Remove obsolete settings: New tool chains would be created at each startup - // otherwise, overriding manually set ones. - s->remove(QLatin1String("MingwDirectory")); - s->remove(QLatin1String("MwcDirectory")); - s->remove(QLatin1String("GcceDirectory")); - ++it; - } - s->endArray(); -} - -QList<QtVersion *> QtVersionManager::versions() const -{ - QList<QtVersion *> versions; - foreach (QtVersion *version, m_versions) + QList<BaseQtVersion *> versions; + foreach (BaseQtVersion *version, m_versions) versions << version; qSort(versions.begin(), versions.end(), &qtVersionNumberCompare); return versions; } -QList<QtVersion *> QtVersionManager::validVersions() const +QList<BaseQtVersion *> QtVersionManager::validVersions() const { - QList<QtVersion *> results; - foreach(QtVersion *v, m_versions) { + QList<BaseQtVersion *> results; + foreach(BaseQtVersion *v, m_versions) { if (v->isValid()) results.append(v); } @@ -411,134 +462,33 @@ QString QtVersionManager::popPendingGcceUpdate() return m_pendingGcceUpdates.takeFirst(); } -QtVersion *QtVersionManager::version(int id) const +BaseQtVersion *QtVersionManager::version(int id) const { - QMap<int, QtVersion *>::const_iterator it = m_versions.find(id); + QMap<int, BaseQtVersion *>::const_iterator it = m_versions.find(id); if (it == m_versions.constEnd()) - return m_emptyVersion; + return 0; return it.value(); } -// FIXME: Rework this! -void QtVersionManager::addNewVersionsFromInstaller() -{ - // Add new versions which may have been installed by the WB installer in the form: - // NewQtVersions="qt 4.3.2=c:\\qt\\qt432\bin\qmake.exe;qt embedded=c:\\qtembedded;" - // or NewQtVersions="qt 4.3.2=c:\\qt\\qt432bin\qmake.exe; - // i.e. - // NewQtVersions="versionname=pathtoversion=s60sdk;" - // Duplicate entries are not added, the first new version is set as default. - QSettings *settings = Core::ICore::instance()->settings(); - QSettings *globalSettings = Core::ICore::instance()->settings(QSettings::SystemScope); - - QDateTime lastUpdateFromGlobalSettings = globalSettings->value( - QLatin1String("General/LastQtVersionUpdate")).toDateTime(); - - const QFileInfo gsFi(globalSettings->fileName()); - if ( !lastUpdateFromGlobalSettings.isNull() && - (!gsFi.exists() || (gsFi.lastModified() > lastUpdateFromGlobalSettings)) ) - return; - - if (!globalSettings->contains(newQtVersionsKey) && - !globalSettings->contains(QLatin1String("Installer/")+newQtVersionsKey)) - { - return; - } - - QString newVersionsValue = settings->value(newQtVersionsKey).toString(); - if (newVersionsValue.isEmpty()) - newVersionsValue = settings->value(QLatin1String("Installer/")+newQtVersionsKey).toString(); - - QStringList newVersionsList = newVersionsValue.split(';', QString::SkipEmptyParts); - foreach (const QString &newVersion, newVersionsList) { - QStringList newVersionData = newVersion.split('='); - if (newVersionData.count() >= 2) { - if (QFile::exists(newVersionData[1])) { - QtVersion *version = new QtVersion(newVersionData[0], newVersionData[1], m_idcount++ ); - if (newVersionData.count() >= 3) - version->setSystemRoot(QDir::fromNativeSeparators(newVersionData[2])); - if (newVersionData.count() >= 4) - version->setSbsV2Directory(QDir::fromNativeSeparators(newVersionData[3])); - - bool versionWasAlreadyInList = false; - foreach(const QtVersion * const it, m_versions) { - if (QDir(version->qmakeCommand()).canonicalPath() == QDir(it->qmakeCommand()).canonicalPath()) { - versionWasAlreadyInList = true; - break; - } - } - - if (!versionWasAlreadyInList) { - m_versions.insert(version->uniqueId(), version); - } else { - // clean up - delete version; - } - } - } - } - settings->setValue(QLatin1String("General/LastQtVersionUpdate"), QDateTime::currentDateTime()); -} - -void QtVersionManager::updateSystemVersion() -{ - bool haveSystemVersion = false; - QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(Utils::Environment::systemEnvironment()); - if (systemQMakePath.isNull()) - systemQMakePath = tr("<not found>"); - - foreach (QtVersion *version, m_versions) { - if (version->isAutodetected() - && version->autodetectionSource() == PATH_AUTODETECTION_SOURCE) { - version->setQMakeCommand(systemQMakePath); - version->setDisplayName(tr("Qt in PATH")); - haveSystemVersion = true; - } - } - if (haveSystemVersion) - return; - QtVersion *version = new QtVersion(tr("Qt in PATH"), - systemQMakePath, - getUniqueId(), - true, - PATH_AUTODETECTION_SOURCE); - m_versions.insert(version->uniqueId(), version); -} - -QtVersion *QtVersionManager::emptyVersion() const -{ - return m_emptyVersion; -} - class SortByUniqueId { public: - bool operator()(QtVersion *a, QtVersion *b) + bool operator()(BaseQtVersion *a, BaseQtVersion *b) { return a->uniqueId() < b->uniqueId(); } }; -bool QtVersionManager::equals(QtVersion *a, QtVersion *b) +bool QtVersionManager::equals(BaseQtVersion *a, BaseQtVersion *b) { - if (a->m_qmakeCommand != b->m_qmakeCommand) - return false; - if (a->m_id != b->m_id) - return false; - if (a->m_displayName != b->displayName()) - return false; - if (a->m_sbsV2Directory != b->m_sbsV2Directory) - return false; - if (a->m_systemRoot != b->m_systemRoot) - return false; - return true; + return a->equals(b); } -void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions) +void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> newVersions) { // We want to preserve the same order as in the settings dialog // so we sort a copy - QList<QtVersion *> sortedNewVersions = newVersions; + QList<BaseQtVersion *> sortedNewVersions = newVersions; SortByUniqueId sortByUniqueId; qSort(sortedNewVersions.begin(), sortedNewVersions.end(), sortByUniqueId); @@ -547,8 +497,8 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions) // iterate over both sorted list // newVersions and oldVersions iterator - QList<QtVersion *>::const_iterator nit, nend; - QMap<int, QtVersion *>::const_iterator oit, oend; + QList<BaseQtVersion *>::const_iterator nit, nend; + QMap<int, BaseQtVersion *>::const_iterator oit, oend; nit = sortedNewVersions.constBegin(); nend = sortedNewVersions.constEnd(); oit = m_versions.constBegin(); @@ -583,379 +533,19 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions) qDeleteAll(m_versions); m_versions.clear(); - foreach (QtVersion *v, sortedNewVersions) + foreach (BaseQtVersion *v, sortedNewVersions) m_versions.insert(v->uniqueId(), v); if (!changedVersions.isEmpty()) updateDocumentation(); updateSettings(); - writeVersionsIntoSettings(); + saveQtVersions(); if (!changedVersions.isEmpty()) emit qtVersionsChanged(changedVersions); } -// -------------------------------------------------------------------------- -// QtVersion -// -------------------------------------------------------------------------- - -QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id, - bool isAutodetected, const QString &autodetectionSource) - : m_displayName(name), - m_isAutodetected(isAutodetected), - m_autodetectionSource(autodetectionSource), - m_hasDebuggingHelper(false), - m_hasQmlDump(false), - m_hasQmlDebuggingLibrary(false), - m_hasQmlObserver(false), - m_abiUpToDate(false), - m_versionInfoUpToDate(false), - m_notInstalled(false), - m_defaultConfigIsDebug(true), - m_defaultConfigIsDebugAndRelease(true), - m_hasExamples(false), - m_hasDemos(false), - m_hasDocumentation(false), - m_qmakeIsExecutable(false), - m_validSystemRoot(true) -{ - if (id == -1) - m_id = getUniqueId(); - else - m_id = id; - setQMakeCommand(qmakeCommand); -} - -QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, - bool isAutodetected, const QString &autodetectionSource) - : m_displayName(name), - m_isAutodetected(isAutodetected), - m_autodetectionSource(autodetectionSource), - m_hasDebuggingHelper(false), - m_hasQmlDump(false), - m_hasQmlDebuggingLibrary(false), - m_hasQmlObserver(false), - m_abiUpToDate(false), - m_versionInfoUpToDate(false), - m_notInstalled(false), - m_defaultConfigIsDebug(true), - m_defaultConfigIsDebugAndRelease(true), - m_hasExamples(false), - m_hasDemos(false), - m_hasDocumentation(false), - m_qmakeIsExecutable(false), - m_validSystemRoot(true) -{ - m_id = getUniqueId(); - setQMakeCommand(qmakeCommand); -} - - -QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QString &autodetectionSource) - : m_isAutodetected(isAutodetected), - m_autodetectionSource(autodetectionSource), - m_hasDebuggingHelper(false), - m_hasQmlDump(false), - m_hasQmlDebuggingLibrary(false), - m_hasQmlObserver(false), - m_abiUpToDate(false), - m_versionInfoUpToDate(false), - m_notInstalled(false), - m_defaultConfigIsDebug(true), - m_defaultConfigIsDebugAndRelease(true), - m_hasExamples(false), - m_hasDemos(false), - m_hasDocumentation(false), - m_qmakeIsExecutable(false), - m_validSystemRoot(true) -{ - m_id = getUniqueId(); - setQMakeCommand(qmakeCommand); - m_displayName = qtVersionString(); -} - -QtVersion::QtVersion() - : m_id(-1), - m_isAutodetected(false), - m_hasDebuggingHelper(false), - m_hasQmlDump(false), - m_hasQmlDebuggingLibrary(false), - m_hasQmlObserver(false), - m_abiUpToDate(false), - m_versionInfoUpToDate(false), - m_notInstalled(false), - m_defaultConfigIsDebug(true), - m_defaultConfigIsDebugAndRelease(true), - m_hasExamples(false), - m_hasDemos(false), - m_hasDocumentation(false) , - m_qmakeIsExecutable(false), - m_validSystemRoot(true) -{ - setQMakeCommand(QString()); -} - -QtVersion::~QtVersion() -{ -} - -QString QtVersion::toHtml(bool verbose) const -{ - QString rc; - QTextStream str(&rc); - str << "<html><body><table>"; - str << "<tr><td><b>" << QtVersionManager::tr("Name:") - << "</b></td><td>" << displayName() << "</td></tr>"; - if (!isValid()) { - str << "<tr><td colspan=2><b>" + QtVersionManager::tr("Invalid Qt version") +"</b></td></tr>"; - } else { - QString prefix = QLatin1String("<tr><td><b>") + QtVersionManager::tr("ABI:") + QLatin1String("</b></td>"); - foreach (const ProjectExplorer::Abi &abi, qtAbis()) { - str << prefix << "<td>" << abi.toString() << "</td></tr>"; - prefix = QLatin1String("<tr><td></td>"); - } - str << "<tr><td><b>" << QtVersionManager::tr("Source:") - << "</b></td><td>" << sourcePath() << "</td></tr>"; - str << "<tr><td><b>" << QtVersionManager::tr("mkspec:") - << "</b></td><td>" << mkspec() << "</td></tr>"; - str << "<tr><td><b>" << QtVersionManager::tr("qmake:") - << "</b></td><td>" << m_qmakeCommand << "</td></tr>"; - updateAbiAndMkspec(); - if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) { - str << "<tr><td><b>" << QtVersionManager::tr("Default:") << "</b></td><td>" - << (m_defaultConfigIsDebug ? "debug" : "release"); - if (m_defaultConfigIsDebugAndRelease) - str << " debug_and_release"; - str << "</td></tr>"; - } // default config. - str << "<tr><td><b>" << QtVersionManager::tr("Version:") - << "</b></td><td>" << qtVersionString() << "</td></tr>"; - if (verbose) { - const QHash<QString,QString> vInfo = versionInfo(); - if (!vInfo.isEmpty()) { - const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd(); - for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it) - str << "<tr><td><pre>" << it.key() << "</pre></td><td>" << it.value() << "</td></tr>"; - } - } - } - str << "</table></body></html>"; - return rc; -} - -bool QtVersion::supportsShadowBuilds() const -{ - QSet<QString> targets = supportedTargetIds(); - // Symbian does not support shadow building - if (targets.contains(Constants::S60_DEVICE_TARGET_ID) || - targets.contains(Constants::S60_EMULATOR_TARGET_ID)) { - // We can not support shadow building with the ABLD system - return false; - } -#ifdef Q_OS_WIN - if (targets.contains(Constants::MEEGO_DEVICE_TARGET_ID) - || targets.contains(Constants::MAEMO5_DEVICE_TARGET_ID) - || targets.contains(Constants::HARMATTAN_DEVICE_TARGET_ID)) - return false; -#endif - return true; -} - -ProjectExplorer::IOutputParser *QtVersion::createOutputParser() const -{ - if (supportsTargetId(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID) || - supportsTargetId(Qt4ProjectManager::Constants::S60_EMULATOR_TARGET_ID)) { - if (isBuildWithSymbianSbsV2()) { - return new SbsV2Parser; - } else { - ProjectExplorer::IOutputParser *parser = new AbldParser; - parser->appendOutputParser(new ProjectExplorer::GnuMakeParser); - return parser; - } - } - return new ProjectExplorer::GnuMakeParser; -} - -QList<ProjectExplorer::Task> -QtVersion::reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors) -{ - QList<ProjectExplorer::Task> results; - - QString tmpBuildDir = QDir(buildDir).absolutePath(); - if (!tmpBuildDir.endsWith(QLatin1Char('/'))) - tmpBuildDir.append(QLatin1Char('/')); - - if (!isValid()) { - //: %1: Reason for being invalid - const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason()); - results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1, - QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); - } - - QFileInfo qmakeInfo(qmakeCommand()); - if (!qmakeInfo.exists() || - !qmakeInfo.isExecutable()) { - //: %1: Path to qmake executable - const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", - "The qmake command \"%1\" was not found or is not executable.").arg(qmakeCommand()); - results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, msg, QString(), -1, - QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); - } - - QString sourcePath = QFileInfo(proFile).absolutePath(); - if (!sourcePath.endsWith(QLatin1Char('/'))) - sourcePath.append(QLatin1Char('/')); - if ((tmpBuildDir.startsWith(sourcePath)) && (tmpBuildDir != sourcePath)) { - const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", - "Qmake does not support build directories below the source directory."); - results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1, - QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); - } else if (tmpBuildDir.count(QChar('/')) != sourcePath.count(QChar('/'))) { - const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", - "The build directory needs to be at the same level as the source directory."); - - results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1, - QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); - } - -#if defined (Q_OS_WIN) - QSet<QString> targets = supportedTargetIds(); - if (targets.contains(Constants::S60_DEVICE_TARGET_ID) || - targets.contains(Constants::S60_EMULATOR_TARGET_ID)) { - const QString epocRootDir = systemRoot(); - // Report an error if project- and epoc directory are on different drives: - if (!epocRootDir.startsWith(proFile.left(3), Qt::CaseInsensitive) && !isBuildWithSymbianSbsV2()) { - results.append(ProjectExplorer::Task(ProjectExplorer::Task::Error, - QCoreApplication::translate("ProjectExplorer::Internal::S60ProjectChecker", - "The Symbian SDK and the project sources must reside on the same drive."), - QString(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); - } - } -#endif - - if (includeTargetSpecificErrors) { - QList<Qt4BaseTargetFactory *> factories; - foreach (const QString &id, supportedTargetIds()) - if (Qt4BaseTargetFactory *factory = Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(id)) - factories << factory; - - qSort(factories); - QList<Qt4BaseTargetFactory *>::iterator newend = std::unique(factories.begin(), factories.end()); - QList<Qt4BaseTargetFactory *>::iterator it = factories.begin(); - for ( ; it != newend; ++it) - results.append((*it)->reportIssues(proFile)); - } - return results; -} - -QString QtVersion::displayName() const -{ - return m_displayName; -} - -QString QtVersion::qmakeCommand() const -{ - return m_qmakeCommand; -} - -QString QtVersion::sourcePath() const -{ - return m_sourcePath; -} - -QString QtVersion::mkspec() const -{ - updateAbiAndMkspec(); - return m_mkspec; -} - -QString QtVersion::mkspecPath() const -{ - updateAbiAndMkspec(); - return m_mkspecFullPath; -} - -bool QtVersion::isBuildWithSymbianSbsV2() const -{ - updateAbiAndMkspec(); - return m_isBuildUsingSbsV2; -} - -QString QtVersion::qtVersionString() const -{ - if (m_qtVersionString.isNull()) { - QFileInfo qmake(m_qmakeCommand); - if (qmake.exists() && qmake.isExecutable()) { - m_qtVersionString = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath()); - } else { - m_qtVersionString = QLatin1String(""); - } - } - return m_qtVersionString; -} - -QtVersionNumber QtVersion::qtVersion() const -{ - //todo cache this; - return QtVersionNumber(qtVersionString()); -} - -QHash<QString,QString> QtVersion::versionInfo() const -{ - updateVersionInfo(); - return m_versionInfo; -} - -void QtVersion::setDisplayName(const QString &name) -{ - m_displayName = name; -} - -void QtVersion::setQMakeCommand(const QString& qmakeCommand) -{ - m_qmakeCommand = QDir::fromNativeSeparators(qmakeCommand); -#ifdef Q_OS_WIN - m_qmakeCommand = m_qmakeCommand.toLower(); -#endif - m_designerCommand.clear(); - m_linguistCommand.clear(); - m_qmlviewerCommand.clear(); - m_uicCommand.clear(); - m_abiUpToDate = false; - // TODO do i need to optimize this? - m_versionInfoUpToDate = false; - m_qtVersionString.clear(); - updateSourcePath(); -} - -void QtVersion::updateSourcePath() -{ - updateVersionInfo(); - const QString installData = m_versionInfo["QT_INSTALL_DATA"]; - m_sourcePath = installData; - QFile qmakeCache(installData + QLatin1String("/.qmake.cache")); - if (qmakeCache.exists()) { - qmakeCache.open(QIODevice::ReadOnly | QIODevice::Text); - QTextStream stream(&qmakeCache); - while (!stream.atEnd()) { - QString line = stream.readLine().trimmed(); - if (line.startsWith(QLatin1String("QT_SOURCE_TREE"))) { - m_sourcePath = line.split(QLatin1Char('=')).at(1).trimmed(); - if (m_sourcePath.startsWith(QLatin1String("$$quote("))) { - m_sourcePath.remove(0, 8); - m_sourcePath.chop(1); - } - break; - } - } - } - m_sourcePath = QDir::cleanPath(m_sourcePath); -#ifdef Q_OS_WIN - m_sourcePath = m_sourcePath.toLower(); -#endif -} - // Returns the version that was used to build the project in that directory // That is returns the directory // To find out whether we already have a qtversion for that directory call @@ -993,11 +583,11 @@ QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &makefile) return QString(); } -QtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath) +BaseQtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath) { - foreach(QtVersion *v, versions()) { - if (v->qmakeCommand() == qmakePath) { - return v; + foreach(BaseQtVersion *version, versions()) { + if (version->qmakeCommand() == qmakePath) { + return version; break; } } @@ -1028,11 +618,11 @@ QtVersionManager::MakefileCompatible QtVersionManager::makefileIsFor(const QStri return (srcFileInfo == proFileInfo) ? SameProject : DifferentProject; } -QPair<QtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, QtVersion::QmakeBuildConfigs defaultBuildConfig) +QPair<BaseQtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(const QString &makefile, BaseQtVersion::QmakeBuildConfigs defaultBuildConfig) { if (debug) qDebug()<<"ScanMakeFile, the gory details:"; - QtVersion::QmakeBuildConfigs result = defaultBuildConfig; + BaseQtVersion::QmakeBuildConfigs result = defaultBuildConfig; QString result2; QString line = findQMakeLine(makefile, QLatin1String("# Command:")); @@ -1071,9 +661,9 @@ QPair<QtVersion::QmakeBuildConfigs, QString> QtVersionManager::scanMakeFile(cons if (debug) { qDebug()<<"\n\nDumping information from scanMakeFile"; qDebug()<<"QMake CONFIG variable parsing"; - qDebug()<<" "<< (result & QtVersion::NoBuild ? "No Build" : QString::number(int(result))); - qDebug()<<" "<< (result & QtVersion::DebugBuild ? "debug" : "release"); - qDebug()<<" "<< (result & QtVersion::BuildAll ? "debug_and_release" : "no debug_and_release"); + qDebug()<<" "<< (result & BaseQtVersion::NoBuild ? "No Build" : QString::number(int(result))); + qDebug()<<" "<< (result & BaseQtVersion::DebugBuild ? "debug" : "release"); + qDebug()<<" "<< (result & BaseQtVersion::BuildAll ? "debug_and_release" : "no debug_and_release"); qDebug()<<"\nAddtional Arguments"; qDebug()<<result2; qDebug()<<"\n\n"; @@ -1152,9 +742,9 @@ void QtVersionManager::parseArgs(const QString &args, QList<QMakeAssignment> *as } /// This function extracts all the CONFIG+=debug, CONFIG+=release -QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, QtVersion::QmakeBuildConfigs defaultBuildConfig) +BaseQtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, BaseQtVersion::QmakeBuildConfigs defaultBuildConfig) { - QtVersion::QmakeBuildConfigs result = defaultBuildConfig; + BaseQtVersion::QmakeBuildConfigs result = defaultBuildConfig; QList<QMakeAssignment> oldAssignments = *assignments; assignments->clear(); foreach(const QMakeAssignment &qa, oldAssignments) { @@ -1164,19 +754,19 @@ QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList foreach(const QString &value, values) { if (value == "debug") { if (qa.op == "+=") - result = result | QtVersion::DebugBuild; + result = result | BaseQtVersion::DebugBuild; else - result = result & ~QtVersion::DebugBuild; + result = result & ~BaseQtVersion::DebugBuild; } else if (value == "release") { if (qa.op == "+=") - result = result & ~QtVersion::DebugBuild; + result = result & ~BaseQtVersion::DebugBuild; else - result = result | QtVersion::DebugBuild; + result = result | BaseQtVersion::DebugBuild; } else if (value == "debug_and_release") { if (qa.op == "+=") - result = result | QtVersion::BuildAll; + result = result | BaseQtVersion::BuildAll; else - result = result & ~QtVersion::BuildAll; + result = result & ~BaseQtVersion::BuildAll; } else { newValues.append(value); } @@ -1191,972 +781,3 @@ QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList } return result; } - -static bool queryQMakeVariables(const QString &binary, QHash<QString, QString> *versionInfo) -{ - const int timeOutMS = 30000; // Might be slow on some machines. - QFileInfo qmake(binary); - static const char * const variables[] = { - "QT_VERSION", - "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", - "QT_INSTALL_IMPORTS", - "QMAKEFEATURES" - }; - QStringList args; - for (uint i = 0; i < sizeof variables / sizeof variables[0]; ++i) - args << "-query" << variables[i]; - QProcess process; - process.start(qmake.absoluteFilePath(), args, QIODevice::ReadOnly); - if (!process.waitForStarted()) { - qWarning("Cannot start '%s': %s", qPrintable(binary), qPrintable(process.errorString())); - return false; - } - if (!process.waitForFinished(timeOutMS)) { - Utils::SynchronousProcess::stopProcess(process); - qWarning("Timeout running '%s' (%dms).", qPrintable(binary), timeOutMS); - return false; - } - if (process.exitStatus() != QProcess::NormalExit) { - qWarning("'%s' crashed.", qPrintable(binary)); - return false; - } - QByteArray output = process.readAllStandardOutput(); - QTextStream stream(&output); - while (!stream.atEnd()) { - const QString line = stream.readLine(); - const int index = line.indexOf(QLatin1Char(':')); - if (index != -1) { - const QString value = QDir::fromNativeSeparators(line.mid(index+1)); - if (value != "**Unknown**") - versionInfo->insert(line.left(index), value); - } - } - return true; -} - -void QtVersion::updateVersionInfo() const -{ - if (m_versionInfoUpToDate) - return; - - // extract data from qmake executable - m_versionInfo.clear(); - m_notInstalled = false; - m_hasExamples = false; - m_hasDocumentation = false; - m_hasDebuggingHelper = false; - m_hasQmlDump = false; - m_hasQmlDebuggingLibrary = false; - m_hasQmlObserver = false; - m_qmakeIsExecutable = true; - - QFileInfo fi(qmakeCommand()); - if (!fi.exists() || !fi.isExecutable()) { - m_qmakeIsExecutable = false; - return; - } - - if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo)) - return; - - if (m_versionInfo.contains("QT_INSTALL_DATA")) { - QString qtInstallData = m_versionInfo.value("QT_INSTALL_DATA"); - QString qtHeaderData = m_versionInfo.value("QT_INSTALL_HEADERS"); - m_versionInfo.insert("QMAKE_MKSPECS", QDir::cleanPath(qtInstallData+"/mkspecs")); - - if (!qtInstallData.isEmpty()) { - m_hasDebuggingHelper = !DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty(); - m_hasQmlDump - = !QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, false).isEmpty() - || !QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, true).isEmpty(); - m_hasQmlDebuggingLibrary - = !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, false).isEmpty() - || !QmlDebuggingLibrary::libraryByInstallData(qtInstallData, true).isEmpty(); - m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty(); - } - } - - // Now check for a qt that is configured with a prefix but not installed - if (m_versionInfo.contains("QT_INSTALL_BINS")) { - QFileInfo fi(m_versionInfo.value("QT_INSTALL_BINS")); - if (!fi.exists()) - m_notInstalled = true; - } - if (m_versionInfo.contains("QT_INSTALL_HEADERS")){ - QFileInfo fi(m_versionInfo.value("QT_INSTALL_HEADERS")); - if (!fi.exists()) - m_notInstalled = true; - } - if (m_versionInfo.contains("QT_INSTALL_DOCS")){ - QFileInfo fi(m_versionInfo.value("QT_INSTALL_DOCS")); - if (fi.exists()) - m_hasDocumentation = true; - } - if (m_versionInfo.contains("QT_INSTALL_EXAMPLES")){ - QFileInfo fi(m_versionInfo.value("QT_INSTALL_EXAMPLES")); - if (fi.exists()) - m_hasExamples = true; - } - if (m_versionInfo.contains("QT_INSTALL_DEMOS")){ - QFileInfo fi(m_versionInfo.value("QT_INSTALL_DEMOS")); - if (fi.exists()) - m_hasDemos = true; - } - - m_versionInfoUpToDate = true; -} - -QString QtVersion::findQtBinary(const QStringList &possibleCommands) const -{ - const QString qtdirbin = versionInfo().value(QLatin1String("QT_INSTALL_BINS")) + QLatin1Char('/'); - foreach (const QString &possibleCommand, possibleCommands) { - const QString fullPath = qtdirbin + possibleCommand; - if (QFileInfo(fullPath).isFile()) - return QDir::cleanPath(fullPath); - } - return QString(); -} - -QString QtVersion::uicCommand() const -{ - if (!isValid()) - return QString(); - if (!m_uicCommand.isNull()) - return m_uicCommand; -#ifdef Q_OS_WIN - const QStringList possibleCommands(QLatin1String("uic.exe")); -#else - QStringList possibleCommands; - 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) -{ -#ifdef Q_OS_WIN - return QStringList(name + QLatin1String(".exe")); -#elif defined(Q_OS_MAC) // 'Foo.app/Contents/MacOS/Foo' - QString upCaseName = name; - upCaseName[0] = upCaseName.at(0).toUpper(); - QString macBinary = upCaseName; - macBinary += QLatin1String(".app/Contents/MacOS/"); - macBinary += upCaseName; - return QStringList(macBinary); -#else - return QStringList(name); -#endif -} - -QString QtVersion::designerCommand() const -{ - if (!isValid()) - return QString(); - if (m_designerCommand.isNull()) - m_designerCommand = findQtBinary(possibleGuiBinaries(QLatin1String("designer"))); - return m_designerCommand; -} - -QString QtVersion::linguistCommand() const -{ - if (!isValid()) - return QString(); - if (m_linguistCommand.isNull()) - m_linguistCommand = findQtBinary(possibleGuiBinaries(QLatin1String("linguist"))); - return m_linguistCommand; -} - -QString QtVersion::qmlviewerCommand() const -{ - if (!isValid()) - return QString(); - - if (m_qmlviewerCommand.isNull()) { -#ifdef Q_OS_MAC - const QString qmlViewerName = QLatin1String("QMLViewer"); -#else - const QString qmlViewerName = QLatin1String("qmlviewer"); -#endif - - m_qmlviewerCommand = findQtBinary(possibleGuiBinaries(qmlViewerName)); - } - return m_qmlviewerCommand; -} - -void QtVersion::setSystemRoot(const QString &root) -{ - if (root == m_systemRoot) - return; - m_systemRoot = root; - m_abiUpToDate = false; -} - -QString QtVersion::systemRoot() const -{ - updateAbiAndMkspec(); - return m_systemRoot; -} - -bool QtVersion::supportsTargetId(const QString &id) const -{ - updateAbiAndMkspec(); - return m_targetIds.contains(id); -} - -QSet<QString> QtVersion::supportedTargetIds() const -{ - updateAbiAndMkspec(); - return m_targetIds; -} - -QList<ProjectExplorer::Abi> QtVersion::qtAbis() const -{ - updateAbiAndMkspec(); - return m_abis; -} - -// if none, then it's INVALID everywhere this function is called -void QtVersion::updateAbiAndMkspec() const -{ - if (m_id == -1 || m_abiUpToDate) - return; - - m_abiUpToDate = true; - - m_targetIds.clear(); - m_abis.clear(); - m_validSystemRoot = true; - -// qDebug()<<"Finding mkspec for"<<qmakeCommand(); - - // no .qmake.cache so look at the default mkspec - - QString baseMkspecDir = versionInfo().value("QMAKE_MKSPECS"); - if (baseMkspecDir.isEmpty()) - baseMkspecDir = versionInfo().value("QT_INSTALL_DATA") + "/mkspecs"; - -#ifdef Q_OS_WIN - baseMkspecDir = baseMkspecDir.toLower(); -#endif - - QString mkspecFullPath = baseMkspecDir + "/default"; - - // qDebug() << "default mkspec is located at" << mkspecFullPath; - -#ifdef Q_OS_WIN - QFile f2(mkspecFullPath + "/qmake.conf"); - if (f2.exists() && f2.open(QIODevice::ReadOnly)) { - while (!f2.atEnd()) { - QByteArray line = f2.readLine(); - if (line.startsWith("QMAKESPEC_ORIGINAL")) { - const QList<QByteArray> &temp = line.split('='); - if (temp.size() == 2) { - QString possibleFullPath = temp.at(1).trimmed(); - // We sometimes get a mix of different slash styles here... - possibleFullPath = possibleFullPath.replace('\\', '/'); - if (QFileInfo(possibleFullPath).exists()) // Only if the path exists - mkspecFullPath = possibleFullPath; - } - break; - } - } - f2.close(); - } -#elif defined(Q_OS_MAC) - QFile f2(mkspecFullPath + "/qmake.conf"); - if (f2.exists() && f2.open(QIODevice::ReadOnly)) { - while (!f2.atEnd()) { - QByteArray line = f2.readLine(); - if (line.startsWith("MAKEFILE_GENERATOR")) { - const QList<QByteArray> &temp = line.split('='); - if (temp.size() == 2) { - const QByteArray &value = temp.at(1); - if (value.contains("XCODE")) { - // we don't want to generate xcode projects... -// qDebug() << "default mkspec is xcode, falling back to g++"; - mkspecFullPath = baseMkspecDir + "/macx-g++"; - } - //resolve mkspec link - mkspecFullPath = QFileInfo(mkspecFullPath).canonicalFilePath(); - } - break; - } - } - f2.close(); - } -#else - mkspecFullPath = QFileInfo(mkspecFullPath).canonicalFilePath(); -#endif - -#ifdef Q_OS_WIN - mkspecFullPath = mkspecFullPath.toLower(); -#endif - - m_mkspecFullPath = mkspecFullPath; - QString mkspec = m_mkspecFullPath; - - if (mkspec.startsWith(baseMkspecDir)) { - mkspec = mkspec.mid(baseMkspecDir.length() + 1); -// qDebug() << "Setting mkspec to"<<mkspec; - } else { - QString sourceMkSpecPath = sourcePath() + "/mkspecs"; - if (mkspec.startsWith(sourceMkSpecPath)) { - mkspec = mkspec.mid(sourceMkSpecPath.length() + 1); - } else { - // Do nothing - } - } - - m_mkspec = mkspec; - m_isBuildUsingSbsV2 = false; - - ProFileOption option; - option.properties = versionInfo(); - ProMessageHandler msgHandler(true); - ProFileCacheManager::instance()->incRefCount(); - ProFileParser parser(ProFileCacheManager::instance()->cache(), &msgHandler); - ProFileEvaluator evaluator(&option, &parser, &msgHandler); - if (ProFile *pro = parser.parsedProFile(m_mkspecFullPath + "/qmake.conf")) { - evaluator.setCumulative(false); - evaluator.accept(pro, ProFileEvaluator::LoadProOnly); - pro->deref(); - } - - QString qmakeCXX = evaluator.values("QMAKE_CXX").join(" "); - QString makefileGenerator = evaluator.value("MAKEFILE_GENERATOR"); - QString ce_sdk = evaluator.values("CE_SDK").join(QLatin1String(" ")); - QString ce_arch = evaluator.value("CE_ARCH"); - - const QString coreLibrary = qtCorePath(); - - // Evaluate all the information we have: - if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) { - // Treat windows CE as desktop. - m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::WindowsOS, - ProjectExplorer::Abi::WindowsCEFlavor, ProjectExplorer::Abi::PEFormat, false)); - m_targetIds.insert(Constants::DESKTOP_TARGET_ID); - } else if (makefileGenerator == QLatin1String("SYMBIAN_ABLD") || - makefileGenerator == QLatin1String("SYMBIAN_SBSV2") || - makefileGenerator == QLatin1String("SYMBIAN_UNIX")) { - m_isBuildUsingSbsV2 = (makefileGenerator == QLatin1String("SYMBIAN_SBSV2")); - if (S60Manager::instance()) { - m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::SymbianOS, - ProjectExplorer::Abi::UnknownFlavor, - ProjectExplorer::Abi::ElfFormat, - 32)); - m_targetIds.insert(QLatin1String(Constants::S60_DEVICE_TARGET_ID)); - m_targetIds.insert(QLatin1String(Constants::S60_EMULATOR_TARGET_ID)); - } - } else if (MaemoGlobal::isValidMaemo5QtVersion(this)) { - m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::MaemoLinuxFlavor, ProjectExplorer::Abi::ElfFormat, - 32)); - m_targetIds.insert(QLatin1String(Constants::MAEMO5_DEVICE_TARGET_ID)); - } else if (MaemoGlobal::isValidHarmattanQtVersion(this)) { - m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::HarmattanLinuxFlavor, - ProjectExplorer::Abi::ElfFormat, - 32)); - m_targetIds.insert(QLatin1String(Constants::HARMATTAN_DEVICE_TARGET_ID)); - } else if (MaemoGlobal::isValidMeegoQtVersion(this)) { - m_abis.append(ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, ProjectExplorer::Abi::LinuxOS, - ProjectExplorer::Abi::MeegoLinuxFlavor, - ProjectExplorer::Abi::ElfFormat, 32)); - m_targetIds.insert(QLatin1String(Constants::MEEGO_DEVICE_TARGET_ID)); - } else if (qmakeCXX.contains("g++") - || qmakeCXX == "cl" || qmakeCXX == "icl" // intel cl - || qmakeCXX == QLatin1String("icpc")) { - m_abis = ProjectExplorer::Abi::abisOfBinary(coreLibrary); -#if defined (Q_OS_WIN) - if (makefileGenerator == "MINGW") { - QList<ProjectExplorer::Abi> tmp = m_abis; - m_abis.clear(); - foreach (const ProjectExplorer::Abi &abi, tmp) - m_abis.append(ProjectExplorer::Abi(abi.architecture(), abi.os(), ProjectExplorer::Abi::WindowsMSysFlavor, - abi.binaryFormat(), abi.wordWidth())); - } -#endif - m_targetIds.insert(QLatin1String(Constants::DESKTOP_TARGET_ID)); - } - - if (m_abis.isEmpty() && !coreLibrary.isEmpty()) { - qWarning("Warning: Could not find ABI for '%s' ('%s', %s)/%s by looking at %s:" - "Qt Creator does not know about the system includes, " - "nor the system defines.", - qPrintable(m_mkspecFullPath), qPrintable(displayName()), - qPrintable(qmakeCommand()), qPrintable(qmakeCXX), qPrintable(coreLibrary)); - } - - QStringList configValues = evaluator.values("CONFIG"); - m_defaultConfigIsDebugAndRelease = false; - foreach(const QString &value, configValues) { - if (value == "debug") - m_defaultConfigIsDebug = true; - else if (value == "release") - m_defaultConfigIsDebug = false; - else if (value == "build_all") - m_defaultConfigIsDebugAndRelease = true; - } - // Is this actually a simulator Qt? - if (configValues.contains(QLatin1String("simulator"))) { - m_targetIds.clear(); - m_targetIds.insert(QLatin1String(Constants::QT_SIMULATOR_TARGET_ID)); - } - ProFileCacheManager::instance()->decRefCount(); - - // Set up systemroot - if (supportsTargetId(Constants::MAEMO5_DEVICE_TARGET_ID) - || supportsTargetId(Constants::HARMATTAN_DEVICE_TARGET_ID) - || supportsTargetId(Constants::MEEGO_DEVICE_TARGET_ID)) { - if (m_systemRoot.isNull()) { - QFile file(QDir::cleanPath(MaemoGlobal::targetRoot(this)) - + QLatin1String("/information")); - if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream stream(&file); - while (!stream.atEnd()) { - const QString &line = stream.readLine().trimmed(); - const QStringList &list = line.split(QLatin1Char(' ')); - if (list.count() <= 1) - continue; - if (list.at(0) == QLatin1String("sysroot")) { - m_systemRoot = MaemoGlobal::maddeRoot(this) - + QLatin1String("/sysroots/") + list.at(1); - } - } - } - } - } else if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID) - || supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) { - if (m_systemRoot.isEmpty()) - m_validSystemRoot = false; - - if (!m_systemRoot.endsWith(QLatin1Char('/'))) - m_systemRoot.append(QLatin1Char('/')); - - QFileInfo cppheader(m_systemRoot + QLatin1String("epoc32/include/stdapis/string.h")); - if (!cppheader.exists()) - m_validSystemRoot = false; - } else { - m_systemRoot = QLatin1String(""); - } -} - -QString QtVersion::qtCorePath() const -{ - QList<QDir> dirs; - dirs << QDir(libraryInstallPath()) << QDir(versionInfo().value(QLatin1String("QT_INSTALL_BINS"))); - - QFileInfoList staticLibs; - foreach (const QDir &d, dirs) { - QFileInfoList infoList = d.entryInfoList(); - foreach (const QFileInfo &info, infoList) { - const QString file = info.fileName(); - if (info.isDir() - && file.startsWith(QLatin1String("QtCore")) - && file.endsWith(QLatin1String(".framework"))) { - // handle Framework - const QString libName = file.left(file.lastIndexOf('.')); - return info.absoluteFilePath() + '/' + libName; - } - if (info.isReadable()) { - if (file.startsWith(QLatin1String("libQtCore")) - || file.startsWith(QLatin1String("QtCore"))) { - // Only handle static libs if we can not find dynamic ones: - if (file.endsWith(".a") || file.endsWith(".lib")) - staticLibs.append(info); - else if (file.endsWith(QLatin1String(".dll")) - || file.endsWith(QString::fromLatin1(".so.") + qtVersionString()) - || file.endsWith(QLatin1Char('.') + qtVersionString() + QLatin1String(".dylib"))) - return info.absoluteFilePath(); - } - } - } - } - // Return path to first static library found: - if (!staticLibs.isEmpty()) - return staticLibs.at(0).absoluteFilePath(); - return QString(); -} - -QString QtVersion::sbsV2Directory() const -{ - QDir dir(m_sbsV2Directory); - if (dir.exists(QLatin1String("sbs"))) - return dir.absolutePath(); - dir.cd("bin"); - if (dir.exists(QLatin1String("sbs"))) - return dir.absolutePath(); - return m_sbsV2Directory; -} - -void QtVersion::setSbsV2Directory(const QString &directory) -{ - QDir dir(directory); - if (dir.exists(QLatin1String("sbs"))) { - m_sbsV2Directory = dir.absolutePath(); - return; - } - dir.cd("bin"); - if (dir.exists(QLatin1String("sbs"))) { - m_sbsV2Directory = dir.absolutePath(); - return; - } - m_sbsV2Directory = directory; -} - -void QtVersion::addToEnvironment(Utils::Environment &env) const -{ - // Generic: - env.set("QTDIR", QDir::toNativeSeparators(versionInfo().value("QT_INSTALL_DATA"))); - env.prependOrSetPath(versionInfo().value("QT_INSTALL_BINS")); - env.prependOrSetLibrarySearchPath(versionInfo().value("QT_INSTALL_LIBS")); - - // Symbian specific: - if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID) - || supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) { - // Generic Symbian environment: - QString epocRootPath(systemRoot()); - QDir epocDir(epocRootPath); - - // Clean up epoc root path for the environment: - if (!epocRootPath.endsWith(QLatin1Char('/'))) - epocRootPath.append(QLatin1Char('/')); - if (!isBuildWithSymbianSbsV2()) { -#ifdef Q_OS_WIN - if (epocRootPath.count() > 2 - && epocRootPath.at(0).toLower() >= QLatin1Char('a') - && epocRootPath.at(0).toLower() <= QLatin1Char('z') - && epocRootPath.at(1) == QLatin1Char(':')) { - epocRootPath = epocRootPath.mid(2); - } -#endif - } - env.set(QLatin1String("EPOCROOT"), QDir::toNativeSeparators(epocRootPath)); - - env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/tools"))); // e.g. make.exe - // Windows only: - if (ProjectExplorer::Abi::hostAbi().os() == ProjectExplorer::Abi::WindowsOS) { - QString winDir = QLatin1String(qgetenv("WINDIR")); - if (!winDir.isEmpty()) - env.prependOrSetPath(QDir(winDir).filePath(QLatin1String("system32"))); - - if (epocDir.exists(QLatin1String("epoc32/gcc/bin"))) - env.prependOrSetPath(epocDir.filePath(QLatin1String("epoc32/gcc/bin"))); // e.g. cpp.exe, *NOT* gcc.exe - // Find perl in the special Symbian flavour: - if (epocDir.exists(QLatin1String("../../tools/perl/bin"))) { - epocDir.cd(QLatin1String("../../tools/perl/bin")); - env.prependOrSetPath(epocDir.absolutePath()); - } else { - env.prependOrSetPath(epocDir.filePath(QLatin1String("perl/bin"))); - } - } - - // SBSv2: - if (isBuildWithSymbianSbsV2()) { - QString sbsHome(env.value(QLatin1String("SBS_HOME"))); - QString sbsConfig = sbsV2Directory(); - if (!sbsConfig.isEmpty()) { - env.prependOrSetPath(sbsConfig); - // SBS_HOME is the path minus the trailing /bin: - env.set(QLatin1String("SBS_HOME"), - QDir::toNativeSeparators(sbsConfig.left(sbsConfig.count() - 4))); // We need this for Qt 4.6.3 compatibility - } else if (!sbsHome.isEmpty()) { - env.prependOrSetPath(sbsHome + QLatin1String("/bin")); - } - } - } -} - -static const char *S60_EPOC_HEADERS[] = { - "include", "mkspecs/common/symbian", "epoc32/include", - "epoc32/include/osextensions/stdapis", "epoc32/include/osextensions/stdapis/sys", - "epoc32/include/stdapis", "epoc32/include/stdapis/sys", - "epoc32/include/osextensions/stdapis/stlport", "epoc32/include/stdapis/stlport", - "epoc32/include/oem", "epoc32/include/middleware", "epoc32/include/domain/middleware", - "epoc32/include/osextensions", "epoc32/include/domain/osextensions", - "epoc32/include/domain/osextensions/loc", "epoc32/include/domain/middleware/loc", - "epoc32/include/domain/osextensions/loc/sc", "epoc32/include/domain/middleware/loc/sc" -}; - -QList<ProjectExplorer::HeaderPath> QtVersion::systemHeaderPathes() const -{ - QList<ProjectExplorer::HeaderPath> result; - if (supportsTargetId(Constants::S60_DEVICE_TARGET_ID) - || supportsTargetId(Constants::S60_EMULATOR_TARGET_ID)) { - QString root = systemRoot() + QLatin1Char('/'); - const int count = sizeof(S60_EPOC_HEADERS) / sizeof(const char *); - for (int i = 0; i < count; ++i) { - const QDir dir(root + QLatin1String(S60_EPOC_HEADERS[i])); - if (dir.exists()) - result.append(ProjectExplorer::HeaderPath(dir.absolutePath(), - ProjectExplorer::HeaderPath::GlobalHeaderPath)); - } - } - return result; -} - -int QtVersion::uniqueId() const -{ - return m_id; -} - -int QtVersion::getUniqueId() -{ - return QtVersionManager::instance()->getUniqueId(); -} - -bool QtVersion::isValid() const -{ - updateVersionInfo(); - updateAbiAndMkspec(); - - return m_id != -1 - && !qmakeCommand().isEmpty() - && !displayName().isEmpty() - && !m_notInstalled - && m_versionInfo.contains("QT_INSTALL_BINS") - && (!m_mkspecFullPath.isEmpty() || !m_abiUpToDate) - && !m_abis.isEmpty() - && m_qmakeIsExecutable - && m_validSystemRoot - && (!isBuildWithSymbianSbsV2() - || (isBuildWithSymbianSbsV2() - && !m_sbsV2Directory.isEmpty() - && QFileInfo(m_sbsV2Directory + QLatin1String("/sbs")).exists())); -} - -bool QtVersion::toolChainAvailable(const QString &id) const -{ - if (!isValid()) - return false; - - if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) { - QList<ProjectExplorer::ToolChain *> tcList = - ProjectExplorer::ToolChainManager::instance()->toolChains(); - foreach (ProjectExplorer::ToolChain *tc, tcList) { - if (tc->id().startsWith(QLatin1String(Constants::WINSCW_TOOLCHAIN_ID))) - return true; - } - return false; - } else if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) { - QList<ProjectExplorer::ToolChain *> tcList = - ProjectExplorer::ToolChainManager::instance()->toolChains(); - foreach (ProjectExplorer::ToolChain *tc, tcList) { - if (!tc->id().startsWith(Qt4ProjectManager::Constants::WINSCW_TOOLCHAIN_ID)) - return true; - } - return false; - } - - foreach (const ProjectExplorer::Abi &abi, qtAbis()) - if (!ProjectExplorer::ToolChainManager::instance()->findToolChains(abi).isEmpty()) - return true; - return false; -} - -QString QtVersion::invalidReason() const -{ - if (isValid()) - return QString(); - if (qmakeCommand().isEmpty()) - return QCoreApplication::translate("QtVersion", "No qmake path set"); - if (!m_qmakeIsExecutable) - return QCoreApplication::translate("QtVersion", "qmake does not exist or is not executable"); - if (displayName().isEmpty()) - return QCoreApplication::translate("QtVersion", "Qt version has no name"); - if (m_notInstalled) - return QCoreApplication::translate("QtVersion", "Qt version is not properly installed, please run make install"); - if (!m_versionInfo.contains("QT_INSTALL_BINS")) - return QCoreApplication::translate("QtVersion", - "Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?"); - if (m_abiUpToDate && m_mkspecFullPath.isEmpty()) - return QCoreApplication::translate("QtVersion", "The default mkspec symlink is broken."); - if (m_abiUpToDate && m_abis.isEmpty()) - return QCoreApplication::translate("QtVersion", "Failed to detect the ABI(s) used by the Qt version."); - if (!m_validSystemRoot) - return QCoreApplication::translate("QtVersion", "The \"Open C/C++ plugin\" is not installed in the Symbian SDK or the Symbian SDK path is misconfigured"); - if (isBuildWithSymbianSbsV2() - && (m_sbsV2Directory.isEmpty() || !QFileInfo(m_sbsV2Directory + QLatin1String("/sbs")).exists())) - return QCoreApplication::translate("QtVersion", "SBS was not found."); - return QString(); -} - -QString QtVersion::description() const -{ - if (!isValid()) - return invalidReason(); - QSet<QString> targets = supportedTargetIds(); - QString envs; - if (targets.contains(Constants::DESKTOP_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Desktop", "Qt Version is meant for the desktop"); - else if (targets.contains(Constants::S60_DEVICE_TARGET_ID) || - targets.contains(Constants::S60_EMULATOR_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Symbian", "Qt Version is meant for Symbian"); - else if (targets.contains(Constants::MAEMO5_DEVICE_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Maemo", "Qt Version is meant for Maemo5"); - else if (targets.contains(Constants::HARMATTAN_DEVICE_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Harmattan ", "Qt Version is meant for Harmattan"); - else if (targets.contains(Constants::MEEGO_DEVICE_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Meego", "Qt Version is meant for Meego"); - else if (targets.contains(Constants::QT_SIMULATOR_TARGET_ID)) - envs = QCoreApplication::translate("QtVersion", "Qt Simulator", "Qt Version is meant for Qt Simulator"); - else - envs = QCoreApplication::translate("QtVersion", "unknown", "No idea what this Qt Version is meant for!"); - return QCoreApplication::translate("QtVersion", "Qt version %1, using mkspec %2 (%3)") - .arg(qtVersionString(), mkspec(), envs); -} - -QtVersion::QmakeBuildConfigs QtVersion::defaultBuildConfig() const -{ - updateAbiAndMkspec(); - QtVersion::QmakeBuildConfigs result = QtVersion::QmakeBuildConfig(0); - - if (m_defaultConfigIsDebugAndRelease) - result = QtVersion::BuildAll; - if (m_defaultConfigIsDebug) - result = result | QtVersion::DebugBuild; - return result; -} - -bool QtVersion::hasGdbDebuggingHelper() const -{ - updateVersionInfo(); - return m_hasDebuggingHelper; -} - - -bool QtVersion::hasQmlDump() const -{ - updateVersionInfo(); - return m_hasQmlDump; -} - -bool QtVersion::hasQmlDebuggingLibrary() const -{ - updateVersionInfo(); - return m_hasQmlDebuggingLibrary; -} - -bool QtVersion::hasQmlObserver() const -{ - updateVersionInfo(); - return m_hasQmlObserver; -} - -Utils::Environment QtVersion::qmlToolsEnvironment() const -{ - // FIXME: This seems broken! - Utils::Environment environment = Utils::Environment::systemEnvironment(); - addToEnvironment(environment); - - // add preferred tool chain, as that is how the tools are built, compare QtVersion::buildDebuggingHelperLibrary - QList<ProjectExplorer::ToolChain *> alltc = - ProjectExplorer::ToolChainManager::instance()->findToolChains(qtAbis().at(0)); - if (!alltc.isEmpty()) - alltc.first()->addToEnvironment(environment); - - return environment; -} - -QString QtVersion::gdbDebuggingHelperLibrary() const -{ - QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); - if (qtInstallData.isEmpty()) - return QString(); - return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData); -} - -QString QtVersion::qmlDumpTool(bool debugVersion) const -{ - QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); - QString qtHeaderData = versionInfo().value("QT_INSTALL_HEADERS"); - if (qtInstallData.isEmpty()) - return QString(); - return QmlDumpTool::toolByInstallData(qtInstallData, qtHeaderData, debugVersion); -} - -QString QtVersion::qmlDebuggingHelperLibrary(bool debugVersion) const -{ - QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); - if (qtInstallData.isEmpty()) - return QString(); - return QmlDebuggingLibrary::libraryByInstallData(qtInstallData, debugVersion); -} - -QString QtVersion::qmlObserverTool() const -{ - QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); - if (qtInstallData.isEmpty()) - return QString(); - return QmlObserverTool::toolByInstallData(qtInstallData); -} - -QStringList QtVersion::debuggingHelperLibraryLocations() const -{ - QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); - if (qtInstallData.isEmpty()) - return QStringList(); - return DebuggingHelperLibrary::locationsByInstallData(qtInstallData); -} - -bool QtVersion::hasDocumentation() const -{ - updateVersionInfo(); - return m_hasDocumentation; -} - -QString QtVersion::documentationPath() const -{ - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_DOCS"]; -} - -bool QtVersion::hasDemos() const -{ - updateVersionInfo(); - return m_hasDemos; -} - -QString QtVersion::demosPath() const -{ - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_DEMOS"]; -} - -QString QtVersion::headerInstallPath() const -{ - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_HEADERS"]; -} - -QString QtVersion::frameworkInstallPath() const -{ -#ifdef Q_OS_MAC - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_LIBS"]; -#else - return QString(); -#endif -} - -QString QtVersion::libraryInstallPath() const -{ - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_LIBS"]; -} - -bool QtVersion::hasExamples() const -{ - updateVersionInfo(); - return m_hasExamples; -} - -QString QtVersion::examplesPath() const -{ - updateVersionInfo(); - return m_versionInfo["QT_INSTALL_EXAMPLES"]; -} - -void QtVersion::invalidateCache() -{ - m_versionInfoUpToDate = false; -} - -/////////////// -// QtVersionNumber -/////////////// - - -QtVersionNumber::QtVersionNumber(int ma, int mi, int p) - : majorVersion(ma), minorVersion(mi), patchVersion(p) -{ -} - -QtVersionNumber::QtVersionNumber(const QString &versionString) -{ - if (!checkVersionString(versionString)) { - majorVersion = minorVersion = patchVersion = -1; - return; - } - - QStringList parts = versionString.split(QLatin1Char('.')); - majorVersion = parts.at(0).toInt(); - minorVersion = parts.at(1).toInt(); - patchVersion = parts.at(2).toInt(); -} - -QtVersionNumber::QtVersionNumber() -{ - majorVersion = minorVersion = patchVersion = -1; -} - - -bool QtVersionNumber::checkVersionString(const QString &version) const -{ - int dots = 0; - QString validChars = "0123456789."; - foreach (const QChar &c, version) { - if (!validChars.contains(c)) - return false; - if (c == '.') - ++dots; - } - if (dots != 2) - return false; - return true; -} - -bool QtVersionNumber::operator <(const QtVersionNumber &b) const -{ - if (majorVersion < b.majorVersion) - return true; - if (majorVersion > b.majorVersion) - return false; - if (minorVersion < b.minorVersion) - return true; - if (minorVersion > b.minorVersion) - return false; - if (patchVersion < b.patchVersion) - return true; - return false; -} - -bool QtVersionNumber::operator >(const QtVersionNumber &b) const -{ - return b < *this; -} - -bool QtVersionNumber::operator ==(const QtVersionNumber &b) const -{ - return majorVersion == b.majorVersion - && minorVersion == b.minorVersion - && patchVersion == b.patchVersion; -} - -bool QtVersionNumber::operator !=(const QtVersionNumber &b) const -{ - return !(*this == b); -} - -bool QtVersionNumber::operator <=(const QtVersionNumber &b) const -{ - return !(*this > b); -} - -bool QtVersionNumber::operator >=(const QtVersionNumber &b) const -{ - return b <= *this; -} diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 93c40c7697..2b676e06f3 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -34,6 +34,7 @@ #define QTVERSIONMANAGER_H #include "qt4projectmanager_global.h" +#include "baseqtversion.h" #include <projectexplorer/abi.h> @@ -42,6 +43,7 @@ #include <QtCore/QSharedPointer> #include <QtCore/QFutureInterface> #include <QtCore/QStringList> +#include <QtCore/QVariantMap> namespace Utils { class Environment; @@ -54,194 +56,13 @@ class Task; } namespace Qt4ProjectManager { +class BaseQtVersion; namespace Internal { class QtOptionsPageWidget; class QtOptionsPage; } -class QT4PROJECTMANAGER_EXPORT QtVersionNumber -{ -public: - QtVersionNumber(int ma, int mi, int p); - QtVersionNumber(const QString &versionString); - QtVersionNumber(); - - int majorVersion; - int minorVersion; - int patchVersion; - bool operator <(const QtVersionNumber &b) const; - bool operator <=(const QtVersionNumber &b) const; - bool operator >(const QtVersionNumber &b) const; - bool operator >=(const QtVersionNumber &b) const; - bool operator !=(const QtVersionNumber &b) const; - bool operator ==(const QtVersionNumber &b) const; -private: - bool checkVersionString(const QString &version) const; -}; - - -class QT4PROJECTMANAGER_EXPORT QtVersion -{ - friend class QtVersionManager; -public: - QtVersion(const QString &name, const QString &qmakeCommand, - bool isAutodetected = false, const QString &autodetectionSource = QString()); - - explicit QtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); - - QtVersion(const QString &name, const QString &qmakeCommand, int id, - bool isAutodetected = false, const QString &autodetectionSource = QString()); - QtVersion(); - ~QtVersion(); - - bool isValid() const; - bool toolChainAvailable(const QString &id) const; - - QString invalidReason() const; - QString description() const; - bool isAutodetected() const { return m_isAutodetected; } - QString autodetectionSource() const { return m_autodetectionSource; } - - QString displayName() const; - QString sourcePath() const; - QString qmakeCommand() const; - QString uicCommand() const; - QString designerCommand() const; - QString linguistCommand() const; - QString qmlviewerCommand() const; - QString systemRoot() const; - void setSystemRoot(const QString &); - - bool supportsTargetId(const QString &id) const; - QSet<QString> supportedTargetIds() const; - - QList<ProjectExplorer::Abi> qtAbis() const; - - /// @returns the name of the mkspec, which is generally not enough - /// to pass to qmake. - QString mkspec() const; - /// @returns the full path to the default directory - /// specifally not the directory the symlink/ORIGINAL_QMAKESPEC points to - QString mkspecPath() const; - - bool isBuildWithSymbianSbsV2() const; - - void setDisplayName(const QString &name); - void setQMakeCommand(const QString &path); - - QString qtVersionString() const; - QtVersionNumber qtVersion() const; - // Returns the PREFIX, BINPREFIX, DOCPREFIX and similar information - QHash<QString,QString> versionInfo() const; - - QString sbsV2Directory() const; - void setSbsV2Directory(const QString &directory); - - void addToEnvironment(Utils::Environment &env) const; - QList<ProjectExplorer::HeaderPath> systemHeaderPathes() const; - - QString gdbDebuggingHelperLibrary() const; - QString qmlDebuggingHelperLibrary(bool debugVersion) const; - QString qmlDumpTool(bool debugVersion) const; - QString qmlObserverTool() const; - QStringList debuggingHelperLibraryLocations() const; - - bool hasGdbDebuggingHelper() const; - bool hasQmlDump() const; - bool hasQmlDebuggingLibrary() const; - bool hasQmlObserver() const; - Utils::Environment qmlToolsEnvironment() const; - - void invalidateCache(); - - bool hasExamples() const; - QString examplesPath() const; - - bool hasDocumentation() const; - QString documentationPath() const; - - bool hasDemos() const; - QString demosPath() const; - - QString headerInstallPath() const; - QString frameworkInstallPath() const; - QString libraryInstallPath() const; - - // All valid Ids are >= 0 - int uniqueId() const; - - enum QmakeBuildConfig - { - NoBuild = 1, - DebugBuild = 2, - BuildAll = 8 - }; - - Q_DECLARE_FLAGS(QmakeBuildConfigs, QmakeBuildConfig) - - QmakeBuildConfigs defaultBuildConfig() const; - QString toHtml(bool verbose) const; - - bool supportsShadowBuilds() const; - - /// Check a .pro-file/Qt version combination on possible issues with - /// its symbian setup. - /// @return a list of tasks, ordered on severity (errors first, then - /// warnings and finally info items. - QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir, bool includeTargetSpecificErrors); - - ProjectExplorer::IOutputParser *createOutputParser() const; - -private: - static int getUniqueId(); - // Also used by QtOptionsPageWidget - void updateSourcePath(); - void updateVersionInfo() const; - QString findQtBinary(const QStringList &possibleName) const; - void updateAbiAndMkspec() const; - QString qtCorePath() const; - - QString m_displayName; - QString m_sourcePath; - int m_id; - bool m_isAutodetected; - QString m_autodetectionSource; - mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate - mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate - mutable bool m_hasQmlDebuggingLibrary; // controlled by m_versionInfoUpdate - mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate - - QString m_sbsV2Directory; - mutable QString m_systemRoot; - - mutable bool m_abiUpToDate; - mutable QString m_mkspec; // updated lazily - mutable QString m_mkspecFullPath; - mutable QList<ProjectExplorer::Abi> m_abis; - - mutable bool m_versionInfoUpToDate; - mutable QHash<QString,QString> m_versionInfo; // updated lazily - mutable bool m_notInstalled; - mutable bool m_defaultConfigIsDebug; - mutable bool m_defaultConfigIsDebugAndRelease; - mutable bool m_hasExamples; - mutable bool m_hasDemos; - mutable bool m_hasDocumentation; - - mutable QString m_qmakeCommand; - mutable QString m_qtVersionString; - mutable QString m_uicCommand; - mutable QString m_designerCommand; - mutable QString m_linguistCommand; - mutable QString m_qmlviewerCommand; - mutable QSet<QString> m_targetIds; - - mutable bool m_isBuildUsingSbsV2; - mutable bool m_qmakeIsExecutable; - mutable bool m_validSystemRoot; -}; - struct QMakeAssignment { QString variable; @@ -253,51 +74,49 @@ class QT4PROJECTMANAGER_EXPORT QtVersionManager : public QObject { Q_OBJECT // for getUniqueId(); - friend class QtVersion; + friend class BaseQtVersion; friend class Internal::QtOptionsPage; public: static QtVersionManager *instance(); QtVersionManager(); ~QtVersionManager(); + void extensionsInitialized(); // This will *always* return at least one (Qt in Path), even if that is // unconfigured. - QList<QtVersion *> versions() const; - QList<QtVersion *> validVersions() const; + QList<BaseQtVersion *> versions() const; + QList<BaseQtVersion *> validVersions() const; // Note: DO NOT STORE THIS POINTER! // The QtVersionManager will delete it at random times and you will // need to get a new pointer by calling this method again! - QtVersion *version(int id) const; - QtVersion *emptyVersion() const; + BaseQtVersion *version(int id) const; - QtVersion *qtVersionForQMakeBinary(const QString &qmakePath); + BaseQtVersion *qtVersionForQMakeBinary(const QString &qmakePath); // Used by the projectloadwizard - void addVersion(QtVersion *version); - void removeVersion(QtVersion *version); + void addVersion(BaseQtVersion *version); + void removeVersion(BaseQtVersion *version); // Target Support: bool supportsTargetId(const QString &id) const; // This returns a list of versions that support the target with the given id. // @return A list of QtVersions that supports a target. This list may be empty! - QList<QtVersion *> versionsForTargetId(const QString &id, const QtVersionNumber &minimumQtVersion = QtVersionNumber()) const; + QList<BaseQtVersion *> versionsForTargetId(const QString &id, const QtVersionNumber &minimumQtVersion = QtVersionNumber()) const; QSet<QString> supportedTargetIds() const; // Static Methods - enum MakefileCompatible { CouldNotParse, DifferentProject, SameProject }; static MakefileCompatible makefileIsFor(const QString &makefile, const QString &proFile); - static QPair<QtVersion::QmakeBuildConfigs, QString> scanMakeFile(const QString &makefile, - QtVersion::QmakeBuildConfigs defaultBuildConfig); + static QPair<BaseQtVersion::QmakeBuildConfigs, QString> scanMakeFile(const QString &makefile, + BaseQtVersion::QmakeBuildConfigs defaultBuildConfig); static QString findQMakeBinaryFromMakefile(const QString &directory); bool isValidId(int id) const; // Compatibility with pre-2.2: QString popPendingMwcUpdate(); QString popPendingGcceUpdate(); - signals: void qtVersionsChanged(const QList<int> &uniqueIds); void updateExamples(QString, QString, QString); @@ -306,29 +125,31 @@ private slots: void updateSettings(); private: // This function is really simplistic... - static bool equals(QtVersion *a, QtVersion *b); + static bool equals(BaseQtVersion *a, BaseQtVersion *b); static QString findQMakeLine(const QString &directory, const QString &key); static QString trimLine(const QString line); static void parseArgs(const QString &args, QList<QMakeAssignment> *assignments, QList<QMakeAssignment> *afterAssignments, QString *additionalArguments); - static QtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, - QtVersion::QmakeBuildConfigs defaultBuildConfig); + static BaseQtVersion::QmakeBuildConfigs qmakeBuildConfigFromCmdArgs(QList<QMakeAssignment> *assignments, + BaseQtVersion::QmakeBuildConfigs defaultBuildConfig); + bool restoreQtVersions(); + bool legacyRestore(); + void findSystemQt(); + void updateFromInstaller(); + void saveQtVersions(); // Used by QtOptionsPage - void setNewQtVersions(QList<QtVersion *> newVersions); + void setNewQtVersions(QList<BaseQtVersion *> newVersions); // Used by QtVersion int getUniqueId(); - void writeVersionsIntoSettings(); void addNewVersionsFromInstaller(); - void updateSystemVersion(); void updateDocumentation(); - static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list); + static int indexOfVersionInList(const BaseQtVersion * const version, const QList<BaseQtVersion *> &list); void updateUniqueIdToIndexMap(); - QtVersion *m_emptyVersion; - QMap<int, QtVersion *> m_versions; + QMap<int, BaseQtVersion *> m_versions; int m_idcount; // managed by QtProjectManagerPlugin static QtVersionManager *m_self; @@ -340,6 +161,6 @@ private: } // namespace Qt4ProjectManager -Q_DECLARE_OPERATORS_FOR_FLAGS(Qt4ProjectManager::QtVersion::QmakeBuildConfigs) +Q_DECLARE_OPERATORS_FOR_FLAGS(Qt4ProjectManager::BaseQtVersion::QmakeBuildConfigs) #endif // QTVERSIONMANAGER_H diff --git a/src/plugins/qt4projectmanager/winceqtversion.cpp b/src/plugins/qt4projectmanager/winceqtversion.cpp new file mode 100644 index 0000000000..136addb075 --- /dev/null +++ b/src/plugins/qt4projectmanager/winceqtversion.cpp @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "winceqtversion.h" +#include "qt4projectmanagerconstants.h" +#include <QtCore/QCoreApplication> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +WinCeQtVersion::WinCeQtVersion() + : BaseQtVersion() +{ + +} + +WinCeQtVersion::WinCeQtVersion(const QString &path, bool isAutodetected, const QString &autodetectionSource) + : BaseQtVersion(path, isAutodetected, autodetectionSource) +{ + +} + +WinCeQtVersion::~WinCeQtVersion() +{ + +} + +WinCeQtVersion *WinCeQtVersion::clone() const +{ + return new WinCeQtVersion(*this); +} + +QString WinCeQtVersion::type() const +{ + return Constants::WINCEQT; +} + +QList<ProjectExplorer::Abi> WinCeQtVersion::qtAbis() const +{ + return QList<ProjectExplorer::Abi>() + << ProjectExplorer::Abi(ProjectExplorer::Abi::ArmArchitecture, + ProjectExplorer::Abi::WindowsOS, + ProjectExplorer::Abi::WindowsCEFlavor, + ProjectExplorer::Abi::PEFormat, + false); +} + +bool WinCeQtVersion::supportsTargetId(const QString &id) const +{ + return id == QLatin1String(Constants::DESKTOP_TARGET_ID); +} + +QSet<QString> WinCeQtVersion::supportedTargetIds() const +{ + return QSet<QString>() << QLatin1String(Constants::DESKTOP_TARGET_ID); +} + +QString WinCeQtVersion::description() const +{ + return QCoreApplication::translate("QtVersion", "Qt for WinCE", "Qt Version is meant for WinCE"); +} diff --git a/src/plugins/qt4projectmanager/winceqtversion.h b/src/plugins/qt4projectmanager/winceqtversion.h new file mode 100644 index 0000000000..ede35fae7f --- /dev/null +++ b/src/plugins/qt4projectmanager/winceqtversion.h @@ -0,0 +1,61 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#ifndef WINCEQTVERSION_H +#define WINCEQTVERSION_H +#include "baseqtversion.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class WinCeQtVersion : public BaseQtVersion +{ +public: + WinCeQtVersion(); + WinCeQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); + ~WinCeQtVersion(); + WinCeQtVersion *clone() const; + + QString type() const; + + virtual QList<ProjectExplorer::Abi> qtAbis() const; + + virtual bool supportsTargetId(const QString &id) const; + virtual QSet<QString> supportedTargetIds() const; + + QString description() const; +}; + +} +} + +#endif // WINCEQTVERSION_H diff --git a/src/plugins/qt4projectmanager/winceqtversionfactory.cpp b/src/plugins/qt4projectmanager/winceqtversionfactory.cpp new file mode 100644 index 0000000000..7ddf03ed25 --- /dev/null +++ b/src/plugins/qt4projectmanager/winceqtversionfactory.cpp @@ -0,0 +1,83 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ + +#include "winceqtversionfactory.h" +#include "winceqtversion.h" +#include "qt4projectmanagerconstants.h" +#include <QtCore/QFileInfo> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +WinCeQtVersionFactory::WinCeQtVersionFactory(QObject *parent) + : QtVersionFactory(parent) +{ + +} + +WinCeQtVersionFactory::~WinCeQtVersionFactory() +{ + +} + +bool WinCeQtVersionFactory::canRestore(const QString &type) +{ + return type == QLatin1String(Constants::WINCEQT); +} + +BaseQtVersion *WinCeQtVersionFactory::restore(const QVariantMap &data) +{ + WinCeQtVersion *v = new WinCeQtVersion; + v->fromMap(data); + return v; +} + +int WinCeQtVersionFactory::priority() const +{ + return 50; +} + +BaseQtVersion *WinCeQtVersionFactory::create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) +{ + // we are the fallback :) so we don't care what kinf of qt it is + QFileInfo fi(qmakePath); + if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) + return 0; + + QString ce_sdk = evaluator->values("CE_SDK").join(QLatin1String(" ")); + QString ce_arch = evaluator->value("CE_ARCH"); + + if (!ce_sdk.isEmpty() && !ce_arch.isEmpty()) + return new WinCeQtVersion(qmakePath, isAutoDetected, autoDetectionSource); + + return 0; +} diff --git a/src/plugins/qt4projectmanager/winceqtversionfactory.h b/src/plugins/qt4projectmanager/winceqtversionfactory.h new file mode 100644 index 0000000000..fd4bbdfaa3 --- /dev/null +++ b/src/plugins/qt4projectmanager/winceqtversionfactory.h @@ -0,0 +1,57 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at info@qt.nokia.com. +** +**************************************************************************/ +#ifndef WINCEQTVERSIONFACTORY_H +#define WINCEQTVERSIONFACTORY_H + +#include "qtversionfactory.h" + +namespace Qt4ProjectManager { +namespace Internal { + +class WinCeQtVersionFactory : public QtVersionFactory +{ +public: + explicit WinCeQtVersionFactory(QObject *parent = 0); + ~WinCeQtVersionFactory(); + + virtual bool canRestore(const QString &type); + virtual BaseQtVersion *restore(const QVariantMap &data); + + virtual int priority() const; + + virtual BaseQtVersion *create(const QString &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); +}; + +} // Internal +} // Qt4ProjectManager + +#endif // WINCEQTVERSIONFACTORY_H diff --git a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp index c0c41fd48d..03f45d14b4 100644 --- a/src/plugins/qt4projectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtwizard.cpp @@ -315,7 +315,7 @@ bool BaseQt4ProjectWizardDialog::isTargetSelected(const QString &targetid) const void BaseQt4ProjectWizardDialog::generateProfileName(const QString &name, const QString &path) { - const QString proFile = QDir::fromNativeSeparators(path) + QChar('/') + name + QChar('/') + name + QLatin1String(".pro"); + const QString proFile = QDir::cleanPath(path + QChar('/') + name + QChar('/') + name + QLatin1String(".pro")); m_targetSetupPage->setProFilePath(proFile); } diff --git a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp index 70b9225533..76be0dd7af 100644 --- a/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp +++ b/src/plugins/qt4projectmanager/wizards/targetsetuppage.cpp @@ -207,7 +207,7 @@ bool TargetSetupPage::setupProject(Qt4ProjectManager::Qt4Project *project) Qt4BaseTargetFactory *factory = m_factories.value(it.value()); foreach (const BuildConfigurationInfo &info, it.value()->usedImportInfos()) { - QtVersion *version = info.version; + BaseQtVersion *version = info.version; for (int i=0; i < m_importInfos.size(); ++i) { if (m_importInfos.at(i).version == version) { if (m_importInfos[i].temporaryQtVersion) { |