Commit 2b302332 authored by dt's avatar dt
Browse files

Move QtVersionManager, QtVersion and QtOptionsPage back

After all I don't need all that stuff in the cmakeplugin, all i needed
is now bundled in debugginghelper.h/cpp
parent 1c722840
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "cmakeprojectconstants.h" #include "cmakeprojectconstants.h"
#include <projectexplorer/environment.h> #include <projectexplorer/environment.h>
#include <projectexplorer/qtversionmanager.h> #include <projectexplorer/debugginghelper.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtGui/QFormLayout> #include <QtGui/QFormLayout>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "debugginghelper.h"
#include <coreplugin/icore.h>
#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include <QtCore/QProcess>
#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
using namespace ProjectExplorer;
QString DebuggingHelperLibrary::findSystemQt(const Environment &env)
{
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()) {
return qmake.absoluteFilePath();
}
}
}
}
return QString::null;
}
bool DebuggingHelperLibrary::hasDebuggingHelperLibrary(const QString &qmakePath)
{
return !debuggingHelperLibrary(qmakePath).isNull();
}
QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath)
{
uint hash = qHash(qtpath);
QStringList directories;
directories
<< (qtInstallData + "/qtc-debugging-helper/")
<< (QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash)) + "/"
<< (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash)) + "/";
return directories;
}
QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qmakePath)
{
return debuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath));
}
QString DebuggingHelperLibrary::qtInstallDataDir(const QString &qmakePath)
{
QProcess proc;
proc.start(qmakePath, QStringList() << "-query"<< "QT_INSTALL_DATA");
if (proc.waitForFinished())
return QString(proc.readAll().trimmed());
return QString::null;
}
QString DebuggingHelperLibrary::qtDir(const QString &qmakePath)
{
QDir dir = QFileInfo(qmakePath).absoluteDir();
dir.cdUp();
return dir.absolutePath();
}
// Debugging Helper Library
QString DebuggingHelperLibrary::debuggingHelperLibrary(const QString &qtInstallData, const QString &qtpath)
{
foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData, qtpath)) {
#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())
return fi.filePath();
}
return QString();
}
QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env)
{
QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), qtDir(qmakePath));
return buildDebuggingHelperLibrary(directory, make, qmakePath, QString::null, env);
return QString::null;
}
QString DebuggingHelperLibrary::copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir)
{
// Locations to try:
// $QTDIR/qtc-debugging-helper
// $APPLICATION-DIR/qtc-debugging-helper/$hash
// $USERDIR/qtc-debugging-helper/$hash
QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData, qtdir);
QStringList files;
files << "gdbmacros.cpp" << "gdbmacros.pro"
<< "LICENSE.LGPL" << "LGPL_EXCEPTION.TXT";
foreach(const QString &directory, directories) {
QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/";
bool success = true;
QDir().mkpath(directory);
foreach (const QString &file, files) {
QString source = dumperPath + file;
QString dest = directory + file;
QFileInfo destInfo(dest);
if (destInfo.exists()) {
if (destInfo.lastModified() >= QFileInfo(source).lastModified())
continue;
success &= QFile::remove(dest);
}
success &= QFile::copy(source, dest);
}
if (success)
return directory;
}
return QString::null;
}
QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env)
{
QString output;
// Setup process
QProcess proc;
proc.setEnvironment(env.toStringList());
proc.setWorkingDirectory(directory);
proc.setProcessChannelMode(QProcess::MergedChannels);
output += QString("Building debugging helper library in %1\n").arg(directory);
output += "\n";
QString makeFullPath = env.searchInPath(makeCommand);
if (!makeFullPath.isEmpty()) {
output += QString("Running %1 clean...\n").arg(makeFullPath);
proc.start(makeFullPath, QStringList() << "clean");
proc.waitForFinished();
output += proc.readAll();
} else {
output += QString("%1 not found in PATH\n").arg(makeCommand);
return output;
}
output += QString("\nRunning %1 ...\n").arg(qmakeCommand);
proc.start(qmakeCommand, QStringList()<<"-spec"<< (mkspec.isEmpty() ? "default" : mkspec) <<"gdbmacros.pro");
proc.waitForFinished();
output += proc.readAll();
output += "\n";
if (!makeFullPath.isEmpty()) {
output += QString("Running %1 ...\n").arg(makeFullPath);
proc.start(makeFullPath, QStringList());
proc.waitForFinished();
output += proc.readAll();
} else {
output += QString("%1 not found in PATH\n").arg(makeCommand);
}
return output;
}
QString DebuggingHelperLibrary::qtVersionForQMake(const QString &qmakePath)
{
QProcess qmake;
qmake.start(qmakePath, QStringList()<<"--version");
if (!qmake.waitForFinished())
return false;
QString output = qmake.readAllStandardOutput();
QRegExp regexp("(QMake version|QMake version:)[\\s]*([\\d.]*)", Qt::CaseInsensitive);
regexp.indexIn(output);
if (regexp.cap(2).startsWith("2.")) {
QRegExp regexp2("Using Qt version[\\s]*([\\d\\.]*)", Qt::CaseInsensitive);
regexp2.indexIn(output);
return regexp2.cap(1);
}
return QString();
}
QStringList DebuggingHelperLibrary::possibleQMakeCommands()
{
// On windows noone has renamed qmake, right?
#ifdef Q_OS_WIN
return QStringList() << "qmake.exe";
#endif
// On unix some distributions renamed qmake to avoid clashes
QStringList result;
result << "qmake-qt4" << "qmake4" << "qmake";
return result;
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef DEBUGGINGHELPER_H
#define DEBUGGINGHELPER_H
#include "environment.h"
#include "projectexplorer_export.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT DebuggingHelperLibrary
{
public:
// 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);
// returns something like qmake4, qmake, qmake-qt4 or whatever distributions have chosen (used by QtVersion)
static QStringList possibleQMakeCommands();
// return true if the qmake at qmakePath is qt4 (used by QtVersion)
static QString qtVersionForQMake(const QString &qmakePath);
static bool hasDebuggingHelperLibrary(const QString &qmakePath);
static QString debuggingHelperLibrary(const QString &qmakePath);
static QString buildDebuggingHelperLibrary(const QString &qmakePath, const QString &make, const Environment &env);
static QString debuggingHelperLibrary(const QString &qtInstallData, const QString &qtpath);
static QString copyDebuggingHelperLibrary(const QString &qtInstallData, const QString &qtdir);
static QString buildDebuggingHelperLibrary(const QString &directory, const QString &makeCommand, const QString &qmakeCommand, const QString &mkspec, const Environment &env);
private:
static QStringList debuggingHelperLibraryDirectories(const QString &qtInstallData, const QString &qtpath);
static QString qtInstallDataDir(const QString &qmakePath);
static QString qtDir(const QString &qmakePath);
};
}
#endif // DEBUGGINGHELPER_H
...@@ -56,8 +56,6 @@ ...@@ -56,8 +56,6 @@
#include "session.h" #include "session.h"
#include "sessiondialog.h" #include "sessiondialog.h"
#include "buildparserfactory.h" #include "buildparserfactory.h"
#include "qtversionmanager.h"
#include "qtoptionspage.h"
#include <coreplugin/basemode.h> #include <coreplugin/basemode.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
...@@ -196,11 +194,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -196,11 +194,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(m_buildManager, SIGNAL(tasksChanged()), connect(m_buildManager, SIGNAL(tasksChanged()),
this, SLOT(updateTaskActions())); this, SLOT(updateTaskActions()));
m_versionManager = new QtVersionManager();
addAutoReleasedObject(m_versionManager);
addAutoReleasedObject(new QtOptionsPage());
addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager));
m_outputPane = new OutputPane; m_outputPane = new OutputPane;
...@@ -1912,9 +1905,4 @@ void ProjectExplorerPlugin::setSession(QAction *action) ...@@ -1912,9 +1905,4 @@ void ProjectExplorerPlugin::setSession(QAction *action)
m_session->loadSession(session); m_session->loadSession(session);
} }
QtVersionManager *ProjectExplorerPlugin::qtVersionManager() const
{
return m_versionManager;
}
Q_EXPORT_PLUGIN(ProjectExplorerPlugin) Q_EXPORT_PLUGIN(ProjectExplorerPlugin)
...@@ -64,7 +64,6 @@ class RunConfiguration; ...@@ -64,7 +64,6 @@ class RunConfiguration;
class RunControl; class RunControl;
class SessionManager; class SessionManager;
class IRunConfigurationRunner; class IRunConfigurationRunner;
class QtVersionManager;
namespace Internal { namespace Internal {
class ApplicationOutput; class ApplicationOutput;
...@@ -105,8 +104,6 @@ public: ...@@ -105,8 +104,6 @@ public:
void showContextMenu(const QPoint &globalPos, Node *node); void showContextMenu(const QPoint &globalPos, Node *node);
QtVersionManager *qtVersionManager() const;
//PluginInterface //PluginInterface
bool initialize(const QStringList &arguments, QString *error_message); bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized(); void extensionsInitialized();
...@@ -249,7 +246,6 @@ private: ...@@ -249,7 +246,6 @@ private:
Node *m_currentNode; Node *m_currentNode;
BuildManager *m_buildManager; BuildManager *m_buildManager;
QtVersionManager *m_versionManager;
QList<Internal::ProjectFileFactory*> m_fileFactories; QList<Internal::ProjectFileFactory*> m_fileFactories;
QStringList m_profileMimeTypes; QStringList m_profileMimeTypes;
......
...@@ -59,8 +59,7 @@ HEADERS += projectexplorer.h \ ...@@ -59,8 +59,7 @@ HEADERS += projectexplorer.h \
gccparser.h \ gccparser.h \
msvcparser.h \ msvcparser.h \
filewatcher.h \ filewatcher.h \
qtversionmanager.h \ debugginghelper.h
qtoptionspage.h
SOURCES += projectexplorer.cpp \ SOURCES += projectexplorer.cpp \
projectwindow.cpp \ projectwindow.cpp \
buildmanager.cpp \ buildmanager.cpp \
...@@ -108,8 +107,7 @@ SOURCES += projectexplorer.cpp \ ...@@ -108,8 +107,7 @@ SOURCES += projectexplorer.cpp \
gccparser.cpp \ gccparser.cpp \
msvcparser.cpp \ msvcparser.cpp \
filewatcher.cpp \ filewatcher.cpp \
qtversionmanager.cpp \ debugginghelper.cpp
qtoptionspage.cpp
FORMS += dependenciespanel.ui \ FORMS += dependenciespanel.ui \
buildsettingspropertiespage.ui \ buildsettingspropertiespage.ui \
processstep.ui \ processstep.ui \
...@@ -118,9 +116,7 @@ FORMS += dependenciespanel.ui \ ...@@ -118,9 +116,7 @@ FORMS += dependenciespanel.ui \
sessiondialog.ui \ sessiondialog.ui \
projectwizardpage.ui \ projectwizardpage.ui \
buildstepspage.ui \ buildstepspage.ui \
removefiledialog.ui \ removefiledialog.ui
qtversionmanager.ui \
showbuildlog.ui
win32 { win32 {
SOURCES += applicationlauncher_win.cpp \ SOURCES += applicationlauncher_win.cpp \
winguiprocess.cpp winguiprocess.cpp
......
...@@ -176,11 +176,6 @@ const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource"; ...@@ -176,11 +176,6 @@ const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource";
// build parsers // build parsers
const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC"; const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC";
const char * const BUILD_PARSER_GCC = "BuildParser.Gcc"; const char * const BUILD_PARSER_GCC = "BuildParser.Gcc";
//Qt4 settings pages
const char * const QT_CATEGORY = "Qt4";
const char * const QTVERSION_PAGE = "Qt Versions";
const char * const BUILD_ENVIRONMENT_PAGE = "Build Environments";
} // namespace Constants } // namespace Constants
} // namespace ProjectExplorer } // namespace ProjectExplorer
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
using ProjectExplorer::IBuildParserFactory; using ProjectExplorer::IBuildParserFactory;
using ProjectExplorer::BuildParserInterface; using ProjectExplorer::BuildParserInterface;
using ProjectExplorer::Environment; using ProjectExplorer::Environment;
using ProjectExplorer::QtVersion;
using ExtensionSystem::PluginManager; using ExtensionSystem::PluginManager;
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
......
...@@ -31,16 +31,15 @@ ...@@ -31,16 +31,15 @@
#define MAKESTEP_H #define MAKESTEP_H
#include "ui_makestep.h" #include "ui_makestep.h"
#include "qtversionmanager.h"
#include <projectexplorer/abstractprocessstep.h> #include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/qtversionmanager.h>
namespace ProjectExplorer { namespace ProjectExplorer {
class BuildStep; class BuildStep;
class IBuildStepFactory; class IBuildStepFactory;
class Project; class Project;
class QtVersion;
} }
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
...@@ -82,7 +81,7 @@ private slots: ...@@ -82,7 +81,7 @@ private slots:
void addDirectory(const QString &dir); void addDirectory(const QString &dir);
void removeDirectory(const QString &dir); void removeDirectory(const QString &dir);
private: private:
ProjectExplorer::BuildParserInterface *buildParser(const ProjectExplorer::QtVersion *const version); ProjectExplorer::BuildParserInterface *buildParser(const QtVersion *const version);
Qt4Project *m_project; Qt4Project *m_project;
ProjectExplorer::BuildParserInterface *m_buildParser; ProjectExplorer::BuildParserInterface *m_buildParser;
bool m_skipMakeClean; bool m_skipMakeClean;
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::QtVersion;
ProFileReader::ProFileReader() ProFileReader::ProFileReader()
{ {
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define PROFILEREADER_H #define PROFILEREADER_H
#include "profileevaluator.h" #include "profileevaluator.h"
#include <projectexplorer/qtversionmanager.h> #include "qtversionmanager.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QMap> #include <QtCore/QMap>
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
ProFileReader(); ProFileReader();
~ProFileReader(); ~ProFileReader();
void setQtVersion(ProjectExplorer::QtVersion *qtVersion); void setQtVersion(QtVersion *qtVersion);
bool readProFile(const QString &fileName); bool readProFile(const QString &fileName);
QList<ProFile*> includeFiles() const; QList<ProFile*> includeFiles() const;
......
...@@ -45,14 +45,12 @@ ...@@ -45,14 +45,12 @@
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::QtVersion;
ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags) ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags)
: QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false) : QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false)
{ {
ProjectExplorer::QtVersionManager * vm = ProjectExplorer::QtVersionManager::instance(); QtVersionManager * vm = QtVersionManager::instance();
QString directory = QFileInfo(project->file()->fileName()).absolutePath(); QString directory = QFileInfo(project->file()->fileName()).absolutePath();
QString importVersion = ProjectExplorer::QtVersionManager::findQtVersionFromMakefile(directory); QString importVersion = QtVersionManager::findQtVersionFromMakefile(directory);
if (!importVersion.isNull()) { if (!importVersion.isNull()) {
// This also means we have a build in there // This also means we have a build in there
...@@ -65,7 +63,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W ...@@ -65,7 +63,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
} }
m_importBuildConfig = m_importVersion->defaultBuildConfig(); m_importBuildConfig = m_importVersion->defaultBuildConfig();
m_importBuildConfig= ProjectExplorer::QtVersionManager::scanMakefileForQmakeConfig(directory, m_importBuildConfig); m_importBuildConfig= QtVersionManager::scanMakefileForQmakeConfig(directory, m_importBuildConfig);
} }
// So now we have the version and the configuration for that version // So now we have the version and the configuration for that version
...@@ -129,7 +127,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion ...@@ -129,7 +127,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion
void ProjectLoadWizard::done(int result) void ProjectLoadWizard::done(int result)
{ {
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance(); QtVersionManager *vm = QtVersionManager::instance();
QWizard::done(result); QWizard::done(result);
// This normally happens on showing the final page, but since we