Commit 3fef120d authored by Kai Koehne's avatar Kai Koehne

QmlJSDebug: Move qmljsdebug into a static library

Reviewed-by: dt
parent 45187a15
......@@ -43,7 +43,7 @@
# define QMLJSDEBUGGER_EXPORT
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
# else
# define QMLJSDEBUGGER_EXPORT Q_DECL_IMPORT
# define QMLJSDEBUGGER_EXPORT
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
#endif
......
# This file is part of Qt Creator
# It enables debugging of Qt Quick applications
QT += declarative script
QT += declarative
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD $$PWD/include editor $$PWD/qt-private
contains(CONFIG, dll) {
DEFINES += BUILD_QMLJSDEBUGGER_LIB
} else {
DEFINES += BUILD_QMLJSDEBUGGER_STATIC_LIB
}
!contains(DEFINES, NO_JSDEBUGGER) {
HEADERS += \
include/jsdebuggeragent.h \
include/qmljsdebugger_global.h
SOURCES += \
jsdebuggeragent.cpp
}
!contains(DEFINES, NO_QMLOBSERVER) {
HEADERS += \
include/qdeclarativeviewobserver.h \
include/qdeclarativeobserverservice.h \
include/qmlobserverconstants.h \
editor/abstractliveedittool.h \
editor/liveselectiontool.h \
editor/livelayeritem.h \
editor/livesingleselectionmanipulator.h \
editor/liverubberbandselectionmanipulator.h \
editor/liveselectionrectangle.h \
editor/liveselectionindicator.h \
editor/boundingrecthighlighter.h \
editor/subcomponenteditortool.h \
editor/subcomponentmasklayeritem.h \
editor/zoomtool.h \
editor/colorpickertool.h \
editor/qmltoolbar.h \
editor/toolbarcolorbox.h \
qdeclarativeviewobserver_p.h
SOURCES += \
qdeclarativeviewobserver.cpp \
qdeclarativeobserverservice.cpp \
editor/abstractliveedittool.cpp \
editor/liveselectiontool.cpp \
editor/livelayeritem.cpp \
editor/livesingleselectionmanipulator.cpp \
editor/liverubberbandselectionmanipulator.cpp \
editor/liveselectionrectangle.cpp \
editor/liveselectionindicator.cpp \
editor/boundingrecthighlighter.cpp \
editor/subcomponenteditortool.cpp \
editor/subcomponentmasklayeritem.cpp \
editor/zoomtool.cpp \
editor/colorpickertool.cpp \
editor/qmltoolbar.cpp \
editor/toolbarcolorbox.cpp
RESOURCES += editor/editor.qrc
}
OTHER_FILES += qmljsdebugger.pri
LIBS += -L$$PWD -lQmlJSDebugger
......@@ -2,10 +2,67 @@
# It enables debugging of Qt Quick applications
TEMPLATE = lib
CONFIG+=dll
TARGET = QmlJSDebugger
CONFIG += staticlib
QT += declarative script
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD $$PWD/include editor $$PWD/qt-private
DEFINES += BUILD_QMLJSDEBUGGER_STATIC_LIB
unix:QMAKE_CXXFLAGS_DEBUG += -O3
include(../../../../src/qtcreatorlibrary.pri)
include(qmljsdebugger-lib.pri)
DESTDIR = $$PWD
TARGET=qmljsdebugger
CONFIG(debug, debug|release) {
windows:TARGET=qmljsdebuggerd
}
# JS Debugging
HEADERS += \
include/jsdebuggeragent.h \
include/qmljsdebugger_global.h
SOURCES += \
jsdebuggeragent.cpp
HEADERS += \
include/qdeclarativeviewobserver.h \
include/qdeclarativeobserverservice.h \
include/qmlobserverconstants.h \
editor/abstractliveedittool.h \
editor/liveselectiontool.h \
editor/livelayeritem.h \
editor/livesingleselectionmanipulator.h \
editor/liverubberbandselectionmanipulator.h \
editor/liveselectionrectangle.h \
editor/liveselectionindicator.h \
editor/boundingrecthighlighter.h \
editor/subcomponenteditortool.h \
editor/subcomponentmasklayeritem.h \
editor/zoomtool.h \
editor/colorpickertool.h \
editor/qmltoolbar.h \
editor/toolbarcolorbox.h \
qdeclarativeviewobserver_p.h
SOURCES += \
qdeclarativeviewobserver.cpp \
qdeclarativeobserverservice.cpp \
editor/abstractliveedittool.cpp \
editor/liveselectiontool.cpp \
editor/livelayeritem.cpp \
editor/livesingleselectionmanipulator.cpp \
editor/liverubberbandselectionmanipulator.cpp \
editor/liveselectionrectangle.cpp \
editor/liveselectionindicator.cpp \
editor/boundingrecthighlighter.cpp \
editor/subcomponenteditortool.cpp \
editor/subcomponentmasklayeritem.cpp \
editor/zoomtool.cpp \
editor/colorpickertool.cpp \
editor/qmltoolbar.cpp \
editor/toolbarcolorbox.cpp
RESOURCES += editor/editor.qrc
OTHER_FILES += qmljsdebugger.pri
......@@ -2,20 +2,17 @@ TEMPLATE = app
CONFIG += qt uic
### FIXME: only debug plugins are now supported.
CONFIG -= release
CONFIG += debug
include(qml.pri)
SOURCES += main.cpp
exists($$PWD/qmljsdebugger/qmljsdebugger-lib.pri) {
# for building helpers within QT_INSTALL_DATA, we deploy the lib inside the observer directory.
include($$PWD/qmljsdebugger/qmljsdebugger-lib.pri)
} else {
include($$PWD/../qmljsdebugger/qmljsdebugger-lib.pri)
# INCLUDEPATH and library path has to be extended by qmake call
DEBUGLIB=qmljsdebugger
CONFIG(debug, debug|release) {
windows:DEBUGLIB = qmljsdebuggerd
}
LIBS+=-l$$DEBUGLIB
#INCLUDEPATH += ../../include/QtDeclarative
#INCLUDEPATH += ../../src/declarative/util
......
......@@ -10,49 +10,9 @@ SOURCES += $$PWD/qmlapplicationviewer.cpp
HEADERS += $$PWD/qmlapplicationviewer.h
INCLUDEPATH += $$PWD
defineTest(minQtVersion) {
maj = $$1
min = $$2
patch = $$3
isEqual(QT_MAJOR_VERSION, $$maj) {
isEqual(QT_MINOR_VERSION, $$min) {
isEqual(QT_PATCH_VERSION, $$patch) {
return(true)
}
greaterThan(QT_PATCH_VERSION, $$patch) {
return(true)
}
}
greaterThan(QT_MINOR_VERSION, $$min) {
return(true)
}
}
return(false)
}
contains(DEFINES, QMLJSDEBUGGER) {
CONFIG(debug, debug|release) {
!minQtVersion(4, 7, 1) {
warning()
warning("Disabling QML debugging:")
warning()
warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.")
warning("This library requires Qt 4.7.1 or newer.")
warning()
DEFINES -= QMLJSDEBUGGER
} else:isEmpty(QMLJSDEBUGGER_PATH) {
warning()
warning("Disabling QML debugging:")
warning()
warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.")
warning("Please specify its location on the qmake command line, eg")
warning(" qmake -r QMLJSDEBUGGER_PATH=$CREATORDIR/share/qtcreator/qmljsdebugger")
warning()
DEFINES -= QMLJSDEBUGGER
} else {
include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
}
} else {
DEFINES -= QMLJSDEBUGGER
}
# Include JS debugger library if QMLJSDEBUGGER_PATH is set
!isEmpty(QMLJSDEBUGGER_PATH) {
include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri)
} else {
DEFINES -= QMLJSDEBUGGER
}
......@@ -255,7 +255,8 @@ bool BuildableHelperLibrary::buildHelper(const QString &helperName, const QStrin
const QString &directory, const QString &makeCommand,
const QString &qmakeCommand, const QString &mkspec,
const Utils::Environment &env, const QString &targetMode,
QString *output, QString *errorMessage)
const QStringList &qmakeArguments, QString *output,
QString *errorMessage)
{
const QChar newline = QLatin1Char('\n');
// Setup process
......@@ -284,13 +285,14 @@ bool BuildableHelperLibrary::buildHelper(const QString &helperName, const QStrin
output->append(newline);
output->append(QCoreApplication::translate("ProjectExplorer::BuildableHelperLibrary", "Running %1 ...\n").arg(qmakeCommand));
QStringList qMakeArgs;
QStringList qmakeArgs;
if (!targetMode.isEmpty())
qMakeArgs << targetMode;
qmakeArgs << targetMode;
if (!mkspec.isEmpty())
qMakeArgs << QLatin1String("-spec") << mkspec;
qMakeArgs << proFilename;
if (!runBuildProcess(proc, qmakeCommand, qMakeArgs, 30000, false, output, errorMessage))
qmakeArgs << QLatin1String("-spec") << mkspec;
qmakeArgs << proFilename;
qmakeArgs << qmakeArguments;
if (!runBuildProcess(proc, qmakeCommand, qmakeArgs, 30000, false, output, errorMessage))
return false;
output->append(newline);
if (makeFullPath.isEmpty()) {
......
......@@ -70,7 +70,8 @@ public:
const QString &directory, const QString &makeCommand,
const QString &qmakeCommand, const QString &mkspec,
const Utils::Environment &env, const QString &targetMode,
QString *output, QString *errorMessage);
const QStringList &qmakeArguments, QString *output,
QString *errorMessage);
static bool getHelperFileInfoFor(const QStringList &validBinaryFilenames,
const QString &directory, QFileInfo* info);
......
......@@ -58,6 +58,8 @@ DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
m_debugServerPortLabel->setBuddy(m_debugServerPort);
m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\"qthelp://com.nokia.qtcreator/doc/creator-qml-debugging.html\">What are the prerequisites?</a>"));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPort, SLOT(setEnabled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPortLabel, SLOT(setEnabled(bool)));
connect(m_debugServerPort, SIGNAL(valueChanged(int)), this, SLOT(onDebugServerPortChanged(int)));
......@@ -67,6 +69,7 @@ DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
qmlLayout->addWidget(m_useQmlDebugger);
qmlLayout->addWidget(m_debugServerPortLabel);
qmlLayout->addWidget(m_debugServerPort);
qmlLayout->addWidget(m_qmlDebuggerInfoLabel);
qmlLayout->addStretch();
QVBoxLayout *layout = new QVBoxLayout;
......
......@@ -73,6 +73,7 @@ private:
QCheckBox *m_useQmlDebugger;
QSpinBox *m_debugServerPort;
QLabel *m_debugServerPortLabel;
QLabel *m_qmlDebuggerInfoLabel;
};
} // namespace Utils
......
......@@ -125,9 +125,10 @@ QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
bool DebuggingHelperLibrary::build(const QString &directory, const QString &makeCommand,
const QString &qmakeCommand, const QString &mkspec,
const Utils::Environment &env, const QString &targetMode,
QString *output, QString *errorMessage)
const QStringList &qmakeArguments, QString *output,
QString *errorMessage)
{
return buildHelper(QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
"GDB helper"), QLatin1String("gdbmacros.pro"), directory,
makeCommand, qmakeCommand, mkspec, env, targetMode, output, errorMessage);
makeCommand, qmakeCommand, mkspec, env, targetMode, qmakeArguments, output, errorMessage);
}
......@@ -54,7 +54,7 @@ public:
static bool build(const QString &directory, const QString &makeCommand,
const QString &qmakeCommand, const QString &mkspec,
const Utils::Environment &env, const QString &targetMode,
QString *output, QString *errorMessage);
const QStringList &qmakeArguments, QString *output, QString *errorMessage);
// Copy the source files to a target location and return the chosen target location.
static QString copy(const QString &qtInstallData, QString *errorMessage);
......
......@@ -68,7 +68,7 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="qmlObserverLabel">
<property name="toolTip">
<string>A modified version of qmlviewer with support for QML/JS debugging.</string>
......@@ -78,14 +78,14 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QLabel" name="qmlObserverStatus">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -112,13 +112,47 @@
</property>
</widget>
</item>
<item row="2" column="4">
<item row="3" column="4">
<widget class="QPushButton" name="qmlObserverBuildButton">
<property name="text">
<string>Build</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="qmlDebuggingLibLabel">
<property name="text">
<string>Qml Debugging Library:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="qmlDebuggingLibStatus">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="qmlDebuggingLibBuildButton">
<property name="text">
<string>Build</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -34,6 +34,7 @@
#include "debugginghelperbuildtask.h"
#include "qmldumptool.h"
#include "qmlobservertool.h"
#include "qmldebugginglibrary.h"
#include <projectexplorer/debugginghelper.h>
#include <QtCore/QCoreApplication>
......@@ -97,14 +98,25 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(QtVersion *version, Tools too
m_tools = tools;
// Check the build requirements of the tools
if (m_tools & QmlDump) {
if (!QmlDumpTool::canBuild(version)) {
m_tools ^= QmlDump;
}
}
if (m_tools & QmlObserver) {
if (!QmlObserverTool::canBuild(version)) {
m_tools ^= QmlObserver;
} else {
m_tools |= QmlDebugging;
}
}
if (m_tools & QmlDebugging) {
if (!QmlDebuggingLibrary::canBuild(version)) {
m_tools ^= QmlDebugging;
m_tools &= ~QmlObserver; // remove observer if set
}
}
}
......@@ -143,7 +155,7 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
return false;
if (!DebuggingHelperLibrary::build(gdbHelperDirectory, m_makeCommand,
m_qmakeCommand, m_mkspec, m_environment,
m_target, output, &m_errorMessage))
m_target, QStringList(), output, &m_errorMessage))
return false;
}
future.setProgressValue(2);
......@@ -153,20 +165,37 @@ bool DebuggingHelperBuildTask::buildDebuggingHelper(QFutureInterface<void> &futu
if (qmlDumpToolDirectory.isEmpty())
return false;
if (!QmlDumpTool::build(qmlDumpToolDirectory, m_makeCommand, m_qmakeCommand, m_mkspec,
m_environment, m_target, output, &m_errorMessage))
m_environment, m_target, QStringList(), output, &m_errorMessage))
return false;
}
future.setProgressValue(3);
QString qmlDebuggingDirectory;
if (m_tools & QmlDebugging) {
qmlDebuggingDirectory = QmlDebuggingLibrary::copy(m_qtInstallData, &m_errorMessage);
if (qmlDebuggingDirectory.isEmpty())
return false;
if (!QmlDebuggingLibrary::build(qmlDebuggingDirectory, m_makeCommand,
m_qmakeCommand, m_mkspec, m_environment,
m_target, QStringList(), output, &m_errorMessage))
return false;
}
future.setProgressValue(4);
if (m_tools & QmlObserver) {
const QString qmlObserverDirectory = QmlObserverTool::copy(m_qtInstallData,
&m_errorMessage);
if (qmlObserverDirectory.isEmpty())
return false;
QStringList qmakeArgs;
qmakeArgs << QLatin1String("INCLUDEPATH+=") + qmlDebuggingDirectory + "/include";
qmakeArgs << QLatin1String("LIBS+=-L") + qmlDebuggingDirectory;
if (!QmlObserverTool::build(qmlObserverDirectory, m_makeCommand, m_qmakeCommand, m_mkspec,
m_environment, m_target, output, &m_errorMessage))
m_environment, m_target, qmakeArgs, output, &m_errorMessage))
return false;
}
future.setProgressValue(4);
future.setProgressValue(5);
return true;
}
......@@ -47,9 +47,10 @@ class DebuggingHelperBuildTask : public QObject {
public:
enum DebuggingHelper {
GdbDebugging = 0x01,
QmlObserver = 0x02,
QmlDump = 0x04,
AllTools = GdbDebugging | QmlObserver | QmlDump
QmlDebugging = 0x02,
QmlObserver = 0x04,
QmlDump = 0x08,
AllTools = GdbDebugging | QmlDebugging | QmlObserver | QmlDump
};
Q_DECLARE_FLAGS(Tools, DebuggingHelper)
......
......@@ -42,15 +42,19 @@
#include "qt4projectmanager.h"
#include "qt4target.h"
#include "qtversionmanager.h"
#include "debugginghelperbuildtask.h"
#include <projectexplorer/buildsteplist.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <qtconcurrent/runextensions.h>
#include <QtCore/QtConcurrentRun>
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
......@@ -61,18 +65,21 @@ const char * const QMAKE_BS_ID("QtProjectManager.QMakeBuildStep");
const char * const QMAKE_ARGUMENTS_KEY("QtProjectManager.QMakeBuildStep.QMakeArguments");
const char * const QMAKE_FORCED_KEY("QtProjectManager.QMakeBuildStep.QMakeForced");
const char * const QMAKE_QMLDEBUGLIB_KEY("QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary");
}
QMakeStep::QMakeStep(BuildStepList *bsl) :
AbstractProcessStep(bsl, QLatin1String(QMAKE_BS_ID)),
m_forced(false)
m_forced(false),
m_linkQmlDebuggingLibrary(false)
{
ctor();
}
QMakeStep::QMakeStep(BuildStepList *bsl, const QString &id) :
AbstractProcessStep(bsl, id),
m_forced(false)
m_forced(false),
m_linkQmlDebuggingLibrary(false)
{
ctor();
}
......@@ -80,7 +87,8 @@ QMakeStep::QMakeStep(BuildStepList *bsl, const QString &id) :
QMakeStep::QMakeStep(BuildStepList *bsl, QMakeStep *bs) :
AbstractProcessStep(bsl, bs),
m_forced(bs->m_forced),
m_userArgs(bs->m_userArgs)
m_userArgs(bs->m_userArgs),
m_linkQmlDebuggingLibrary(bs->m_linkQmlDebuggingLibrary)
{
ctor();
}
......@@ -166,9 +174,15 @@ QStringList QMakeStep::moreArguments()
<< QLatin1String("RCC_DIR=rcc");
}
// Do not turn debugger path into native path separators: Qmake does not like that!
arguments << QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH) + QLatin1Char('=') +
Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger");
if (m_linkQmlDebuggingLibrary
&& !bc->qtVersion()->qmlDebuggingHelperLibrary(true).isEmpty()) {
// Do not turn debugger path into native path separators: Qmake does not like that!
const QString debuggingHelperPath
= QFileInfo(bc->qtVersion()->qmlDebuggingHelperLibrary(true)).dir().path();
arguments << QLatin1String(Constants::QMAKEVAR_QMLJSDEBUGGER_PATH)
+ QLatin1Char('=') + debuggingHelperPath;
}
return arguments;
}
......@@ -313,6 +327,57 @@ void QMakeStep::setUserArguments(const QString &arguments)
qt4BuildConfiguration()->emitProFileEvaluteNeeded();
}
bool QMakeStep::isQmlDebuggingLibrarySupported(QString *reason) const
{
if (qt4BuildConfiguration()->qtVersion()->hasQmlDebuggingLibrary())
return true;
int major, minor, patch;
if (!qt4BuildConfiguration()->qtVersion()->versionNumbers(&major, &minor, &patch)) {
if (reason)
*reason = tr("Invalid Qt version.");
return false;
}
// only support 4.7.1 onwards
bool compatibleQt = false;
if (major == 4) {
if (minor == 7) {
if (patch >= 1)
compatibleQt = true;
} else if (minor > 7)
compatibleQt = true;
}
if (!compatibleQt) {
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
{
return m_linkQmlDebuggingLibrary;
}
void QMakeStep::setLinkQmlDebuggingLibrary(bool enable)
{
if (m_linkQmlDebuggingLibrary == enable)
return;