Change the way the debugging library is build and found, yet again.

We used to build a helper library as part of the project. First with the
qmake -after SOURCES= stuff and after until now with the
gdbmacrosbuildstep. Now, the all new and fancy integretation directtly
into the qt version dialog. You build the debugger library once for
each qt version and then it's there ready to be loaded into each
project build against that qt version. Saves a lot of time.
And makes it possible to also load that library into while debuggign a
cmake project. (Need to hook that up now.)
Unfourtanetly this breaks the custom dumpers if you use a custom run
executable.
This commit is contained in:
dt
2009-03-25 15:18:37 +01:00
parent c964d64d34
commit e21a74cb35
18 changed files with 388 additions and 378 deletions

View File

@@ -123,6 +123,11 @@ QWidget *CMakeRunConfiguration::configurationWidget()
return new QWidget(); return new QWidget();
} }
QString CMakeRunConfiguration::dumperLibrary() const
{
return QString();
}
// Factory // Factory
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory() CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
{ {

View File

@@ -59,6 +59,7 @@ public:
virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const; virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader); virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);
virtual QString dumperLibrary() const;
private: private:
RunMode m_runMode; RunMode m_runMode;
QString m_target; QString m_target;

View File

@@ -132,8 +132,6 @@ void DebuggerRunControl::start()
project->buildDirectory(project->activeBuildConfiguration()); project->buildDirectory(project->activeBuildConfiguration());
m_manager->m_useTerminal = rc->runMode() == ApplicationRunConfiguration::Console; m_manager->m_useTerminal = rc->runMode() == ApplicationRunConfiguration::Console;
//<daniel> andre: + "\qtc-gdbmacros\"
//emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable)); //emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable));
if (m_manager->startNewDebugger(StartInternal)) if (m_manager->startNewDebugger(StartInternal))
emit started(); emit started();

View File

@@ -54,6 +54,7 @@ public:
virtual QString workingDirectory() const = 0; virtual QString workingDirectory() const = 0;
virtual QStringList commandLineArguments() const = 0; virtual QStringList commandLineArguments() const = 0;
virtual Environment environment() const = 0; virtual Environment environment() const = 0;
virtual QString dumperLibrary() const = 0;
virtual void save(PersistentSettingsWriter &writer) const; virtual void save(PersistentSettingsWriter &writer) const;
virtual void restore(const PersistentSettingsReader &reader); virtual void restore(const PersistentSettingsReader &reader);

View File

@@ -308,6 +308,13 @@ void CustomExecutableRunConfiguration::setUserName(const QString &name)
emit changed(); emit changed();
} }
QString CustomExecutableRunConfiguration::dumperLibrary() const
{
return QString();
}
// Factory // Factory
CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory() CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory()

View File

@@ -86,6 +86,7 @@ public:
virtual void restore(const PersistentSettingsReader &reader); virtual void restore(const PersistentSettingsReader &reader);
virtual QWidget *configurationWidget(); virtual QWidget *configurationWidget();
virtual QString dumperLibrary() const;
signals: signals:
void changed(); void changed();

View File

@@ -1,229 +0,0 @@
/**************************************************************************
**
** 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 "gdbmacrosbuildstep.h"
#include "makestep.h"
#include "qmakestep.h"
#include "qt4project.h"
#include "qt4projectmanagerconstants.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
GdbMacrosBuildStep::GdbMacrosBuildStep(Qt4Project *project)
: BuildStep(project), m_project(project)
{
}
GdbMacrosBuildStep::~GdbMacrosBuildStep()
{
}
bool GdbMacrosBuildStep::init(const QString &buildConfiguration)
{
m_buildDirectory = m_project->buildDirectory(buildConfiguration);
m_qmake = m_project->qtVersion(buildConfiguration)->qmakeCommand();
m_buildConfiguration = buildConfiguration;
return true;
}
void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi)
{
QStringList files;
files << "gdbmacros.cpp" << "gdbmacros.pro"
<< "LICENSE.LGPL" << "LGPL_EXCEPTION.TXT";
QVariant v = value("clean");
if (v.isNull() || v.toBool() == false) {
addToOutputWindow("<b>Creating gdb macros library...</b>");
// Normal run
QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/";
QString destDir = m_buildDirectory + "/qtc-gdbmacros/";
QDir dir;
dir.mkpath(destDir);
foreach (const QString &file, files) {
QString source = dumperPath + file;
QString dest = destDir + file;
QFileInfo destInfo(dest);
if (destInfo.exists()) {
if (destInfo.lastModified() >= QFileInfo(source).lastModified())
continue;
QFile::remove(dest);
}
QFile::copy(source, dest);
}
Qt4Project *qt4Project = static_cast<Qt4Project *>(project());
QProcess qmake;
qmake.setEnvironment(qt4Project->environment(m_buildConfiguration).toStringList());
qmake.setWorkingDirectory(destDir);
QStringList configarguments;
QStringList makeArguments;
// Find qmake step...
QMakeStep *qmakeStep = qt4Project->qmakeStep();
// Find out which configuration is used in this build configuration
// and what kind of CONFIG we need to pass to qmake for that
if (qmakeStep->value(m_buildConfiguration, "buildConfiguration").isValid()) {
QtVersion::QmakeBuildConfig defaultBuildConfiguration = qt4Project->qtVersion(m_buildConfiguration)->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration = QtVersion::QmakeBuildConfig(qmakeStep->value(m_buildConfiguration, "buildConfiguration").toInt());
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
configarguments << "CONFIG-=debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
configarguments << "CONFIG+=debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(projectBuildConfiguration & QtVersion::DebugBuild))
configarguments << "CONFIG+=release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (projectBuildConfiguration & QtVersion::DebugBuild))
configarguments << "CONFIG+=debug";
if (projectBuildConfiguration & QtVersion::BuildAll)
makeArguments << (projectBuildConfiguration & QtVersion::DebugBuild ? "debug" : "release");
} else {
// Old style with CONFIG+=debug_and_release
configarguments << "CONFIG+=debug_and_release";
const MakeStep *ms = qt4Project->makeStep();
QStringList makeargs = ms->value(m_buildConfiguration, "makeargs").toStringList();
if (makeargs.contains("debug")) {
makeArguments << "debug";
} else if (makeargs.contains("release")) {
makeArguments << "release";
}
}
QString mkspec = qt4Project->qtVersion(m_buildConfiguration)->mkspec();
qmake.start(m_qmake, QStringList()<<"-spec"<<mkspec<<configarguments<<"gdbmacros.pro");
qmake.waitForFinished();
QString makeCmd = qt4Project->makeCommand(m_buildConfiguration);
if (!value(m_buildConfiguration, "makeCmd").toString().isEmpty())
makeCmd = value(m_buildConfiguration, "makeCmd").toString();
if (!QFileInfo(makeCmd).isAbsolute()) {
// Try to detect command in environment
QString tmp = qt4Project->environment(m_buildConfiguration).searchInPath(makeCmd);
makeCmd = tmp;
}
qmake.start(makeCmd, makeArguments);
qmake.waitForFinished();
fi.reportResult(true);
} else {
// Clean step, we want to remove the directory
QString destDir = m_buildDirectory + "/qtc-gdbmacros/";
Qt4Project *qt4Project = static_cast<Qt4Project *>(project());
QProcess make;
make.setEnvironment(qt4Project->environment(m_buildConfiguration).toStringList());
make.setWorkingDirectory(destDir);
make.start(qt4Project->makeCommand(m_buildConfiguration), QStringList()<<"distclean");
make.waitForFinished();
QStringList directories;
directories << "debug"
<< "release";
foreach(const QString &file, files) {
QFile destination(destDir + file);
destination.remove();
}
foreach(const QString &dir, directories) {
QDir destination(destDir + dir);
destination.rmdir(destDir + dir);
}
QDir(destDir).rmdir(destDir);
fi.reportResult(true);
}
}
QString GdbMacrosBuildStep::name()
{
return Constants::GDBMACROSBUILDSTEP;
}
QString GdbMacrosBuildStep::displayName()
{
return "Gdb Macros Build";
}
ProjectExplorer::BuildStepConfigWidget *GdbMacrosBuildStep::createConfigWidget()
{
return new GdbMacrosBuildStepConfigWidget;
}
bool GdbMacrosBuildStep::immutable() const
{
return false;
}
bool GdbMacrosBuildStepFactory::canCreate(const QString &name) const
{
return name == Constants::GDBMACROSBUILDSTEP;
}
ProjectExplorer::BuildStep *GdbMacrosBuildStepFactory::create(ProjectExplorer::Project *pro, const QString &name) const
{
Q_ASSERT(name == Constants::GDBMACROSBUILDSTEP);
Qt4Project *qt4project = qobject_cast<Qt4Project *>(pro);
Q_ASSERT(qt4project);
return new GdbMacrosBuildStep(qt4project);
}
QStringList GdbMacrosBuildStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const
{
QStringList results;
if (qobject_cast<Qt4Project *>(pro))
results << Constants::GDBMACROSBUILDSTEP;
return results;
}
QString GdbMacrosBuildStepFactory::displayNameForName(const QString &name) const
{
if (name == Constants::GDBMACROSBUILDSTEP)
return "Gdb Macros Build";
else
return QString::null;
}
QString GdbMacrosBuildStepConfigWidget::displayName() const
{
return "Gdb Macros Build";
}
void GdbMacrosBuildStepConfigWidget::init(const QString & /*buildConfiguration*/)
{
// TODO
}

View File

@@ -1,79 +0,0 @@
/**************************************************************************
**
** 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 GDBMACROSBUILDSTEP_H
#define GDBMACROSBUILDSTEP_H
#include <projectexplorer/buildstep.h>
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class GdbMacrosBuildStepConfigWidget;
class GdbMacrosBuildStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
public:
GdbMacrosBuildStep(Qt4Project * project);
virtual ~GdbMacrosBuildStep();
virtual bool init(const QString &buildConfiguration);
virtual void run(QFutureInterface<bool> &);
virtual QString name();
virtual QString displayName();
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
virtual bool immutable() const;
private:
Qt4Project *m_project;
QString m_buildDirectory;
QString m_qmake;
QString m_buildConfiguration;
};
class GdbMacrosBuildStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
virtual bool canCreate(const QString &name) const;
virtual ProjectExplorer::BuildStep *create(ProjectExplorer::Project *pro, const QString &name) const;
virtual QStringList canCreateForProject(ProjectExplorer::Project *pro) const;
virtual QString displayNameForName(const QString &name) const;
};
class GdbMacrosBuildStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
virtual QString displayName() const;
virtual void init(const QString &buildConfiguration);
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // GDBMACROSBUILDSTEP_H

View File

@@ -42,7 +42,6 @@
#include "qt4buildenvironmentwidget.h" #include "qt4buildenvironmentwidget.h"
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include "projectloadwizard.h" #include "projectloadwizard.h"
#include "gdbmacrosbuildstep.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
@@ -656,10 +655,6 @@ void Qt4Project::addDefaultBuild()
//TODO have a better check wheter there is already a configuration? //TODO have a better check wheter there is already a configuration?
QMakeStep *qmakeStep = 0; QMakeStep *qmakeStep = 0;
MakeStep *makeStep = 0; MakeStep *makeStep = 0;
GdbMacrosBuildStep *gdbmacrostep;
gdbmacrostep = new GdbMacrosBuildStep(this);
insertBuildStep(0, gdbmacrostep);
qmakeStep = new QMakeStep(this); qmakeStep = new QMakeStep(this);
qmakeStep->setValue("mkspec", ""); qmakeStep->setValue("mkspec", "");
@@ -668,10 +663,6 @@ void Qt4Project::addDefaultBuild()
makeStep = new MakeStep(this); makeStep = new MakeStep(this);
insertBuildStep(2, makeStep); insertBuildStep(2, makeStep);
GdbMacrosBuildStep *gdbmacrosCleanStep = new GdbMacrosBuildStep(this);
gdbmacrosCleanStep->setValue("clean", true);
insertCleanStep(0, gdbmacrosCleanStep);
MakeStep* cleanStep = new MakeStep(this); MakeStep* cleanStep = new MakeStep(this);
cleanStep->setValue("clean", true); cleanStep->setValue("clean", true);
insertCleanStep(1, cleanStep); insertCleanStep(1, cleanStep);
@@ -680,25 +671,6 @@ void Qt4Project::addDefaultBuild()
wizard.execDialog(); wizard.execDialog();
} else { } else {
// Restoring configuration // Restoring configuration
// Do we already have a gdbmacrobuildstep?
// If not add it and disable linking of debugging helper
// Check for old link debugging helper setting in each buildConfiguration
// We add a gdbmacrosbuildstep if at least one has it
// TODO remove migration code from pre beta
foreach(const QString &bc, buildConfigurations()) {
QVariant v = value(bc, "addQDumper");
if (v.isValid() && v.toBool()) {
GdbMacrosBuildStep *gdbmacrostep = new GdbMacrosBuildStep(this);
insertBuildStep(0, gdbmacrostep);
GdbMacrosBuildStep *gdbmacrosCleanStep = new GdbMacrosBuildStep(this);
gdbmacrosCleanStep->setValue("clean", true);
insertCleanStep(0, gdbmacrosCleanStep );
break;
}
}
foreach(const QString &bc, buildConfigurations()) { foreach(const QString &bc, buildConfigurations()) {
setValue(bc, "addQDumper", QVariant()); setValue(bc, "addQDumper", QVariant());
} }

View File

@@ -35,8 +35,7 @@ HEADERS = qt4projectmanagerplugin.h \
qt4buildconfigwidget.h \ qt4buildconfigwidget.h \
qt4buildenvironmentwidget.h \ qt4buildenvironmentwidget.h \
projectloadwizard.h \ projectloadwizard.h \
directorywatcher.h \ directorywatcher.h
gdbmacrosbuildstep.h
SOURCES = qt4projectmanagerplugin.cpp \ SOURCES = qt4projectmanagerplugin.cpp \
qt4projectmanager.cpp \ qt4projectmanager.cpp \
qtversionmanager.cpp \ qtversionmanager.cpp \
@@ -67,8 +66,7 @@ SOURCES = qt4projectmanagerplugin.cpp \
qt4buildconfigwidget.cpp \ qt4buildconfigwidget.cpp \
qt4buildenvironmentwidget.cpp \ qt4buildenvironmentwidget.cpp \
projectloadwizard.cpp \ projectloadwizard.cpp \
directorywatcher.cpp \ directorywatcher.cpp
gdbmacrosbuildstep.cpp
FORMS = qtversionmanager.ui \ FORMS = qtversionmanager.ui \
envvariablespage.ui \ envvariablespage.ui \
enveditdialog.ui \ enveditdialog.ui \
@@ -77,7 +75,8 @@ FORMS = qtversionmanager.ui \
qmakestep.ui \ qmakestep.ui \
qt4buildconfigwidget.ui \ qt4buildconfigwidget.ui \
embeddedpropertiespage.ui \ embeddedpropertiespage.ui \
qt4buildenvironmentwidget.ui qt4buildenvironmentwidget.ui \
showbuildlog.ui
RESOURCES = qt4projectmanager.qrc \ RESOURCES = qt4projectmanager.qrc \
wizards/wizards.qrc wizards/wizards.qrc
include(../../shared/proparser/proparser.pri) include(../../shared/proparser/proparser.pri)

View File

@@ -71,7 +71,6 @@ const char * const GC_COMPILER = "Qt4.Compiler";
// qmakestep // qmakestep
const char * const QMAKESTEP = "trolltech.qt4projectmanager.qmake"; const char * const QMAKESTEP = "trolltech.qt4projectmanager.qmake";
const char * const MAKESTEP = "trolltech.qt4projectmanager.make"; const char * const MAKESTEP = "trolltech.qt4projectmanager.make";
const char * const GDBMACROSBUILDSTEP = "trolltech.qt4projectmanager.gdbmaros";
const char * const QT4RUNSTEP = "trolltech.qt4projectmanager.qt4runstep"; const char * const QT4RUNSTEP = "trolltech.qt4projectmanager.qt4runstep";
const char * const DEPLOYHELPERRUNSTEP = "trolltech.qt4projectmanager.deployhelperrunstep"; const char * const DEPLOYHELPERRUNSTEP = "trolltech.qt4projectmanager.deployhelperrunstep";

View File

@@ -41,7 +41,6 @@
#include "embeddedpropertiespage.h" #include "embeddedpropertiespage.h"
#include "qt4runconfiguration.h" #include "qt4runconfiguration.h"
#include "profilereader.h" #include "profilereader.h"
#include "gdbmacrosbuildstep.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
@@ -125,7 +124,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new QMakeBuildStepFactory); addAutoReleasedObject(new QMakeBuildStepFactory);
addAutoReleasedObject(new MakeBuildStepFactory); addAutoReleasedObject(new MakeBuildStepFactory);
addAutoReleasedObject(new GdbMacrosBuildStepFactory);
m_qtVersionManager = new QtVersionManager; m_qtVersionManager = new QtVersionManager;
addObject(m_qtVersionManager); addObject(m_qtVersionManager);

View File

@@ -370,6 +370,14 @@ void Qt4RunConfiguration::invalidateCachedTargetInformation()
emit effectiveTargetInformationChanged(); emit effectiveTargetInformationChanged();
} }
QString Qt4RunConfiguration::dumperLibrary() const
{
Qt4Project *pro = qobject_cast<Qt4Project *>(project());
QtVersion *version = pro->qtVersion(pro->activeBuildConfiguration());
return version->dumperLibrary();
}
/// ///
/// Qt4RunConfigurationFactory /// Qt4RunConfigurationFactory
/// This class is used to restore run settings (saved in .user files) /// This class is used to restore run settings (saved in .user files)

View File

@@ -70,6 +70,7 @@ public:
virtual QString workingDirectory() const; virtual QString workingDirectory() const;
virtual QStringList commandLineArguments() const; virtual QStringList commandLineArguments() const;
virtual ProjectExplorer::Environment environment() const; virtual ProjectExplorer::Environment environment() const;
virtual QString dumperLibrary() const;
QString proFilePath() const; QString proFilePath() const;

View File

@@ -30,6 +30,7 @@
#include "qtversionmanager.h" #include "qtversionmanager.h"
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include "ui_showbuildlog.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
@@ -48,6 +49,12 @@
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
#include <QtGui/QHeaderView> #include <QtGui/QHeaderView>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
@@ -57,6 +64,43 @@ static const char *QtVersionsSectionName = "QtVersions";
static const char *defaultQtVersionKey = "DefaultQtVersion"; static const char *defaultQtVersionKey = "DefaultQtVersion";
static const char *newQtVersionsKey = "NewQtVersions"; static const char *newQtVersionsKey = "NewQtVersions";
DebuggingHelperWidget::DebuggingHelperWidget()
{
setLayout(new QHBoxLayout());
m_statusLabel = new QLabel(this);
layout()->addWidget(m_statusLabel);
m_showLog = new QPushButton(this);
m_showLog->setText("Show Log");
layout()->addWidget(m_showLog);
m_rebuild = new QPushButton(this);
m_rebuild->setText("Rebuild");
layout()->addWidget(m_rebuild);
connect(m_showLog, SIGNAL(clicked()), this, SIGNAL(showLogClicked()));
connect(m_rebuild, SIGNAL(clicked()), this, SIGNAL(rebuildClicked()));
}
void DebuggingHelperWidget::setState(State s)
{
bool validQt = true;
if (s & InvalidQt)
validQt = false;
m_statusLabel->setVisible(validQt);
m_showLog->setVisible(validQt);
m_rebuild->setVisible(validQt);
if (!validQt)
return;
if (s & Error)
m_statusLabel->setPixmap(QPixmap(":/extensionsystem/images/error.png"));
else
m_statusLabel->setPixmap(QPixmap(":/extensionsystem/images/ok.png"));
m_showLog->setVisible(s & ShowLog);
}
QtVersionManager::QtVersionManager() QtVersionManager::QtVersionManager()
: m_emptyVersion(new QtVersion) : m_emptyVersion(new QtVersion)
{ {
@@ -370,7 +414,6 @@ QtVersion *QtVersionManager::currentQtVersion() const
} }
//----------------------------------------------------- //-----------------------------------------------------
QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion) QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion)
: QWidget(parent) : QWidget(parent)
, m_defaultVersion(defaultVersion) , m_defaultVersion(defaultVersion)
@@ -398,6 +441,17 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defau
item->setText(0, version->name()); item->setText(0, version->name());
item->setText(1, version->path()); item->setText(1, version->path());
item->setData(0, Qt::UserRole, version->uniqueId()); item->setData(0, Qt::UserRole, version->uniqueId());
DebuggingHelperWidget *dhw = new DebuggingHelperWidget();
m_ui.qtdirList->setItemWidget(item, 2, dhw);
if (version->hasDebuggingHelper())
dhw->setState(DebuggingHelperWidget::Ok);
else
dhw->setState(DebuggingHelperWidget::Error);
connect(dhw, SIGNAL(rebuildClicked()), this, SLOT(buildDebuggingHelper()));
connect(dhw, SIGNAL(showLogClicked()), this, SLOT(showDebuggingBuildLog()));
m_ui.defaultCombo->addItem(version->name()); m_ui.defaultCombo->addItem(version->name());
if (i == m_defaultVersion) if (i == m_defaultVersion)
m_ui.defaultCombo->setCurrentIndex(i); m_ui.defaultCombo->setCurrentIndex(i);
@@ -434,6 +488,51 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defau
updateState(); updateState();
} }
void QtDirWidget::buildDebuggingHelper()
{
// Find the qt version for this button..
int index = indexForWidget(qobject_cast<QWidget *>(sender());
if (index == -1)
return;
QString result = m_versions.at(index)->buildDebuggingHelperLibrary();
QTreeWidgetItem *item = m_ui.qtdirList->topLevelItem(index);
item->setData(2, Qt::UserRole, result);
DebuggingHelperWidget *dhw = qobject_cast<DebuggingHelperWidget *>(m_ui.qtdirList->itemWidget(item, 2));
if (dhw) {
if (m_versions.at(index)->hasDebuggingHelper())
dhw->setState(DebuggingHelperWidget::State(DebuggingHelperWidget::Ok | DebuggingHelperWidget::ShowLog));
else
dhw->setState(DebuggingHelperWidget::State(DebuggingHelperWidget::Error | DebuggingHelperWidget::ShowLog));
}
}
int QtDirWidget::indexFor(QWidget *debuggingHelperWidget) const
{
int index = -1;
for(int i=0; i < m_ui.qtdirList->topLevelItemCount(); ++i) {
if (m_ui.qtdirList->itemWidget(m_ui.qtdirList->topLevelItem(i), 2) == widget) {
index = i;
break;
}
}
return index;
}
void QtDirWidget::showDebuggingBuildLog()
{
int index = indexForWidget(qobject_cast<QWidget *>(sender());
if (index == -1)
return;
QDialog dlg;
::Ui::ShowBuildLog ui;
ui.setupUi(&dlg);
ui.log->setPlainText(m_ui.qtdirList->topLevelItem(index)->data(2, Qt::UserRole).toString());
dlg.exec();
}
QtDirWidget::~QtDirWidget() QtDirWidget::~QtDirWidget()
{ {
qDeleteAll(m_versions); qDeleteAll(m_versions);
@@ -449,6 +548,16 @@ void QtDirWidget::addQtDir()
item->setText(1, newVersion->path()); item->setText(1, newVersion->path());
item->setData(0, Qt::UserRole, newVersion->uniqueId()); item->setData(0, Qt::UserRole, newVersion->uniqueId());
DebuggingHelperWidget *dhw = new DebuggingHelperWidget();
m_ui.qtdirList->setItemWidget(item, 2, dhw);
if (newVersion->hasDebuggingHelper())
dhw->setState(DebuggingHelperWidget::Ok);
else
dhw->setState(DebuggingHelperWidget::Error);
connect(dhw, SIGNAL(rebuildClicked()), this, SLOT(buildDebuggingHelper()));
connect(dhw, SIGNAL(showLogClicked()), this, SLOT(showDebuggingBuildLog()));
m_ui.qtdirList->setItemWidget(item, 2, dhw);
m_ui.qtdirList->setCurrentItem(item); m_ui.qtdirList->setCurrentItem(item);
m_ui.nameEdit->setText(newVersion->name()); m_ui.nameEdit->setText(newVersion->name());
@@ -506,19 +615,14 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType();
if (t == ProjectExplorer::ToolChain::MinGW) { if (t == ProjectExplorer::ToolChain::MinGW) {
m_ui.msvcComboBox->setVisible(false); m_ui.msvcComboBox->setVisible(false);
m_ui.msvcLabel->setVisible(false);
makeMingwVisible(true); makeMingwVisible(true);
m_ui.mingwPath->setPath(m_versions.at(index)->mingwDirectory()); m_ui.mingwPath->setPath(m_versions.at(index)->mingwDirectory());
} else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){
m_ui.msvcComboBox->setVisible(false); m_ui.msvcComboBox->setVisible(false);
m_ui.msvcLabel->setVisible(true);
makeMingwVisible(false); makeMingwVisible(false);
QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions();
if (msvcEnvironments.count() == 0) { if (msvcEnvironments.count() == 0) {
m_ui.msvcLabel->setText(tr("No Visual Studio Installation found"));
} else if (msvcEnvironments.count() == 1) { } else if (msvcEnvironments.count() == 1) {
//TODO m_ui.msvcLabel->setText( msvcEnvironments.at(0).description());
m_ui.msvcLabel->setText("");
} else { } else {
m_ui.msvcComboBox->setVisible(true); m_ui.msvcComboBox->setVisible(true);
bool block = m_ui.msvcComboBox->blockSignals(true); bool block = m_ui.msvcComboBox->blockSignals(true);
@@ -527,14 +631,12 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
m_ui.msvcComboBox->addItem(msvcenv); m_ui.msvcComboBox->addItem(msvcenv);
if (msvcenv == m_versions.at(index)->msvcVersion()) { if (msvcenv == m_versions.at(index)->msvcVersion()) {
m_ui.msvcComboBox->setCurrentIndex(m_ui.msvcComboBox->count() - 1); m_ui.msvcComboBox->setCurrentIndex(m_ui.msvcComboBox->count() - 1);
m_ui.msvcLabel->setText(""); //TODO
} }
} }
m_ui.msvcComboBox->blockSignals(block); m_ui.msvcComboBox->blockSignals(block);
} }
} else if (t == ProjectExplorer::ToolChain::INVALID) { } else if (t == ProjectExplorer::ToolChain::INVALID) {
m_ui.msvcComboBox->setVisible(false); m_ui.msvcComboBox->setVisible(false);
m_ui.msvcLabel->setVisible(false);
makeMingwVisible(false); makeMingwVisible(false);
if (!m_versions.at(index)->isInstalled()) if (!m_versions.at(index)->isInstalled())
m_ui.errorLabel->setText(tr("The Qt Version is not installed. Run make install") m_ui.errorLabel->setText(tr("The Qt Version is not installed. Run make install")
@@ -543,7 +645,6 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
m_ui.errorLabel->setText(tr("%1 is not a valid qt directory").arg(m_versions.at(index)->path())); m_ui.errorLabel->setText(tr("%1 is not a valid qt directory").arg(m_versions.at(index)->path()));
} else { //ProjectExplorer::ToolChain::GCC } else { //ProjectExplorer::ToolChain::GCC
m_ui.msvcComboBox->setVisible(false); m_ui.msvcComboBox->setVisible(false);
m_ui.msvcLabel->setVisible(false);
makeMingwVisible(false); makeMingwVisible(false);
m_ui.errorLabel->setText("Found Qt version " m_ui.errorLabel->setText("Found Qt version "
+ m_versions.at(index)->qtVersionString() + m_versions.at(index)->qtVersionString()
@@ -552,7 +653,6 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item)
} }
} else { } else {
m_ui.msvcComboBox->setVisible(false); m_ui.msvcComboBox->setVisible(false);
m_ui.msvcLabel->setVisible(false);
makeMingwVisible(false); makeMingwVisible(false);
} }
} }
@@ -665,10 +765,24 @@ void QtDirWidget::updateCurrentQtPath()
QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem();
Q_ASSERT(currentItem); Q_ASSERT(currentItem);
int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
if (m_versions[currentItemIndex]->path() == m_ui.qtPath->path())
return;
m_versions[currentItemIndex]->setPath(m_ui.qtPath->path()); m_versions[currentItemIndex]->setPath(m_ui.qtPath->path());
currentItem->setText(1, m_versions[currentItemIndex]->path()); currentItem->setText(1, m_versions[currentItemIndex]->path());
showEnvironmentPage(currentItem); showEnvironmentPage(currentItem);
DebuggingHelperWidget *dhw = qobject_cast<DebuggingHelperWidget *>(m_ui.qtdirList->itemWidget(currentItem, 2));
if (m_versions[currentItemIndex]->isValid()) {
DebuggingHelperWidget::State s = DebuggingHelperWidget::Ok;
if (!m_versions[currentItemIndex]->hasDebuggingHelper())
s = DebuggingHelperWidget::State(s | DebuggingHelperWidget::Error);
if (!currentItem->data(2, Qt::UserRole).toString().isEmpty())
s = DebuggingHelperWidget::State(s | DebuggingHelperWidget::ShowLog);
dhw->setState(s);
} else {
dhw->setState(DebuggingHelperWidget::InvalidQt);
}
} }
void QtDirWidget::updateCurrentMingwDirectory() void QtDirWidget::updateCurrentMingwDirectory()
@@ -686,16 +800,6 @@ void QtDirWidget::msvcVersionChanged()
Q_ASSERT(currentItem); Q_ASSERT(currentItem);
int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem);
m_versions[currentItemIndex]->setMsvcVersion(msvcVersion); m_versions[currentItemIndex]->setMsvcVersion(msvcVersion);
//get descriptionx
//TODO
// QList<MSVCEnvironment> msvcEnvironments = MSVCEnvironment::availableVersions();
// foreach(const MSVCEnvironment &msvcEnv, msvcEnvironments) {
// if (msvcEnv.name() == msvcVersion) {
// m_ui.msvcLabel->setText(msvcEnv.description());
// break;
// }
// }
} }
QList<QtVersion *> QtDirWidget::versions() const QList<QtVersion *> QtDirWidget::versions() const
@@ -713,7 +817,12 @@ int QtDirWidget::defaultVersion() const
/// ///
QtVersion::QtVersion(const QString &name, const QString &path, int id, bool isSystemVersion) QtVersion::QtVersion(const QString &name, const QString &path, int id, bool isSystemVersion)
: m_name(name), m_isSystemVersion(isSystemVersion), m_notInstalled(false), m_defaultConfigIsDebug(true), m_defaultConfigIsDebugAndRelease(true) : m_name(name),
m_isSystemVersion(isSystemVersion),
m_notInstalled(false),
m_defaultConfigIsDebug(true),
m_defaultConfigIsDebugAndRelease(true),
m_hasDebuggingHelper(false)
{ {
setPath(path); setPath(path);
if (id == -1) if (id == -1)
@@ -726,7 +835,8 @@ QtVersion::QtVersion(const QString &name, const QString &path)
: m_name(name), : m_name(name),
m_versionInfoUpToDate(false), m_versionInfoUpToDate(false),
m_mkspecUpToDate(false), m_mkspecUpToDate(false),
m_isSystemVersion(false) m_isSystemVersion(false),
m_hasDebuggingHelper(false)
{ {
setPath(path); setPath(path);
m_id = getUniqueId(); m_id = getUniqueId();
@@ -783,6 +893,30 @@ void QtVersion::setPath(const QString &path)
m_versionInfoUpToDate = false; m_versionInfoUpToDate = false;
m_mkspecUpToDate = false; m_mkspecUpToDate = false;
m_qmakeCommand = QString::null; m_qmakeCommand = QString::null;
// TODO do i need to optimize this?
m_hasDebuggingHelper = !dumperLibrary().isEmpty();
}
QString QtVersion::dumperLibrary() const
{
uint hash = qHash(path());
QStringList directories;
directories
<< (path() + "/qtc-debugging-helper/")
<< (QApplication::applicationDirPath() + "../qtc-debugging-helper/" + QString::number(hash))
<< (QDesktopServices::StandardLocation(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())
return fi.filePath();
}
return QString();
} }
void QtVersion::updateSourcePath() void QtVersion::updateSourcePath()
@@ -1263,3 +1397,94 @@ QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const
result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild); result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild);
return result; return result;
} }
bool QtVersion::hasDebuggingHelper() const
{
return m_hasDebuggingHelper;
}
QString QtVersion::buildDebuggingHelperLibrary()
{
// Locations to try:
// $QTDIR/qtc-debugging-helper
// $APPLICATION-DIR/qtc-debugging-helper/$hash
// $USERDIR/qtc-debugging-helper/$hash
QString output;
uint hash = qHash(path());
QStringList directories;
directories
<< path() + "/qtc-debugging-helper/"
<< QApplication::applicationDirPath() + "/../qtc-debugging-helper/" + QString::number(hash)
<< QDesktopServices::storageLocation (QDesktopServices::DataLocation) + "/qtc-debugging-helper/" + QString::number(hash);
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)
continue;
output += QString("Building debugging helper library in %1\n").arg(directory);
output += "\n";
output += "Runinng qmake...\n";
QProcess qmake;
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
addToEnvironment(env);
qmake.setEnvironment(env.toStringList());
qmake.setWorkingDirectory(directory);
qmake.setProcessChannelMode(QProcess::MergedChannels);
qmake.start(qmakeCommand(), QStringList()<<"-spec"<<"default"<<"gdbmacros.pro");
qmake.waitForFinished();
output += qmake.readAll();
// TODO this is butt ugly
// only qt4projects have a toolchain() method. (Reason mostly, that in order to create
// the toolchain, we need to have the path to gcc
// which might depend on environment settings of the project
// so we hardcode the toolchainType to make conversation here
// and think about how to fix that later
QString make;
ProjectExplorer::ToolChain::ToolChainType t = toolchainType();
if (t == ProjectExplorer::ToolChain::MinGW)
make = "mingw32-make.exe";
else if(t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE)
make = "nmake.exe";
else if (t == ProjectExplorer::ToolChain::GCC || t == ProjectExplorer::ToolChain::LinuxICC)
make = "make";
QString makeFullPath = env.searchInPath(make);
output += "\n";
if (!makeFullPath.isEmpty()) {
output += QString("Running %1...\n").arg(makeFullPath);
qmake.start(makeFullPath, QStringList());
qmake.waitForFinished();
output += qmake.readAll();
} else {
output += QString("%1 not found in PATH\n").arg(make);
}
break;
}
m_hasDebuggingHelper = !dumperLibrary().isEmpty();
return output;
}

View File

@@ -38,6 +38,7 @@
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QPushButton>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
@@ -79,6 +80,10 @@ public:
QString wincePlatform() const; QString wincePlatform() const;
void setMsvcVersion(const QString &version); void setMsvcVersion(const QString &version);
void addToEnvironment(ProjectExplorer::Environment &env); void addToEnvironment(ProjectExplorer::Environment &env);
bool hasDebuggingHelper() const;
// Builds a debugging library
// returns the output of the commands
QString buildDebuggingHelperLibrary();
int uniqueId() const; int uniqueId() const;
@@ -90,6 +95,7 @@ public:
}; };
QmakeBuildConfig defaultBuildConfig() const; QmakeBuildConfig defaultBuildConfig() const;
QString dumperLibrary() const;
private: private:
static int getUniqueId(); static int getUniqueId();
void setName(const QString &name); void setName(const QString &name);
@@ -117,6 +123,7 @@ private:
// This is updated on first call to qmakeCommand // This is updated on first call to qmakeCommand
// That function is called from updateVersionInfo() // That function is called from updateVersionInfo()
mutable QString m_qtVersionString; mutable QString m_qtVersionString;
bool m_hasDebuggingHelper;
}; };
@@ -132,6 +139,7 @@ public:
private: private:
void showEnvironmentPage(QTreeWidgetItem * item); void showEnvironmentPage(QTreeWidgetItem * item);
void fixQtVersionName(int index); void fixQtVersionName(int index);
int indexFor(QWidget *debuggingHelperWidget) const;
Ui::QtVersionManager m_ui; Ui::QtVersionManager m_ui;
QList<QtVersion *> m_versions; QList<QtVersion *> m_versions;
int m_defaultVersion; int m_defaultVersion;
@@ -151,6 +159,8 @@ private slots:
void updateCurrentQtPath(); void updateCurrentQtPath();
void updateCurrentMingwDirectory(); void updateCurrentMingwDirectory();
void msvcVersionChanged(); void msvcVersionChanged();
void buildDebuggingHelper();
void showDebuggingBuildLog();
}; };
class QtVersionManager : public Core::IOptionsPage class QtVersionManager : public Core::IOptionsPage
@@ -212,6 +222,27 @@ private:
int m_idcount; int m_idcount;
}; };
class DebuggingHelperWidget : public QWidget
{
Q_OBJECT
public:
DebuggingHelperWidget();
enum State {
Ok = 0,
Error = 1,
ShowLog = 2,
InvalidQt = 4
};
void setState(State s);
signals:
void rebuildClicked();
void showLogClicked();
private:
QLabel *m_statusLabel;
QPushButton *m_showLog;
QPushButton *m_rebuild;
};
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -78,7 +78,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="columnCount"> <property name="columnCount">
<number>2</number> <number>3</number>
</property> </property>
<column> <column>
<property name="text"> <property name="text">
@@ -90,6 +90,11 @@
<string>Path</string> <string>Path</string>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>Debugging Helper</string>
</property>
</column>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@@ -116,21 +121,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="6" column="0" colspan="4">
<widget class="QLabel" name="msvcLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QLabel" name="errorLabel"> <widget class="QLabel" name="errorLabel">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1" colspan="2"> <item row="4" column="1" colspan="2">
<widget class="QComboBox" name="msvcComboBox"/> <widget class="QComboBox" name="msvcComboBox"/>
</item> </item>
<item row="2" column="1" colspan="2"> <item row="2" column="1" colspan="2">

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShowBuildLog</class>
<widget class="QDialog" name="ShowBuildLog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="log">
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ShowBuildLog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ShowBuildLog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>