Commit 8e171e0b authored by dt's avatar dt
Browse files

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
parent 9ef4ea40
......@@ -211,6 +211,7 @@ void BuildConfiguration::setToolChain(ProjectExplorer::ToolChain *tc)
m_toolChain = tc;
emit toolChainChanged();
emit environmentChanged();
Utils::Environment BuildConfiguration::baseEnvironment() const
......@@ -33,6 +33,8 @@
#include <QtCore/QString>
#include "projectexplorer_export.h"
namespace ProjectExplorer {
......@@ -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 =
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())
......@@ -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();
......@@ -393,7 +393,7 @@ void QmlProjectRunConfiguration::updateQtVersions()
bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::QtVersion *version)
bool QmlProjectRunConfiguration::isValidVersion(Qt4ProjectManager::BaseQtVersion *version)
if (version
&& (version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)
......@@ -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 {
......@@ -119,7 +119,7 @@ protected:
void ctor();
static bool isValidVersion(Qt4ProjectManager::QtVersion *version);
static bool isValidVersion(Qt4ProjectManager::BaseQtVersion *version);
void setQtVersionId(int id);
static QString canonicalCapsPath(const QString &filePath);
......@@ -295,7 +295,7 @@ void QmlProjectRunConfigurationWidget::updateQtVersionComboBox()
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());
This diff is collapsed.
** This file is part of Qt Creator
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (
** 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:
** 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
#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>
class ProFileEvaluator;
namespace Qt4ProjectManager {
QtVersionNumber(int ma, int mi, int p);
QtVersionNumber(const QString &versionString);
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;
bool checkVersionString(const QString &version) const;
class QT4PROJECTMANAGER_EXPORT QtConfigWidget : public QWidget
void changed();
friend class QtVersionManager;
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;
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;
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;
......@@ -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;
......@@ -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
......@@ -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);
void finished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools);
......@@ -146,7 +146,10 @@ bool ExternalQtEditor::getEditorLaunchData(const QString &fileName,
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,
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,
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,
QStringList(), false, &data, errorMessage)) {
return false;
......@@ -46,7 +46,7 @@ QT_END_NAMESPACE
namespace Qt4ProjectManager {
class QtVersion;
class BaseQtVersion;
namespace Internal {
......@@ -66,7 +66,7 @@ public:
// 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 {
......@@ -203,9 +203,13 @@ bool MakeStep::init()
ProjectExplorer::IOutputParser *parser = bc->qtVersion()->createOutputParser();
parser->appendOutputParser(new QtParser);
ProjectExplorer::IOutputParser *parser = 0;
if (bc->qtVersion())
parser = bc->qtVersion()->createOutputParser();
if (parser)
parser->appendOutputParser(new QtParser);
parser = new QtParser;
if (toolchain)
......@@ -133,7 +133,8 @@ QString QMakeStep::allArguments(bool shorted)
for (Utils::QtcProcess::ArgIterator ait(&additonalArguments);; )
if (ait.value() == QLatin1String("-spec"))
goto haveSpec;
arguments << "-spec" << bc->qtVersion()->mkspec();
if (bc->qtVersion())
arguments << "-spec" << bc->qtVersion()->mkspec();
// Find out what flags we pass on to qmake
......@@ -163,7 +164,7 @@ QStringList QMakeStep::moreArguments()
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;