diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2011-07-21 16:46:10 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@nokia.com> | 2011-07-22 12:07:50 +0200 |
commit | d943015c761011b2df111403abdeba454ad040ae (patch) | |
tree | 4ba6308d56d8095f4bc5cd1bcfdc0324a7c87ac0 | |
parent | 8d5b3677ea439266acb041c66f00a8d924cc1105 (diff) | |
download | qt-creator-d943015c761011b2df111403abdeba454ad040ae.tar.gz |
DebuggingHelper: Use right toolchain
Don't just use an arbitrary toolchain, which might break esp. for Symbian.
Instead, retrieve the toolchain from the project, or in the case of the Qt Options
page let the user choose.
Change-Id: I6d271c485420e609d223d8cece754ef84e573745
Reviewed-on: http://codereview.qt.nokia.com/1978
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlproject.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qmakestep.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qt4project.cpp | 1 | ||||
-rw-r--r-- | src/plugins/qtsupport/debugginghelper.ui | 32 | ||||
-rw-r--r-- | src/plugins/qtsupport/debugginghelperbuildtask.cpp | 28 | ||||
-rw-r--r-- | src/plugins/qtsupport/debugginghelperbuildtask.h | 5 | ||||
-rw-r--r-- | src/plugins/qtsupport/qmldumptool.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qtsupport/qmldumptool.h | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtoptionspage.cpp | 48 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtoptionspage.h | 5 |
10 files changed, 115 insertions, 29 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 8afc421770..9630e15008 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -46,7 +46,7 @@ #include <qtsupport/qtversionmanager.h> #include <qmljs/qmljsmodelmanagerinterface.h> #include <utils/fileutils.h> - +#include <projectexplorer/toolchainmanager.h> #include <utils/filesystemwatcher.h> #include <QtCore/QTextStream> @@ -147,7 +147,11 @@ void QmlProject::refresh(RefreshOptions options) if (activeTarget()) { if (QmlProjectRunConfiguration *rc = qobject_cast<QmlProjectRunConfiguration *>(activeTarget()->activeRunConfiguration())) version = rc->qtVersion(); - QtSupport::QmlDumpTool::pathAndEnvironment(this, version, false, &pinfo.qmlDumpPath, &pinfo.qmlDumpEnvironment); + QList<ProjectExplorer::ToolChain *> tcList + = ProjectExplorer::ToolChainManager::instance()->findToolChains(version->qtAbis().at(0)); + if (tcList.isEmpty()) + return; + QtSupport::QmlDumpTool::pathAndEnvironment(this, version, tcList.first(), false, &pinfo.qmlDumpPath, &pinfo.qmlDumpEnvironment); } m_modelManager->updateProjectInfo(pinfo); } diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 355c3386fe..cc3b795d97 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -651,8 +651,10 @@ void QMakeStepConfigWidget::buildQmlDebuggingHelper() QtSupport::BaseQtVersion *version = m_step->qt4BuildConfiguration()->qtVersion(); if (!version) return; + QtSupport::DebuggingHelperBuildTask *buildTask = - new QtSupport::DebuggingHelperBuildTask(version, QtSupport::DebuggingHelperBuildTask::QmlDebugging); + new QtSupport::DebuggingHelperBuildTask(version, m_step->qt4BuildConfiguration()->toolChain(), + QtSupport::DebuggingHelperBuildTask::QmlDebugging); // pop up Application Output on error buildTask->showOutputOnError(true); diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 772dd7c8cc..dbba9d5dfa 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -564,6 +564,7 @@ void Qt4Project::updateQmlJSCodeModel() } } QtSupport::QmlDumpTool::pathAndEnvironment(this, activeTarget()->activeBuildConfiguration()->qtVersion(), + activeTarget()->activeBuildConfiguration()->toolChain(), preferDebugDump, &projectInfo.qmlDumpPath, &projectInfo.qmlDumpEnvironment); projectInfo.importPaths.removeDuplicates(); diff --git a/src/plugins/qtsupport/debugginghelper.ui b/src/plugins/qtsupport/debugginghelper.ui index a3cf9e5349..88fc3045ce 100644 --- a/src/plugins/qtsupport/debugginghelper.ui +++ b/src/plugins/qtsupport/debugginghelper.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>321</width> - <height>150</height> + <height>159</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> @@ -164,8 +164,38 @@ </layout> </item> <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> + <widget class="QLabel" name="toolChainLabel"> + <property name="text"> + <string>Tool Chain:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="toolChainComboBox"> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + <item> <spacer name="horizontalSpacer_4"> <property name="orientation"> <enum>Qt::Horizontal</enum> diff --git a/src/plugins/qtsupport/debugginghelperbuildtask.cpp b/src/plugins/qtsupport/debugginghelperbuildtask.cpp index cc43cd1b55..2564710c13 100644 --- a/src/plugins/qtsupport/debugginghelperbuildtask.cpp +++ b/src/plugins/qtsupport/debugginghelperbuildtask.cpp @@ -48,13 +48,17 @@ using namespace QtSupport; using namespace QtSupport::Internal; using ProjectExplorer::DebuggingHelperLibrary; -DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools) : +DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version, + ProjectExplorer::ToolChain *toolChain, + Tools tools) : m_tools(tools & availableTools(version)), m_invalidQt(false), m_showErrors(true) { - if (!version || !version->isValid()) + if (!version || !version->isValid() || !toolChain) { + m_invalidQt = true; return; + } // allow type to be used in queued connections. qRegisterMetaType<DebuggingHelperBuildTask::Tools>("DebuggingHelperBuildTask::Tools"); @@ -84,28 +88,16 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version, m_environment = Utils::Environment::systemEnvironment(); version->addToEnvironment(m_environment); - // TODO: the debugging helper doesn't comply to actual tool chain yet - QList<ProjectExplorer::ToolChain *> tcList = ProjectExplorer::ToolChainManager::instance()->findToolChains(version->qtAbis().at(0)); - if (tcList.isEmpty()) { - const QString error - = QCoreApplication::translate( - "QtVersion", - "The Qt Version has no tool chain."); - log(QString(), error); - m_invalidQt = true; - return; - } - ProjectExplorer::ToolChain *tc = tcList.at(0); - tc->addToEnvironment(m_environment); + toolChain->addToEnvironment(m_environment); log(QCoreApplication::translate("QtVersion", "Building helper(s) with toolchain '%1' ...\n" - ).arg(tc->displayName()), QString()); + ).arg(toolChain->displayName()), QString()); - if (tc->targetAbi().os() == ProjectExplorer::Abi::LinuxOS + if (toolChain->targetAbi().os() == ProjectExplorer::Abi::LinuxOS && ProjectExplorer::Abi::hostAbi().os() == ProjectExplorer::Abi::WindowsOS) m_target = QLatin1String("-unix"); m_qmakeCommand = version->qmakeCommand(); - m_makeCommand = tc->makeCommand(); + m_makeCommand = toolChain->makeCommand(); m_mkspec = version->mkspec(); // Make sure QtVersion cache is invalidated diff --git a/src/plugins/qtsupport/debugginghelperbuildtask.h b/src/plugins/qtsupport/debugginghelperbuildtask.h index 9a0a7fceeb..464c7f53b4 100644 --- a/src/plugins/qtsupport/debugginghelperbuildtask.h +++ b/src/plugins/qtsupport/debugginghelperbuildtask.h @@ -35,6 +35,7 @@ #include "qtsupport_global.h" #include <utils/environment.h> +#include <projectexplorer/toolchain.h> #include <QtCore/QObject> #include <QtCore/QFutureInterface> @@ -56,7 +57,9 @@ public: }; Q_DECLARE_FLAGS(Tools, DebuggingHelper) - explicit DebuggingHelperBuildTask(const BaseQtVersion *version, Tools tools = AllTools); + explicit DebuggingHelperBuildTask(const BaseQtVersion *version, + ProjectExplorer::ToolChain *toolChain, + Tools tools = AllTools); virtual ~DebuggingHelperBuildTask(); void showOutputOnError(bool show); diff --git a/src/plugins/qtsupport/qmldumptool.cpp b/src/plugins/qtsupport/qmldumptool.cpp index 3747ea242c..24bf3c8693 100644 --- a/src/plugins/qtsupport/qmldumptool.cpp +++ b/src/plugins/qtsupport/qmldumptool.cpp @@ -39,6 +39,7 @@ #include <coreplugin/progressmanager/progressmanager.h> #include <projectexplorer/project.h> +#include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/runconfiguration.h> #include <qtconcurrent/runextensions.h> @@ -54,7 +55,7 @@ namespace { using namespace QtSupport; using QtSupport::DebuggingHelperBuildTask; - +using ProjectExplorer::ToolChain; class QmlDumpBuildTask; @@ -66,8 +67,9 @@ class QmlDumpBuildTask : public QObject { Q_DISABLE_COPY(QmlDumpBuildTask) Q_OBJECT public: - explicit QmlDumpBuildTask(BaseQtVersion *version) - : m_buildTask(new DebuggingHelperBuildTask(version, DebuggingHelperBuildTask::QmlDump)) + explicit QmlDumpBuildTask(BaseQtVersion *version, ToolChain *toolChain) + : m_buildTask(new DebuggingHelperBuildTask(version, toolChain, + DebuggingHelperBuildTask::QmlDump)) , m_failed(false) { qmlDumpBuilds()->insert(version->uniqueId(), this); @@ -310,6 +312,7 @@ QStringList QmlDumpTool::installDirectories(const QString &qtInstallData) } void QmlDumpTool::pathAndEnvironment(ProjectExplorer::Project *project, BaseQtVersion *version, + ProjectExplorer::ToolChain *toolChain, bool preferDebug, QString *dumperPath, Utils::Environment *env) { QString path; @@ -319,7 +322,7 @@ void QmlDumpTool::pathAndEnvironment(ProjectExplorer::Project *project, BaseQtVe if (!qmlDumpBuildTask->hasFailed()) qmlDumpBuildTask->updateProjectWhenDone(project, preferDebug); } else { - QmlDumpBuildTask *buildTask = new QmlDumpBuildTask(version); + QmlDumpBuildTask *buildTask = new QmlDumpBuildTask(version, toolChain); buildTask->updateProjectWhenDone(project, preferDebug); QFuture<void> task = QtConcurrent::run(&QmlDumpBuildTask::run, buildTask); const QString taskName = QmlDumpBuildTask::tr("Building helper"); diff --git a/src/plugins/qtsupport/qmldumptool.h b/src/plugins/qtsupport/qmldumptool.h index 4192fc8a06..5e0eeccceb 100644 --- a/src/plugins/qtsupport/qmldumptool.h +++ b/src/plugins/qtsupport/qmldumptool.h @@ -43,6 +43,7 @@ namespace Utils { namespace ProjectExplorer { class Project; + class ToolChain; } namespace QtSupport { @@ -64,6 +65,7 @@ public: static QString copy(const QString &qtInstallData, QString *errorMessage); static void pathAndEnvironment(ProjectExplorer::Project *project, BaseQtVersion *version, + ProjectExplorer::ToolChain *toolChain, bool preferDebug, QString *path, Utils::Environment *env); private: diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index 3a09c926a0..ca9a457c66 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -49,6 +49,7 @@ #include <utils/buildablehelperlibrary.h> #include <utils/pathchooser.h> #include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/toolchain.h> #include <qtconcurrent/runextensions.h> #include <QtCore/QDir> @@ -409,6 +410,25 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba return info; } +QList<ProjectExplorer::ToolChain*> QtOptionsPageWidget::toolChains(const BaseQtVersion *version) +{ + QHash<QString,ProjectExplorer::ToolChain*> toolChains; + if (!version) + return toolChains.values(); + + foreach (const ProjectExplorer::Abi &a, version->qtAbis()) { + // Ignore symbian emulator since we do not support it. + if (a.osFlavor() == ProjectExplorer::Abi::SymbianEmulatorFlavor) + continue; + foreach (ProjectExplorer::ToolChain *tc, + ProjectExplorer::ToolChainManager::instance()->findToolChains(a)) { + toolChains.insert(tc->id(), tc); + } + } + + return toolChains.values(); +} + void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools) { const int index = currentIndex(); @@ -430,7 +450,14 @@ void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools t updateDebuggingHelperUi(); // Run a debugging helper build task in the background. - DebuggingHelperBuildTask *buildTask = new DebuggingHelperBuildTask(version, tools); + QString toolChainId = m_debuggingHelperUi->toolChainComboBox->itemData( + m_debuggingHelperUi->toolChainComboBox->currentIndex()).toString(); + ProjectExplorer::ToolChainManager *tcMgr = ProjectExplorer::ToolChainManager::instance(); + ProjectExplorer::ToolChain *toolChain = tcMgr->findToolChain(toolChainId); + if (!toolChain) + return; + + DebuggingHelperBuildTask *buildTask = new DebuggingHelperBuildTask(version, toolChain, tools); // Don't open General Messages pane with errors buildTask->showOutputOnError(false); connect(buildTask, SIGNAL(finished(int,QString,DebuggingHelperBuildTask::Tools)), @@ -610,7 +637,9 @@ void QtOptionsPageWidget::updateDebuggingHelperUi() BaseQtVersion *version = currentVersion(); const QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem(); - if (!version || !version->isValid()) { + QList<ProjectExplorer::ToolChain*> toolchains = toolChains(currentVersion()); + + if (!version || !version->isValid() || toolchains.isEmpty()) { m_ui->debuggingHelperWidget->setVisible(false); } else { const DebuggingHelperBuildTask::Tools availableTools = DebuggingHelperBuildTask::availableTools(version); @@ -755,6 +784,21 @@ void QtOptionsPageWidget::updateDebuggingHelperUi() m_debuggingHelperUi->qmlObserverBuildButton->setEnabled(canBuildQmlObserver & !isBuildingQmlObserver); + QList<ProjectExplorer::ToolChain*> toolchains = toolChains(currentVersion()); + QString selectedToolChainId = m_debuggingHelperUi->toolChainComboBox->itemData( + m_debuggingHelperUi->toolChainComboBox->currentIndex()).toString(); + m_debuggingHelperUi->toolChainComboBox->clear(); + for (int i = 0; i < toolchains.size(); ++i) { + if (!toolchains.at(i)->isValid()) + continue; + if (i >= m_debuggingHelperUi->toolChainComboBox->count()) { + m_debuggingHelperUi->toolChainComboBox->insertItem(i, toolchains.at(i)->displayName(), + toolchains.at(i)->id()); + } + if (toolchains.at(i)->id() == selectedToolChainId) + m_debuggingHelperUi->toolChainComboBox->setCurrentIndex(i); + } + const bool hasLog = currentItem && !currentItem->data(0, BuildLogRole).toString().isEmpty(); m_debuggingHelperUi->showLogButton->setEnabled(hasLog); diff --git a/src/plugins/qtsupport/qtoptionspage.h b/src/plugins/qtsupport/qtoptionspage.h index 64bc3ba08c..82d38b18b0 100644 --- a/src/plugins/qtsupport/qtoptionspage.h +++ b/src/plugins/qtsupport/qtoptionspage.h @@ -43,6 +43,10 @@ QT_BEGIN_NAMESPACE class QTreeWidgetItem; QT_END_NAMESPACE +namespace ProjectExplorer { +class ToolChain; +} + namespace QtSupport { class BaseQtVersion; @@ -120,6 +124,7 @@ private: QIcon icon; }; ValidityInfo validInformation(const BaseQtVersion *version); + QList<ProjectExplorer::ToolChain*> toolChains(const BaseQtVersion *version); }; class QtOptionsPage : public Core::IOptionsPage |