diff options
author | dt <qtc-committer@nokia.com> | 2009-03-25 15:18:37 +0100 |
---|---|---|
committer | dt <qtc-committer@nokia.com> | 2009-03-25 15:18:37 +0100 |
commit | e21a74cb35e37c178e4ad02bea0fab269dbf76cf (patch) | |
tree | ed6f8c4fb050f6ed5d861d80bff0046d00b5724f | |
parent | c964d64d34aa68f55537e854558bae9a9c99ff76 (diff) | |
download | qt-creator-e21a74cb35e37c178e4ad02bea0fab269dbf76cf.tar.gz |
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.
18 files changed, 388 insertions, 378 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 28213df1e8..3a888a8c67 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -123,6 +123,11 @@ QWidget *CMakeRunConfiguration::configurationWidget() return new QWidget(); } +QString CMakeRunConfiguration::dumperLibrary() const +{ + return QString(); +} + // Factory CMakeRunConfigurationFactory::CMakeRunConfigurationFactory() { diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h index d2a142ff9f..8e01eb9d64 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h @@ -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; diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 3cc74138f4..e5eefdc096 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -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(); diff --git a/src/plugins/projectexplorer/applicationrunconfiguration.h b/src/plugins/projectexplorer/applicationrunconfiguration.h index 6fd9c993c1..e23818c1f9 100644 --- a/src/plugins/projectexplorer/applicationrunconfiguration.h +++ b/src/plugins/projectexplorer/applicationrunconfiguration.h @@ -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); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 06ab960e35..47a1748f4e 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -308,6 +308,13 @@ void CustomExecutableRunConfiguration::setUserName(const QString &name) emit changed(); } +QString CustomExecutableRunConfiguration::dumperLibrary() const +{ + return QString(); +} + + + // Factory CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory() diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.h b/src/plugins/projectexplorer/customexecutablerunconfiguration.h index 6d2ca1755a..107c889f95 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.h +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.h @@ -86,6 +86,7 @@ public: virtual void restore(const PersistentSettingsReader &reader); virtual QWidget *configurationWidget(); + virtual QString dumperLibrary() const; signals: void changed(); diff --git a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp deleted file mode 100644 index 4fe0dc0004..0000000000 --- a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.cpp +++ /dev/null @@ -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 -} diff --git a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.h b/src/plugins/qt4projectmanager/gdbmacrosbuildstep.h deleted file mode 100644 index ba78a0f632..0000000000 --- a/src/plugins/qt4projectmanager/gdbmacrosbuildstep.h +++ /dev/null @@ -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 diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index cf496f991b..36901bbc1c 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -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()); } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 04ac5d8067..98e9527470 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -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) diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index f916effd0c..14f77bdbbb 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -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"; diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp index cc37449efc..529a927279 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanagerplugin.cpp @@ -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); diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index fea2b436ee..4469df5607 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -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) diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.h b/src/plugins/qt4projectmanager/qt4runconfiguration.h index 30ff16a294..30e2878522 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.h +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.h @@ -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; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index d8628d5699..e1f9bc12a3 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -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); + + connect(dhw, SIGNAL(rebuildClicked()), this, SLOT(buildDebuggingHelper())); + connect(dhw, SIGNAL(showLogClicked()), this, SLOT(showDebuggingBuildLog())); + m_ui.defaultCombo->addItem(version->name()); if (i == m_defaultVersion) m_ui.defaultCombo->setCurrentIndex(i); @@ -434,6 +488,51 @@ QtDirWidget::QtDirWidget(QWidget *parent, QList<QtVersion *> versions, int defau 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() { qDeleteAll(m_versions); @@ -449,6 +548,16 @@ void QtDirWidget::addQtDir() item->setText(1, newVersion->path()); 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.nameEdit->setText(newVersion->name()); @@ -506,19 +615,14 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) ProjectExplorer::ToolChain::ToolChainType t = m_versions.at(index)->toolchainType(); if (t == ProjectExplorer::ToolChain::MinGW) { m_ui.msvcComboBox->setVisible(false); - m_ui.msvcLabel->setVisible(false); makeMingwVisible(true); m_ui.mingwPath->setPath(m_versions.at(index)->mingwDirectory()); } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){ m_ui.msvcComboBox->setVisible(false); - m_ui.msvcLabel->setVisible(true); makeMingwVisible(false); QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions(); if (msvcEnvironments.count() == 0) { - m_ui.msvcLabel->setText(tr("No Visual Studio Installation found")); } else if (msvcEnvironments.count() == 1) { - //TODO m_ui.msvcLabel->setText( msvcEnvironments.at(0).description()); - m_ui.msvcLabel->setText(""); } else { m_ui.msvcComboBox->setVisible(true); bool block = m_ui.msvcComboBox->blockSignals(true); @@ -527,14 +631,12 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) m_ui.msvcComboBox->addItem(msvcenv); if (msvcenv == m_versions.at(index)->msvcVersion()) { m_ui.msvcComboBox->setCurrentIndex(m_ui.msvcComboBox->count() - 1); - m_ui.msvcLabel->setText(""); //TODO } } m_ui.msvcComboBox->blockSignals(block); } } else if (t == ProjectExplorer::ToolChain::INVALID) { m_ui.msvcComboBox->setVisible(false); - m_ui.msvcLabel->setVisible(false); makeMingwVisible(false); if (!m_versions.at(index)->isInstalled()) 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())); } else { //ProjectExplorer::ToolChain::GCC m_ui.msvcComboBox->setVisible(false); - m_ui.msvcLabel->setVisible(false); makeMingwVisible(false); m_ui.errorLabel->setText("Found Qt version " + m_versions.at(index)->qtVersionString() @@ -552,7 +653,6 @@ void QtDirWidget::showEnvironmentPage(QTreeWidgetItem *item) } } else { m_ui.msvcComboBox->setVisible(false); - m_ui.msvcLabel->setVisible(false); makeMingwVisible(false); } } @@ -665,10 +765,24 @@ void QtDirWidget::updateCurrentQtPath() QTreeWidgetItem *currentItem = m_ui.qtdirList->currentItem(); Q_ASSERT(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()); currentItem->setText(1, m_versions[currentItemIndex]->path()); 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() @@ -686,16 +800,6 @@ void QtDirWidget::msvcVersionChanged() Q_ASSERT(currentItem); int currentItemIndex = m_ui.qtdirList->indexOfTopLevelItem(currentItem); 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 @@ -713,7 +817,12 @@ int QtDirWidget::defaultVersion() const /// 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); if (id == -1) @@ -726,7 +835,8 @@ QtVersion::QtVersion(const QString &name, const QString &path) : m_name(name), m_versionInfoUpToDate(false), m_mkspecUpToDate(false), - m_isSystemVersion(false) + m_isSystemVersion(false), + m_hasDebuggingHelper(false) { setPath(path); m_id = getUniqueId(); @@ -783,6 +893,30 @@ void QtVersion::setPath(const QString &path) m_versionInfoUpToDate = false; m_mkspecUpToDate = false; 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() @@ -1263,3 +1397,94 @@ QtVersion::QmakeBuildConfig QtVersion::defaultBuildConfig() const result = QtVersion::QmakeBuildConfig(result | QtVersion::DebugBuild); 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; +} diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index 7252a698cd..7c9673ce38 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -38,6 +38,7 @@ #include <QtCore/QPointer> #include <QtGui/QWidget> +#include <QtGui/QPushButton> namespace Qt4ProjectManager { namespace Internal { @@ -79,6 +80,10 @@ public: QString wincePlatform() const; void setMsvcVersion(const QString &version); void addToEnvironment(ProjectExplorer::Environment &env); + bool hasDebuggingHelper() const; + // Builds a debugging library + // returns the output of the commands + QString buildDebuggingHelperLibrary(); int uniqueId() const; @@ -90,6 +95,7 @@ public: }; QmakeBuildConfig defaultBuildConfig() const; + QString dumperLibrary() const; private: static int getUniqueId(); void setName(const QString &name); @@ -117,6 +123,7 @@ private: // This is updated on first call to qmakeCommand // That function is called from updateVersionInfo() mutable QString m_qtVersionString; + bool m_hasDebuggingHelper; }; @@ -132,6 +139,7 @@ public: private: void showEnvironmentPage(QTreeWidgetItem * item); void fixQtVersionName(int index); + int indexFor(QWidget *debuggingHelperWidget) const; Ui::QtVersionManager m_ui; QList<QtVersion *> m_versions; int m_defaultVersion; @@ -151,6 +159,8 @@ private slots: void updateCurrentQtPath(); void updateCurrentMingwDirectory(); void msvcVersionChanged(); + void buildDebuggingHelper(); + void showDebuggingBuildLog(); }; class QtVersionManager : public Core::IOptionsPage @@ -212,6 +222,27 @@ private: 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 Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui index 0d3941d038..fd61e92f4b 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.ui +++ b/src/plugins/qt4projectmanager/qtversionmanager.ui @@ -78,7 +78,7 @@ <bool>false</bool> </property> <property name="columnCount"> - <number>2</number> + <number>3</number> </property> <column> <property name="text"> @@ -90,6 +90,11 @@ <string>Path</string> </property> </column> + <column> + <property name="text"> + <string>Debugging Helper</string> + </property> + </column> </widget> </item> <item row="1" column="0"> @@ -116,21 +121,14 @@ </property> </widget> </item> - <item row="4" column="0" colspan="3"> - <widget class="QLabel" name="msvcLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="7" column="0" colspan="4"> + <item row="6" column="0" colspan="4"> <widget class="QLabel" name="errorLabel"> <property name="text"> <string/> </property> </widget> </item> - <item row="5" column="1" colspan="2"> + <item row="4" column="1" colspan="2"> <widget class="QComboBox" name="msvcComboBox"/> </item> <item row="2" column="1" colspan="2"> diff --git a/src/plugins/qt4projectmanager/showbuildlog.ui b/src/plugins/qt4projectmanager/showbuildlog.ui new file mode 100644 index 0000000000..98c61b360e --- /dev/null +++ b/src/plugins/qt4projectmanager/showbuildlog.ui @@ -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> |