Commit e21a74cb authored by dt's avatar dt
Browse files

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.
parent c964d64d
......@@ -123,6 +123,11 @@ QWidget *CMakeRunConfiguration::configurationWidget()
return new QWidget();
}
QString CMakeRunConfiguration::dumperLibrary() const
{
return QString();
}
// Factory
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
{
......
......@@ -59,6 +59,7 @@ public:
virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);
virtual QString dumperLibrary() const;
private:
RunMode m_runMode;
QString m_target;
......
......@@ -132,8 +132,6 @@ void DebuggerRunControl::start()
project->buildDirectory(project->activeBuildConfiguration());
m_manager->m_useTerminal = rc->runMode() == ApplicationRunConfiguration::Console;
//<daniel> andre: + "\qtc-gdbmacros\"
//emit addToOutputWindow(this, tr("Debugging %1").arg(m_executable));
if (m_manager->startNewDebugger(StartInternal))
emit started();
......
......@@ -54,6 +54,7 @@ public:
virtual QString workingDirectory() const = 0;
virtual QStringList commandLineArguments() const = 0;
virtual Environment environment() const = 0;
virtual QString dumperLibrary() const = 0;
virtual void save(PersistentSettingsWriter &writer) const;
virtual void restore(const PersistentSettingsReader &reader);
......
......@@ -308,6 +308,13 @@ void CustomExecutableRunConfiguration::setUserName(const QString &name)
emit changed();
}
QString CustomExecutableRunConfiguration::dumperLibrary() const
{
return QString();
}
// Factory
CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory()
......
......@@ -86,6 +86,7 @@ public:
virtual void restore(const PersistentSettingsReader &reader);
virtual QWidget *configurationWidget();
virtual QString dumperLibrary() const;
signals:
void changed();
......
/**************************************************************************
**
** 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
}
/**************************************************************************
**
** 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
......@@ -42,7 +42,6 @@
#include "qt4buildenvironmentwidget.h"
#include "qt4projectmanagerconstants.h"
#include "projectloadwizard.h"
#include "gdbmacrosbuildstep.h"
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
......@@ -656,10 +655,6 @@ void Qt4Project::addDefaultBuild()
//TODO have a better check wheter there is already a configuration?
QMakeStep *qmakeStep = 0;
MakeStep *makeStep = 0;
GdbMacrosBuildStep *gdbmacrostep;
gdbmacrostep = new GdbMacrosBuildStep(this);
insertBuildStep(0, gdbmacrostep);
qmakeStep = new QMakeStep(this);
qmakeStep->setValue("mkspec", "");
......@@ -668,10 +663,6 @@ void Qt4Project::addDefaultBuild()
makeStep = new MakeStep(this);
insertBuildStep(2, makeStep);
GdbMacrosBuildStep *gdbmacrosCleanStep = new GdbMacrosBuildStep(this);
gdbmacrosCleanStep->setValue("clean", true);
insertCleanStep(0, gdbmacrosCleanStep);
MakeStep* cleanStep = new MakeStep(this);
cleanStep->setValue("clean", true);
insertCleanStep(1, cleanStep);
......@@ -680,25 +671,6 @@ void Qt4Project::addDefaultBuild()
wizard.execDialog();
} else {
// 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()) {
setValue(bc, "addQDumper", QVariant());
}
......
......@@ -35,8 +35,7 @@ HEADERS = qt4projectmanagerplugin.h \
qt4buildconfigwidget.h \
qt4buildenvironmentwidget.h \
projectloadwizard.h \
directorywatcher.h \
gdbmacrosbuildstep.h
directorywatcher.h
SOURCES = qt4projectmanagerplugin.cpp \
qt4projectmanager.cpp \
qtversionmanager.cpp \
......@@ -67,8 +66,7 @@ SOURCES = qt4projectmanagerplugin.cpp \
qt4buildconfigwidget.cpp \
qt4buildenvironmentwidget.cpp \
projectloadwizard.cpp \
directorywatcher.cpp \
gdbmacrosbuildstep.cpp
directorywatcher.cpp
FORMS = qtversionmanager.ui \
envvariablespage.ui \
enveditdialog.ui \
......@@ -77,7 +75,8 @@ FORMS = qtversionmanager.ui \
qmakestep.ui \
qt4buildconfigwidget.ui \
embeddedpropertiespage.ui \
qt4buildenvironmentwidget.ui
qt4buildenvironmentwidget.ui \
showbuildlog.ui
RESOURCES = qt4projectmanager.qrc \
wizards/wizards.qrc
include(../../shared/proparser/proparser.pri)
......
......@@ -71,7 +71,6 @@ const char * const GC_COMPILER = "Qt4.Compiler";
// qmakestep
const char * const QMAKESTEP = "trolltech.qt4projectmanager.qmake";
const char * const MAKESTEP = "trolltech.qt4projectmanager.make";
const char * const GDBMACROSBUILDSTEP = "trolltech.qt4projectmanager.gdbmaros";
const char * const QT4RUNSTEP = "trolltech.qt4projectmanager.qt4runstep";
const char * const DEPLOYHELPERRUNSTEP = "trolltech.qt4projectmanager.deployhelperrunstep";
......
......@@ -41,7 +41,6 @@
#include "embeddedpropertiespage.h"
#include "qt4runconfiguration.h"
#include "profilereader.h"
#include "gdbmacrosbuildstep.h"
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
......@@ -125,7 +124,6 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new QMakeBuildStepFactory);
addAutoReleasedObject(new MakeBuildStepFactory);
addAutoReleasedObject(new GdbMacrosBuildStepFactory);
m_qtVersionManager = new QtVersionManager;
addObject(m_qtVersionManager);
......
......@@ -370,6 +370,14 @@ void Qt4RunConfiguration::invalidateCachedTargetInformation()
emit effectiveTargetInformationChanged();
}
QString Qt4RunConfiguration::dumperLibrary() const
{
Qt4Project *pro = qobject_cast<Qt4Project *>(project());
QtVersion *version = pro->qtVersion(pro->activeBuildConfiguration());
return version->dumperLibrary();
}
///
/// Qt4RunConfigurationFactory
/// This class is used to restore run settings (saved in .user files)
......
......@@ -70,6 +70,7 @@ public:
virtual QString workingDirectory() const;
virtual QStringList commandLineArguments() const;
virtual ProjectExplorer::Environment environment() const;
virtual QString dumperLibrary() const;
QString proFilePath() const;
......
......@@ -30,6 +30,7 @@
#include "qtversionmanager.h"
#include "qt4projectmanagerconstants.h"
#include "ui_showbuildlog.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
......@@ -48,6 +49,12 @@
#include <QtGui/QFileDialog>
#include <QtGui/QHeaderView>
#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;
......@@ -57,6 +64,43 @@ static const char *QtVersionsSectionName = "QtVersions";
static const char *defaultQtVersionKey = "DefaultQtVersion";
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()
: m_emptyVersion(new QtVersion)
{
......@@ -370,7 +414,6 @@ QtVersion *QtVersionManager::currentQtVersion() const
}
//-----------------------------------------------------
QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defaultVersion)
: QWidget(parent)
, m_defaultVersion(defaultVersion)
......@@ -398,6 +441,17 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defau
item->setText(0, version->name());
item->setText(1, version->path());
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);