Commit b57fd371 authored by Tobias Hunger's avatar Tobias Hunger

Move qmldebugginghelper related code from Qt4PM to QtSupport

... so that it can be reused by the QbsPM

Change-Id: I79ee1aeaf66b07878e159ac9d4aecb657bdcb7ee
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 4929d65e
......@@ -41,17 +41,16 @@
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <qtsupport/debugginghelperbuildtask.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <qtsupport/debugginghelperbuildtask.h>
#include <utils/hostosinfo.h>
#include <utils/qtcprocess.h>
#include <QDir>
#include <utils/runextensions.h>
#include <QMessageBox>
using namespace Qt4ProjectManager;
......@@ -376,46 +375,6 @@ void QMakeStep::setUserArguments(const QString &arguments)
qt4BuildConfiguration()->emitProFileEvaluateNeeded();
}
bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const
{
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (!version) {
if (reason)
*reason = tr("No Qt version.");
return false;
}
if (!version->needsQmlDebuggingLibrary() || version->hasQmlDebuggingLibrary())
return true;
if (!version->qtAbis().isEmpty()) {
ProjectExplorer::Abi abi = version->qtAbis().first();
if (abi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor) {
if (reason)
reason->clear();
// *reason = tr("Qml debugging on device not yet supported.");
return false;
}
}
if (!version->isValid()) {
if (reason)
*reason = tr("Invalid Qt version.");
return false;
}
if (version->qtVersion() < QtSupport::QtVersionNumber(4, 7, 1)) {
if (reason)
*reason = tr("Requires Qt 4.7.1 or newer.");
return false;
}
if (reason)
*reason = tr("Library not available. <a href='compile'>Compile...</a>");
return false;
}
bool QMakeStep::linkQmlDebuggingLibrary() const
{
if (m_linkQmlDebuggingLibrary == DoLink)
......@@ -640,23 +599,8 @@ void QMakeStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked)
void QMakeStepConfigWidget::buildQmlDebuggingHelper()
{
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_step->target()->kit());
if (!version)
return;
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_step->target()->kit());
QtSupport::DebuggingHelperBuildTask *buildTask =
new QtSupport::DebuggingHelperBuildTask(version, tc,
QtSupport::DebuggingHelperBuildTask::QmlDebugging);
// pop up Application Output on error
buildTask->showOutputOnError(true);
QFuture<void> task = QtConcurrent::run(&QtSupport::DebuggingHelperBuildTask::run, buildTask);
const QString taskName = tr("Building helpers");
Core::ICore::progressManager()->addTask(task, taskName,
QLatin1String("Qt4ProjectManager::BuildHelpers"));
QtSupport::BaseQtVersion::buildDebuggingHelper(m_step->target()->kit(),
static_cast<int>(QtSupport::DebuggingHelperBuildTask::QmlDebugging));
}
void QMakeStepConfigWidget::updateSummaryLabel()
......@@ -675,14 +619,13 @@ void QMakeStepConfigWidget::updateSummaryLabel()
void QMakeStepConfigWidget::updateQmlDebuggingOption()
{
m_ui->qmlDebuggingLibraryCheckBox->setEnabled(m_step->isQmlDebuggingLibrarySupported());
m_ui->debuggingLibraryLabel->setText(tr("Enable QML debugging:"));
QString warningText;
bool supported = QtSupport::BaseQtVersion::isQmlDebuggingSupported(m_step->target()->kit(),
&warningText);
m_ui->qmlDebuggingLibraryCheckBox->setEnabled(supported);
m_ui->debuggingLibraryLabel->setText(tr("Enable QML debugging:"));
if (!m_step->isQmlDebuggingLibrarySupported(&warningText))
;
else if (m_step->linkQmlDebuggingLibrary())
if (supported && m_step->linkQmlDebuggingLibrary())
warningText = tr("Might make your application vulnerable. Only use in a safe environment.");
m_ui->qmlDebuggingWarningText->setText(warningText);
......
......@@ -108,7 +108,6 @@ public:
void setUserArguments(const QString &arguments);
bool linkQmlDebuggingLibrary() const;
void setLinkQmlDebuggingLibrary(bool enable);
bool isQmlDebuggingLibrarySupported(QString *reason = 0) const;
QVariantMap toMap() const;
......
......@@ -36,21 +36,27 @@
#include "qtversionmanager.h"
#include "profilereader.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <proparser/qmakevfs.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/headerpath.h>
#include <qtsupport/debugginghelper.h>
#include <qtsupport/debugginghelperbuildtask.h>
#include <qtsupport/qtsupportconstants.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <utils/synchronousprocess.h>
#include <QtConcurrent>
#include <QDir>
#include <QUrl>
#include <QFileInfo>
#include <QFuture>
#include <QCoreApplication>
#include <QProcess>
......@@ -1412,6 +1418,76 @@ FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<QString, QString> &ver
return mkspecFullPath;
}
bool BaseQtVersion::isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason)
{
QTC_ASSERT(k, return false);
BaseQtVersion *version = QtKitInformation::qtVersion(k);
if (!version) {
if (reason)
*reason = QCoreApplication::translate("BaseQtVersion", "No Qt version.");
return false;
}
return version->isQmlDebuggingSupported(reason);
}
bool BaseQtVersion::isQmlDebuggingSupported(QString *reason) const
{
if (!needsQmlDebuggingLibrary() || hasQmlDebuggingLibrary())
return true;
if (!qtAbis().isEmpty()) {
ProjectExplorer::Abi abi = qtAbis().first();
if (abi.osFlavor() == ProjectExplorer::Abi::MaemoLinuxFlavor) {
if (reason)
reason->clear();
// *reason = QCoreApplication::translate("BaseQtVersion", "Qml debugging on device not yet supported.");
return false;
}
}
if (!isValid()) {
if (reason)
*reason = QCoreApplication::translate("BaseQtVersion", "Invalid Qt version.");
return false;
}
if (qtVersion() < QtVersionNumber(4, 7, 1)) {
if (reason)
*reason = QCoreApplication::translate("BaseQtVersion", "Requires Qt 4.7.1 or newer.");
return false;
}
if (reason)
*reason = QCoreApplication::translate("BaseQtVersion", "Library not available. <a href='compile'>Compile...</a>");
return false;
}
void BaseQtVersion::buildDebuggingHelper(ProjectExplorer::Kit *k, int tools)
{
BaseQtVersion *version = QtKitInformation::qtVersion(k);
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
if (!k || !version || !tc)
return;
version->buildDebuggingHelper(tc, tools);
}
void BaseQtVersion::buildDebuggingHelper(ProjectExplorer::ToolChain *tc, int tools)
{
QTC_ASSERT(tc, return);
DebuggingHelperBuildTask *buildTask =
new DebuggingHelperBuildTask(this, tc, static_cast<DebuggingHelperBuildTask::Tools>(tools));
// pop up Application Output on error
buildTask->showOutputOnError(true);
QFuture<void> task = QtConcurrent::run(&QtSupport::DebuggingHelperBuildTask::run, buildTask);
const QString taskName = QCoreApplication::translate("BaseQtVersion", "Building helpers");
Core::ICore::progressManager()->addTask(task, taskName,
QLatin1String("Qt::BuildHelpers"));
}
FileName BaseQtVersion::qtCorePath(const QHash<QString,QString> &versionInfo, const QString &versionString)
{
QStringList dirs;
......
......@@ -184,6 +184,11 @@ public:
static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo);
static Utils::FileName mkspecFromVersionInfo(const QHash<QString, QString> &versionInfo);
static bool isQmlDebuggingSupported(ProjectExplorer::Kit *k, QString *reason = 0);
bool isQmlDebuggingSupported(QString *reason = 0) const;
static void buildDebuggingHelper(ProjectExplorer::Kit *k, int tools);
void buildDebuggingHelper(ProjectExplorer::ToolChain *tc, int tools);
virtual bool supportsBinaryDebuggingHelper() const;
virtual QString gdbDebuggingHelperLibrary() const;
virtual QString qmlDebuggingHelperLibrary(bool debugVersion) const;
......
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