diff options
author | dt <[email protected]> | 2009-04-24 14:59:47 +0200 |
---|---|---|
committer | dt <[email protected]> | 2009-04-24 14:59:47 +0200 |
commit | b419403b0fe7508e9191a43de2f35e2146372d7e (patch) | |
tree | d515ce782fc3fcc09d0e22098bc07566a8512bc8 /src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | |
parent | 55cc9fed5c93aa9a0105312b112db8c611d5c40f (diff) |
Refactoring: Use one common code to find the debugging helper library
Remove duplicated code from cmakeprojectmanager.
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp | 76 |
1 files changed, 1 insertions, 75 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 9e85318461f..f4026c6aaa5 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -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 |