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
This commit is contained in:
dt
2009-04-28 12:43:04 +02:00
parent 1c722840fb
commit 2b302332b8
30 changed files with 366 additions and 312 deletions

View File

@@ -33,7 +33,7 @@
#include "cmakeprojectconstants.h"
#include <projectexplorer/environment.h>
#include <projectexplorer/qtversionmanager.h>
#include <projectexplorer/debugginghelper.h>
#include <utils/qtcassert.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>

View File

@@ -0,0 +1,223 @@
/**************************************************************************
**
** 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;
}

View File

@@ -0,0 +1,64 @@
/**************************************************************************
**
** 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

View File

@@ -56,8 +56,6 @@
#include "session.h"
#include "sessiondialog.h"
#include "buildparserfactory.h"
#include "qtversionmanager.h"
#include "qtoptionspage.h"
#include <coreplugin/basemode.h>
#include <coreplugin/coreconstants.h>
@@ -196,11 +194,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(m_buildManager, SIGNAL(tasksChanged()),
this, SLOT(updateTaskActions()));
m_versionManager = new QtVersionManager();
addAutoReleasedObject(m_versionManager);
addAutoReleasedObject(new QtOptionsPage());
addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager));
m_outputPane = new OutputPane;
@@ -1867,7 +1860,7 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
}
}
}
m_openWithMenu->setEnabled(anyMatches);
m_openWithMenu->setEnabled(anyMatches);
}
void ProjectExplorerPlugin::openWithMenuTriggered(QAction *action)
@@ -1912,9 +1905,4 @@ void ProjectExplorerPlugin::setSession(QAction *action)
m_session->loadSession(session);
}
QtVersionManager *ProjectExplorerPlugin::qtVersionManager() const
{
return m_versionManager;
}
Q_EXPORT_PLUGIN(ProjectExplorerPlugin)

View File

@@ -64,7 +64,6 @@ class RunConfiguration;
class RunControl;
class SessionManager;
class IRunConfigurationRunner;
class QtVersionManager;
namespace Internal {
class ApplicationOutput;
@@ -105,8 +104,6 @@ public:
void showContextMenu(const QPoint &globalPos, Node *node);
QtVersionManager *qtVersionManager() const;
//PluginInterface
bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized();
@@ -249,7 +246,6 @@ private:
Node *m_currentNode;
BuildManager *m_buildManager;
QtVersionManager *m_versionManager;
QList<Internal::ProjectFileFactory*> m_fileFactories;
QStringList m_profileMimeTypes;

View File

@@ -59,8 +59,7 @@ HEADERS += projectexplorer.h \
gccparser.h \
msvcparser.h \
filewatcher.h \
qtversionmanager.h \
qtoptionspage.h
debugginghelper.h
SOURCES += projectexplorer.cpp \
projectwindow.cpp \
buildmanager.cpp \
@@ -108,8 +107,7 @@ SOURCES += projectexplorer.cpp \
gccparser.cpp \
msvcparser.cpp \
filewatcher.cpp \
qtversionmanager.cpp \
qtoptionspage.cpp
debugginghelper.cpp
FORMS += dependenciespanel.ui \
buildsettingspropertiespage.ui \
processstep.ui \
@@ -118,9 +116,7 @@ FORMS += dependenciespanel.ui \
sessiondialog.ui \
projectwizardpage.ui \
buildstepspage.ui \
removefiledialog.ui \
qtversionmanager.ui \
showbuildlog.ui
removefiledialog.ui
win32 {
SOURCES += applicationlauncher_win.cpp \
winguiprocess.cpp

View File

@@ -176,11 +176,6 @@ const char * const RESOURCE_MIMETYPE = "application/vnd.nokia.xml.qt.resource";
// build parsers
const char * const BUILD_PARSER_MSVC = "BuildParser.MSVC";
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 ProjectExplorer

View File

@@ -43,7 +43,6 @@
using ProjectExplorer::IBuildParserFactory;
using ProjectExplorer::BuildParserInterface;
using ProjectExplorer::Environment;
using ProjectExplorer::QtVersion;
using ExtensionSystem::PluginManager;
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;

View File

@@ -31,16 +31,15 @@
#define MAKESTEP_H
#include "ui_makestep.h"
#include "qtversionmanager.h"
#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/qtversionmanager.h>
namespace ProjectExplorer {
class BuildStep;
class IBuildStepFactory;
class Project;
class QtVersion;
}
namespace Qt4ProjectManager {
@@ -82,7 +81,7 @@ private slots:
void addDirectory(const QString &dir);
void removeDirectory(const QString &dir);
private:
ProjectExplorer::BuildParserInterface *buildParser(const ProjectExplorer::QtVersion *const version);
ProjectExplorer::BuildParserInterface *buildParser(const QtVersion *const version);
Qt4Project *m_project;
ProjectExplorer::BuildParserInterface *m_buildParser;
bool m_skipMakeClean;

View File

@@ -35,8 +35,6 @@
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::QtVersion;
ProFileReader::ProFileReader()
{
}

View File

@@ -31,7 +31,7 @@
#define PROFILEREADER_H
#include "profileevaluator.h"
#include <projectexplorer/qtversionmanager.h>
#include "qtversionmanager.h"
#include <QtCore/QObject>
#include <QtCore/QMap>
@@ -47,7 +47,7 @@ public:
ProFileReader();
~ProFileReader();
void setQtVersion(ProjectExplorer::QtVersion *qtVersion);
void setQtVersion(QtVersion *qtVersion);
bool readProFile(const QString &fileName);
QList<ProFile*> includeFiles() const;

View File

@@ -45,14 +45,12 @@
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::QtVersion;
ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags)
: 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 importVersion = ProjectExplorer::QtVersionManager::findQtVersionFromMakefile(directory);
QString importVersion = QtVersionManager::findQtVersionFromMakefile(directory);
if (!importVersion.isNull()) {
// This also means we have a build in there
@@ -65,7 +63,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
}
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
@@ -129,7 +127,7 @@ void ProjectLoadWizard::addBuildConfiguration(QString name, QtVersion *qtversion
void ProjectLoadWizard::done(int result)
{
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
QtVersionManager *vm = QtVersionManager::instance();
QWizard::done(result);
// This normally happens on showing the final page, but since we
// don't show it anymore, do it here

View File

@@ -30,7 +30,7 @@
#ifndef PROJECTLOADWIZARD_H
#define PROJECTLOADWIZARD_H
#include <projectexplorer/qtversionmanager.h>
#include "qtversionmanager.h"
#include <QtGui/QWizard>
@@ -57,14 +57,14 @@ public:
void execDialog();
private:
void addBuildConfiguration(QString name, ProjectExplorer::QtVersion *qtversion, ProjectExplorer::QtVersion::QmakeBuildConfig buildConfiguration);
void setupImportPage(ProjectExplorer::QtVersion *version, ProjectExplorer::QtVersion::QmakeBuildConfig buildConfig);
void addBuildConfiguration(QString name, QtVersion *qtversion, QtVersion::QmakeBuildConfig buildConfiguration);
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfig buildConfig);
Qt4Project *m_project;
// Only used for imported stuff
ProjectExplorer::QtVersion *m_importVersion;
ProjectExplorer::QtVersion::QmakeBuildConfig m_importBuildConfig;
QtVersion *m_importVersion;
QtVersion::QmakeBuildConfig m_importBuildConfig;
// Those that we might add
bool m_temporaryVersion;

View File

@@ -33,10 +33,10 @@
#include "qt4projectmanagerconstants.h"
#include "qt4projectmanager.h"
#include "makestep.h"
#include "qtversionmanager.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <projectexplorer/qtversionmanager.h>
#include <QFileDialog>
#include <QDir>

View File

@@ -64,7 +64,6 @@
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::QtVersion;
namespace {
bool debug = false;

View File

@@ -41,6 +41,7 @@
#include "qt4buildenvironmentwidget.h"
#include "qt4projectmanagerconstants.h"
#include "projectloadwizard.h"
#include "qtversionmanager.h"
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
@@ -50,7 +51,6 @@
#include <projectexplorer/nodesvisitor.h>
#include <projectexplorer/project.h>
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/qtversionmanager.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -236,7 +236,7 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
{
m_manager->registerProject(this);
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
QtVersionManager *vm = QtVersionManager::instance();
connect(vm, SIGNAL(defaultQtVersionChanged()),
this, SLOT(defaultQtVersionChanged()));

View File

@@ -33,12 +33,12 @@
#include "qt4nodes.h"
#include "qmakestep.h"
#include "makestep.h"
#include "qtversionmanager.h"
#include <coreplugin/ifile.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/qtversionmanager.h>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -148,7 +148,7 @@ public:
//returns the qtVersion, if the project is set to use the default qt version, then
// that is returned
// to check wheter the project uses the default qt version use qtVersionId
ProjectExplorer::QtVersion *qtVersion(const QString &buildConfiguration) const;
QtVersion *qtVersion(const QString &buildConfiguration) const;
// returns the id of the qt version, if the project is using the default qt version
// this function returns 0

View File

@@ -43,9 +43,6 @@
#include <QtGui/QFileDialog>
using ProjectExplorer::QtVersionManager;
using ProjectExplorer::QtVersion;
namespace {
bool debug = false;
}
@@ -84,7 +81,7 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()),
this, SLOT(manageQtVersions()));
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
QtVersionManager *vm = QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged()),
this, SLOT(setupQtVersionsComboBox()));
@@ -98,7 +95,7 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget()
void Qt4ProjectConfigWidget::manageQtVersions()
{
Core::ICore *core = Core::ICore::instance();
core->showOptionsDialog(ProjectExplorer::Constants::QT_CATEGORY, ProjectExplorer::Constants::QTVERSION_PAGE);
core->showOptionsDialog(Constants::QT_CATEGORY, Constants::QTVERSION_PAGE);
}
@@ -184,7 +181,7 @@ void Qt4ProjectConfigWidget::updateImportLabel()
{
m_ui->importLabel->setVisible(false);
if (m_ui->shadowBuildCheckBox->isChecked()) {
QString qtPath = ProjectExplorer::QtVersionManager::findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
QString qtPath = QtVersionManager::findQtVersionFromMakefile(m_ui->shadowBuildDirEdit->path());
if (!qtPath.isEmpty()) {
m_ui->importLabel->setVisible(true);
}
@@ -268,7 +265,7 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString
} else {
newQtVersion = m_ui->qtVersionComboBox->itemData(m_ui->qtVersionComboBox->currentIndex()).toInt();
}
ProjectExplorer::QtVersionManager *vm = ProjectExplorer::QtVersionManager::instance();
QtVersionManager *vm = QtVersionManager::instance();
bool isValid = vm->version(newQtVersion)->isValid();
m_ui->invalidQtWarningLabel->setVisible(!isValid);
if (newQtVersion != m_pro->qtVersionId(m_buildConfiguration)) {

View File

@@ -46,7 +46,6 @@
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/qtversionmanager.h>
#include <utils/listutils.h>
#include <QtCore/QCoreApplication>
@@ -68,8 +67,6 @@ using ProjectExplorer::SourceType;
using ProjectExplorer::FormType;
using ProjectExplorer::ResourceType;
using ProjectExplorer::UnknownFileType;
using ProjectExplorer::QtVersion;
using ProjectExplorer::QtVersionManager;
// Known file types of a Qt 4 project
static const char* qt4FileTypes[] = {

View File

@@ -32,7 +32,9 @@ HEADERS = qt4projectmanagerplugin.h \
speinfo.h \
qt4projectconfigwidget.h \
qt4buildenvironmentwidget.h \
projectloadwizard.h
projectloadwizard.h\
qtversionmanager.h\
qtoptionspage.h
SOURCES = qt4projectmanagerplugin.cpp \
qt4projectmanager.cpp \
qt4project.cpp \
@@ -60,7 +62,9 @@ SOURCES = qt4projectmanagerplugin.cpp \
speinfo.cpp \
qt4projectconfigwidget.cpp \
qt4buildenvironmentwidget.cpp \
projectloadwizard.cpp
projectloadwizard.cpp\
qtversionmanager.cpp\
qtoptionspage.cpp
FORMS = envvariablespage.ui \
enveditdialog.ui \
proeditorcontainer.ui \
@@ -68,7 +72,9 @@ FORMS = envvariablespage.ui \
qmakestep.ui \
qt4projectconfigwidget.ui \
embeddedpropertiespage.ui \
qt4buildenvironmentwidget.ui
qt4buildenvironmentwidget.ui \
qtversionmanager.ui\
showbuildlog.ui
RESOURCES = qt4projectmanager.qrc \
wizards/wizards.qrc
include(../../shared/proparser/proparser.pri)

View File

@@ -73,6 +73,11 @@ const char * const DEPLOYHELPERRUNSTEP = "trolltech.qt4projectmanager.deployhelp
const char * const VIEW_DETAILED = "Qt4.View.Detailed";
const char * const VIEW_PROFILESONLY = "Qt4.View.ProjectHierarchy";
//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 Qt4ProjectManager

View File

@@ -39,6 +39,8 @@
#include "embeddedpropertiespage.h"
#include "qt4runconfiguration.h"
#include "profilereader.h"
#include "qtversionmanager.h"
#include "qtoptionspage.h"
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
@@ -47,7 +49,6 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/qtversionmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -64,7 +65,6 @@
using namespace Qt4ProjectManager::Internal;
using namespace Qt4ProjectManager;
using ProjectExplorer::Project;
using ProjectExplorer::QtVersionManager;
Qt4ProjectManagerPlugin::~Qt4ProjectManagerPlugin()
{
@@ -97,9 +97,14 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
return false;
m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
Core::ActionManager *am = core->actionManager();
QtVersionManager::m_self = new QtVersionManager();
addAutoReleasedObject(QtVersionManager::m_self);
addAutoReleasedObject(new QtOptionsPage());
//create and register objects
m_qt4ProjectManager = new Qt4Manager(this);
addObject(m_qt4ProjectManager);

View File

@@ -33,13 +33,10 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
namespace ProjectExplorer {
class QtVersionManager;
}
namespace Qt4ProjectManager {
class Qt4Manager;
class QtVersionManager;
namespace Internal {

View File

@@ -51,7 +51,6 @@ using namespace Qt4ProjectManager;
using ProjectExplorer::ApplicationRunConfiguration;
using ProjectExplorer::PersistentSettingsReader;
using ProjectExplorer::PersistentSettingsWriter;
using ProjectExplorer::QtVersion;
Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFilePath)
: ApplicationRunConfiguration(pro),

View File

@@ -1,14 +1,14 @@
#include "qtoptionspage.h"
#include "ui_showbuildlog.h"
#include "ui_qtversionmanager.h"
#include "projectexplorerconstants.h"
#include "qt4projectmanagerconstants.h"
#include "qtversionmanager.h"
#include <coreplugin/coreconstants.h>
#include <QtCore/QDir>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
///
// QtOptionsPage
///

View File

@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
class QTreeWidgetItem;
QT_END_NAMESPACE
namespace ProjectExplorer {
namespace Qt4ProjectManager {
class QtVersion;
@@ -101,7 +101,7 @@ private:
};
} //namespace Internal
} //namespace ProjectExplorer
} //namespace Qt4ProjectManager
#endif // QTOPTIONSPAGE_H

View File

@@ -29,11 +29,11 @@
#include "qtversionmanager.h"
#include "projectexplorerconstants.h"
#include "cesdkhandler.h"
#include "projectexplorer.h"
#include "qt4projectmanagerconstants.h"
#include <projectexplorer/debugginghelper.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/cesdkhandler.h>
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <help/helpplugin.h>
@@ -45,14 +45,16 @@
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
using ProjectExplorer::DebuggingHelperLibrary;
static const char *QtVersionsSectionName = "QtVersions";
static const char *defaultQtVersionKey = "DefaultQtVersion";
static const char *newQtVersionsKey = "NewQtVersions";
QtVersionManager *QtVersionManager::m_self = 0;
QtVersionManager::QtVersionManager()
: m_emptyVersion(new QtVersion)
@@ -102,7 +104,7 @@ QtVersionManager::~QtVersionManager()
QtVersionManager *QtVersionManager::instance()
{
return ProjectExplorerPlugin::instance()->qtVersionManager();
return m_self;
}
void QtVersionManager::addVersion(QtVersion *version)
@@ -230,7 +232,7 @@ void QtVersionManager::addNewVersionsFromInstaller()
void QtVersionManager::updateSystemVersion()
{
bool haveSystemVersion = false;
QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(Environment::systemEnvironment());
QString systemQMakePath = DebuggingHelperLibrary::findSystemQt(ProjectExplorer::Environment::systemEnvironment());
QString systemQtPath;
if (systemQMakePath.isNull()) {
systemQtPath = tr("<not found>");
@@ -259,18 +261,6 @@ void QtVersionManager::updateSystemVersion()
++m_defaultVersion;
}
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;
}
QtVersion *QtVersionManager::currentQtVersion() const
{
if (m_defaultVersion < m_versions.count())
@@ -809,7 +799,7 @@ void QtVersion::setMsvcVersion(const QString &version)
m_msvcVersion = version;
}
void QtVersion::addToEnvironment(Environment &env)
void QtVersion::addToEnvironment(ProjectExplorer::Environment &env)
{
env.set("QTDIR", m_path);
QString qtdirbin = versionInfo().value("QT_INSTALL_BINS");
@@ -901,178 +891,3 @@ QString QtVersion::buildDebuggingHelperLibrary()
return output;
}
///
// Helper functions for building, checking for existance and finding the debugging helper library
///
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();
}

View File

@@ -30,20 +30,20 @@
#ifndef QTVERSIONMANAGER_H
#define QTVERSIONMANAGER_H
#include "environment.h"
#include "toolchain.h"
#include "projectexplorer_export.h"
#include <projectexplorer/environment.h>
#include <projectexplorer/toolchain.h>
#include <QtCore/QHash>
namespace ProjectExplorer {
namespace Qt4ProjectManager {
namespace Internal {
class QtOptionsPageWidget;
class QtOptionsPage;
class Qt4ProjectManagerPlugin;
}
class PROJECTEXPLORER_EXPORT QtVersion
class QtVersion
{
friend class Internal::QtOptionsPageWidget; //for changing name and path
friend class QtVersionManager;
@@ -124,8 +124,9 @@ private:
bool m_hasDebuggingHelper;
};
class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject
class QtVersionManager : public QObject
{
friend class Internal::Qt4ProjectManagerPlugin;
Q_OBJECT
// for getUniqueId();
friend class QtVersion;
@@ -168,33 +169,10 @@ private:
QList<QtVersion *> m_versions;
QMap<int, int> m_uniqueIdToIndex;
int m_idcount;
// managed by QtProjectManagerPlugin
static QtVersionManager *m_self;
};
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);
};
} // namespace ProjectExplorer
} // namespace Qt4ProjectManager
#endif // QTVERSIONMANAGER_H

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectExplorer::Internal::QtVersionManager</class>
<widget class="QWidget" name="ProjectExplorer::Internal::QtVersionManager">
<class>Qt4ProjectManager::Internal::QtVersionManager</class>
<widget class="QWidget" name="Qt4ProjectManager::Internal::QtVersionManager">
<property name="geometry">
<rect>
<x>0</x>