forked from qt-creator/qt-creator
Refactoring: findSystemQt can now be called for any environemnt
and returns the full path to qmake. This is step 1 towards the cmake plugin not using its own code to find the dumper.
This commit is contained in:
@@ -230,9 +230,19 @@ void QtVersionManager::addNewVersionsFromInstaller()
|
||||
void QtVersionManager::updateSystemVersion()
|
||||
{
|
||||
bool haveSystemVersion = false;
|
||||
QString systemQMakePath = findSystemQt(Environment::systemEnvironment());
|
||||
QString systemQtPath;
|
||||
if (systemQMakePath.isNull()) {
|
||||
systemQtPath = tr("<not found>");
|
||||
} else {
|
||||
QDir dir(QFileInfo(systemQMakePath).absoluteDir());
|
||||
dir.cdUp();
|
||||
systemQtPath = dir.absolutePath();
|
||||
}
|
||||
|
||||
foreach (QtVersion *version, m_versions) {
|
||||
if (version->isSystemVersion()) {
|
||||
version->setPath(findSystemQt());
|
||||
version->setPath(systemQtPath);
|
||||
version->setName(tr("Auto-detected Qt"));
|
||||
haveSystemVersion = true;
|
||||
}
|
||||
@@ -240,7 +250,7 @@ void QtVersionManager::updateSystemVersion()
|
||||
if (haveSystemVersion)
|
||||
return;
|
||||
QtVersion *version = new QtVersion(tr("Auto-detected Qt"),
|
||||
findSystemQt(),
|
||||
systemQtPath,
|
||||
getUniqueId(),
|
||||
true);
|
||||
m_versions.prepend(version);
|
||||
@@ -278,23 +288,20 @@ QString QtVersionManager::qtVersionForQMake(const QString &qmakePath)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QtVersionManager::findSystemQt() const
|
||||
QString QtVersionManager::findSystemQt(const Environment &env)
|
||||
{
|
||||
Environment env = Environment::systemEnvironment();
|
||||
QStringList paths = env.path();
|
||||
foreach (const QString &path, paths) {
|
||||
foreach (const QString &possibleCommand, possibleQMakeCommands()) {
|
||||
QFileInfo qmake(path + "/" + possibleCommand);
|
||||
if (qmake.exists()) {
|
||||
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
|
||||
QDir dir(qmake.absoluteDir());
|
||||
dir.cdUp();
|
||||
return dir.absolutePath();
|
||||
return qmake.absoluteFilePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tr("<not found>");
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
QtVersion *QtVersionManager::currentQtVersion() const
|
||||
|
@@ -40,6 +40,7 @@ namespace ProjectExplorer {
|
||||
|
||||
namespace Internal {
|
||||
class QtOptionsPageWidget;
|
||||
class QtOptionsPage;
|
||||
}
|
||||
|
||||
class PROJECTEXPLORER_EXPORT QtVersion
|
||||
@@ -77,6 +78,7 @@ public:
|
||||
void addToEnvironment(ProjectExplorer::Environment &env);
|
||||
|
||||
bool hasDebuggingHelper() const;
|
||||
QString dumperLibrary() const;
|
||||
// Builds a debugging library
|
||||
// returns the output of the commands
|
||||
QString buildDebuggingHelperLibrary();
|
||||
@@ -91,7 +93,6 @@ public:
|
||||
};
|
||||
|
||||
QmakeBuildConfig defaultBuildConfig() const;
|
||||
QString dumperLibrary() const;
|
||||
private:
|
||||
static int getUniqueId();
|
||||
// Also used by QtOptionsPageWidget
|
||||
@@ -128,7 +129,7 @@ class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject
|
||||
Q_OBJECT
|
||||
// for getUniqueId();
|
||||
friend class QtVersion;
|
||||
friend class QtOptionsPage;
|
||||
friend class Internal::QtOptionsPage;
|
||||
public:
|
||||
static QtVersionManager *instance();
|
||||
QtVersionManager();
|
||||
@@ -150,6 +151,10 @@ public:
|
||||
static QString qtVersionForQMake(const QString &qmakePath);
|
||||
static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig);
|
||||
static QString findQtVersionFromMakefile(const QString &directory);
|
||||
|
||||
// returns the full path to the first qmake, qmake-qt4, qmake4 that has
|
||||
// at least version 2.0.0 and thus is a qt4 qmake
|
||||
static QString findSystemQt(const Environment &env);
|
||||
signals:
|
||||
void defaultQtVersionChanged();
|
||||
void qtVersionsChanged();
|
||||
@@ -162,7 +167,7 @@ private:
|
||||
void addNewVersionsFromInstaller();
|
||||
void updateSystemVersion();
|
||||
void updateDocumentation();
|
||||
QString findSystemQt() const;
|
||||
|
||||
static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list);
|
||||
void updateUniqueIdToIndexMap();
|
||||
|
||||
|
Reference in New Issue
Block a user