forked from qt-creator/qt-creator
Refactoring: Use one common code to find the debugging helper library
Remove duplicated code from cmakeprojectmanager.
This commit is contained in:
@@ -156,81 +156,7 @@ QString CMakeManager::qtVersionForQMake(const QString &qmakePath)
|
||||
return QString();
|
||||
}
|
||||
|
||||
// this is mostly a copy from qt4versionmanager
|
||||
// TODO refactor this code
|
||||
// returns QPair< QTDIR, QT_INSTALL_DATA >
|
||||
QPair<QString, QString> CMakeManager::findQtDir(const ProjectExplorer::Environment &env)
|
||||
{
|
||||
QStringList possibleCommands;
|
||||
// On windows noone has renamed qmake, right?
|
||||
#ifdef Q_OS_WIN
|
||||
possibleCommands << "qmake.exe";
|
||||
#endif
|
||||
// On unix some distributions renamed qmake to avoid clashes
|
||||
possibleCommands << "qmake-qt4" << "qmake4" << "qmake";
|
||||
|
||||
QStringList paths = env.path();
|
||||
foreach (const QString &path, paths) {
|
||||
foreach (const QString &possibleCommand, possibleCommands) {
|
||||
QFileInfo qmake(path + "/" + possibleCommand);
|
||||
if (qmake.exists()) {
|
||||
if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) {
|
||||
QDir qtDir = qmake.absoluteDir();
|
||||
qtDir.cdUp();
|
||||
QProcess proc;
|
||||
proc.start(qmake.absoluteFilePath(), QStringList() << "-query" << "QT_INSTALL_DATA");
|
||||
if (proc.waitForFinished()) {
|
||||
return qMakePair(qtDir.absolutePath(), QString(proc.readAll().trimmed()));
|
||||
} else {
|
||||
proc.kill();
|
||||
QDir dir(qmake.absoluteDir());
|
||||
dir.cdUp();
|
||||
return qMakePair(qtDir.absolutePath(), dir.absolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return qMakePair(QString(), QString());
|
||||
}
|
||||
|
||||
// This code is more or less duplicated in qtversionmanager
|
||||
QString CMakeManager::findDumperLibrary(const ProjectExplorer::Environment &env)
|
||||
{
|
||||
static ProjectExplorer::Environment lastenv;
|
||||
static QString lastpath;
|
||||
if (lastenv == env)
|
||||
return lastpath;
|
||||
|
||||
QPair<QString, QString> pair = findQtDir(env);
|
||||
QString qtInstallDataDir = pair.second;
|
||||
if (qtInstallDataDir.isEmpty())
|
||||
return QString();
|
||||
|
||||
uint hash = qHash(pair.first);
|
||||
QStringList directories;
|
||||
directories
|
||||
<< (qtInstallDataDir + "/qtc-debugging-helper/")
|
||||
<< (QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash)) + "/"
|
||||
<< (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash)) + "/";
|
||||
foreach(const QString &directory, directories) {
|
||||
#if defined(Q_OS_WIN)
|
||||
QFileInfo fi(directory + "debug/gdbmacros.dll");
|
||||
#elif defined(Q_OS_MAC)
|
||||
QFileInfo fi(directory + "libgdbmacros.dylib");
|
||||
#else // generic UNIX
|
||||
QFileInfo fi(directory + "libgdbmacros.so");
|
||||
#endif
|
||||
if (fi.exists()) {
|
||||
lastpath = fi.filePath();
|
||||
return lastpath;
|
||||
}
|
||||
}
|
||||
lastpath = QString();
|
||||
return lastpath;
|
||||
}
|
||||
|
||||
/////
|
||||
////
|
||||
// CMakeRunner
|
||||
////
|
||||
// TODO give a better name, what this class is to update cached information
|
||||
|
||||
Reference in New Issue
Block a user