forked from qt-creator/qt-creator
DebuggingHelpers: Check for Qt version instead checking private files
The location private includes might still change with 4.7.1 . Better check the qt version string. Reviewed-by: Lasse Holmstedt
This commit is contained in:
@@ -101,6 +101,33 @@ QString BuildableHelperLibrary::qtVersionForQMake(const QString &qmakePath)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BuildableHelperLibrary::checkMinimumQtVersion(const QString &qtVersionString, int majorVersion, int minorVersion, int patchVersion)
|
||||||
|
{
|
||||||
|
int major = -1;
|
||||||
|
int minor = -1;
|
||||||
|
int patch = -1;
|
||||||
|
|
||||||
|
// check format
|
||||||
|
QRegExp qtVersionRegex(QLatin1String("^\\d+\\.\\d+\\.\\d+$"));
|
||||||
|
if (!qtVersionRegex.exactMatch(qtVersionString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QStringList parts = qtVersionString.split(QLatin1Char('.'));
|
||||||
|
major = parts.at(0).toInt();
|
||||||
|
minor = parts.at(1).toInt();
|
||||||
|
patch = parts.at(2).toInt();
|
||||||
|
|
||||||
|
if (major == majorVersion) {
|
||||||
|
if (minor == minorVersion) {
|
||||||
|
if (patch >= patchVersion)
|
||||||
|
return true;
|
||||||
|
} else if (minor > minorVersion)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList BuildableHelperLibrary::possibleQMakeCommands()
|
QStringList BuildableHelperLibrary::possibleQMakeCommands()
|
||||||
{
|
{
|
||||||
// On windows no one has renamed qmake, right?
|
// On windows no one has renamed qmake, right?
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
static QString findSystemQt(const Utils::Environment &env);
|
static QString findSystemQt(const Utils::Environment &env);
|
||||||
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
|
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
|
||||||
static QString qtVersionForQMake(const QString &qmakePath);
|
static QString qtVersionForQMake(const QString &qmakePath);
|
||||||
|
static bool checkMinimumQtVersion(const QString &qtversionString, int majorVersion, int minorVersion, int patchVersion);
|
||||||
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
|
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
|
||||||
static QStringList possibleQMakeCommands();
|
static QStringList possibleQMakeCommands();
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,9 @@ static inline QStringList validBinaryFilenames()
|
|||||||
<< QLatin1String("qmldump.app/Contents/MacOS/qmldump");
|
<< QLatin1String("qmldump.app/Contents/MacOS/qmldump");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDumpTool::canBuild(const QString &installHeadersDir)
|
bool QmlDumpTool::canBuild(QtVersion *qtVersion)
|
||||||
{
|
{
|
||||||
QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h");
|
return checkMinimumQtVersion(qtVersion->qtVersionString(), 4, 7, 0);
|
||||||
return QFile::exists(qDeclHeader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project)
|
QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project)
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ namespace ProjectExplorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
|
class QtVersion;
|
||||||
|
|
||||||
class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrary
|
class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool canBuild(const QString &installHeadersDir);
|
static bool canBuild(QtVersion *qtVersion);
|
||||||
static QString toolForProject(ProjectExplorer::Project *project);
|
static QString toolForProject(ProjectExplorer::Project *project);
|
||||||
static QString toolByInstallData(const QString &qtInstallData);
|
static QString toolByInstallData(const QString &qtInstallData);
|
||||||
static QStringList locationsByInstallData(const QString &qtInstallData);
|
static QStringList locationsByInstallData(const QString &qtInstallData);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@@ -50,10 +51,9 @@ static inline QStringList validBinaryFilenames()
|
|||||||
<< QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver");
|
<< QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlObserverTool::canBuild(const QString &installHeadersDir)
|
bool QmlObserverTool::canBuild(QtVersion *qtVersion)
|
||||||
{
|
{
|
||||||
QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h");
|
return checkMinimumQtVersion(qtVersion->qtVersionString(), 4, 7, 1);
|
||||||
return QFile::exists(qDeclHeader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project)
|
QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project)
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
|
|
||||||
|
class QtVersion;
|
||||||
|
|
||||||
class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary
|
class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool canBuild(const QString &installHeadersDir);
|
static bool canBuild(QtVersion *qtVersion);
|
||||||
static QString toolForProject(ProjectExplorer::Project *project);
|
static QString toolForProject(ProjectExplorer::Project *project);
|
||||||
static QString toolByInstallData(const QString &qtInstallData);
|
static QString toolByInstallData(const QString &qtInstallData);
|
||||||
static QStringList locationsByInstallData(const QString &qtInstallData);
|
static QStringList locationsByInstallData(const QString &qtInstallData);
|
||||||
|
|||||||
@@ -1770,7 +1770,7 @@ QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future)
|
|||||||
}
|
}
|
||||||
future.setProgressValue(2);
|
future.setProgressValue(2);
|
||||||
|
|
||||||
if (QmlDumpTool::canBuild(qtInstallHeaders)) {
|
if (QmlDumpTool::canBuild(this)) {
|
||||||
QString toolDirectory = QmlDumpTool::copy(qtInstallData, &output);
|
QString toolDirectory = QmlDumpTool::copy(qtInstallData, &output);
|
||||||
if (!toolDirectory.isEmpty()) {
|
if (!toolDirectory.isEmpty()) {
|
||||||
output += QmlDumpTool::build(toolDirectory, tc->makeCommand(),
|
output += QmlDumpTool::build(toolDirectory, tc->makeCommand(),
|
||||||
@@ -1782,7 +1782,7 @@ QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future)
|
|||||||
}
|
}
|
||||||
future.setProgressValue(3);
|
future.setProgressValue(3);
|
||||||
|
|
||||||
if (QmlObserverTool::canBuild(qtInstallHeaders)) {
|
if (QmlObserverTool::canBuild(this)) {
|
||||||
QString toolDirectory = QmlObserverTool::copy(qtInstallData, &output);
|
QString toolDirectory = QmlObserverTool::copy(qtInstallData, &output);
|
||||||
if (!toolDirectory.isEmpty()) {
|
if (!toolDirectory.isEmpty()) {
|
||||||
output += QmlObserverTool::build(toolDirectory, tc->makeCommand(),
|
output += QmlObserverTool::build(toolDirectory, tc->makeCommand(),
|
||||||
|
|||||||
Reference in New Issue
Block a user