Commit d943015c authored by Kai Koehne's avatar Kai Koehne Committed by Daniel Teske

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/1978Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 8d5b3677
......@@ -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);
}
......
......@@ -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);
......
......@@ -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();
......
......@@ -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">
......@@ -163,8 +163,38 @@
</item>
</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">
......
......@@ -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
......
......@@ -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);
......
......@@ -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");
......
......@@ -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:
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment