From 67d9d69b97c8c2db54974850783d0d10292f63b5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 28 Jun 2018 11:07:18 +0200 Subject: Make the ECMAScript model a configurable feature Introducing this feature allows our users to slim down the module. Task-number: QTBUG-61960 Change-Id: I94215fd3c6dee9766a5f7479bec0440cdfe85ac1 Reviewed-by: Simon Hausmann --- src/scxml/configure.json | 21 +++++++++++++++++++++ src/scxml/qscxmlcompiler.cpp | 1 - src/scxml/qscxmldatamodel.cpp | 4 ++++ src/scxml/qscxmlecmascriptdatamodel.h | 7 +++++++ src/scxml/qscxmlecmascriptplatformproperties_p.h | 2 ++ src/scxml/qscxmlglobals.h | 1 + src/scxml/scxml.pro | 18 +++++++++++++----- 7 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 src/scxml/configure.json (limited to 'src') diff --git a/src/scxml/configure.json b/src/scxml/configure.json new file mode 100644 index 0000000..288373d --- /dev/null +++ b/src/scxml/configure.json @@ -0,0 +1,21 @@ +{ + "module": "scxml", + + "features": { + "scxml-ecmascriptdatamodel": { + "label": "ECMAScript data model for QtScxml", + "purpose": "Enables the usage of ecmascript data models in SCXML state machines.", + "section": "SCXML", + "output": [ "publicFeature" ] + } + }, + + "summary": [ + { + "section": "Qt Scxml", + "entries": [ + "scxml-ecmascriptdatamodel" + ] + } + ] +} diff --git a/src/scxml/qscxmlcompiler.cpp b/src/scxml/qscxmlcompiler.cpp index 61ad030..e2e9b4c 100644 --- a/src/scxml/qscxmlcompiler.cpp +++ b/src/scxml/qscxmlcompiler.cpp @@ -47,7 +47,6 @@ #include #ifndef BUILD_QSCXMLC -#include "qscxmlecmascriptdatamodel.h" #include "qscxmlinvokableservice_p.h" #include "qscxmldatamodel_p.h" #include "qscxmlstatemachine_p.h" diff --git a/src/scxml/qscxmldatamodel.cpp b/src/scxml/qscxmldatamodel.cpp index 5f2ef2d..ab0ae7c 100644 --- a/src/scxml/qscxmldatamodel.cpp +++ b/src/scxml/qscxmldatamodel.cpp @@ -39,7 +39,9 @@ #include "qscxmldatamodel_p.h" #include "qscxmlnulldatamodel.h" +#if QT_CONFIG(scxml_ecmascriptdatamodel) #include "qscxmlecmascriptdatamodel.h" +#endif #include "qscxmlstatemachine_p.h" QT_BEGIN_NAMESPACE @@ -150,7 +152,9 @@ QScxmlDataModel *QScxmlDataModelPrivate::instantiateDataModel(DocumentModel::Scx dataModel = new QScxmlNullDataModel; break; case DocumentModel::Scxml::JSDataModel: +#if QT_CONFIG(scxml_ecmascriptdatamodel) dataModel = new QScxmlEcmaScriptDataModel; +#endif break; case DocumentModel::Scxml::CppDataModel: break; diff --git a/src/scxml/qscxmlecmascriptdatamodel.h b/src/scxml/qscxmlecmascriptdatamodel.h index 658df6d..16f29d4 100644 --- a/src/scxml/qscxmlecmascriptdatamodel.h +++ b/src/scxml/qscxmlecmascriptdatamodel.h @@ -40,9 +40,14 @@ #ifndef QSCXMLECMASCRIPTDATAMODEL_H #define QSCXMLECMASCRIPTDATAMODEL_H +#include #include QT_BEGIN_NAMESPACE + +// We cannot use QT_REQUIRE_CONFIG here, because the feature name contains a dash. +#if QT_CONFIG(scxml_ecmascriptdatamodel) + class QScxmlEcmaScriptDataModelPrivate; class Q_SCXML_EXPORT QScxmlEcmaScriptDataModel: public QScxmlDataModel { @@ -68,6 +73,8 @@ public: bool setScxmlProperty(const QString &name, const QVariant &value, const QString &context) override; }; +#endif // QT_CONFIG(scxml_ecmascriptdatamodel) + QT_END_NAMESPACE #endif // QSCXMLECMASCRIPTDATAMODEL_H diff --git a/src/scxml/qscxmlecmascriptplatformproperties_p.h b/src/scxml/qscxmlecmascriptplatformproperties_p.h index b751bda..e7b8a09 100644 --- a/src/scxml/qscxmlecmascriptplatformproperties_p.h +++ b/src/scxml/qscxmlecmascriptplatformproperties_p.h @@ -58,6 +58,8 @@ QT_FORWARD_DECLARE_CLASS(QJSEngine) QT_FORWARD_DECLARE_CLASS(QJSValue) +QT_REQUIRE_CONFIG(scxml_ecmascriptdatamodel); + QT_BEGIN_NAMESPACE class QScxmlStateMachine; diff --git a/src/scxml/qscxmlglobals.h b/src/scxml/qscxmlglobals.h index 8672aa1..da45a2b 100644 --- a/src/scxml/qscxmlglobals.h +++ b/src/scxml/qscxmlglobals.h @@ -40,6 +40,7 @@ #ifndef QSCXMLGLOBALS_H #define QSCXMLGLOBALS_H #include +#include QT_BEGIN_NAMESPACE diff --git a/src/scxml/scxml.pro b/src/scxml/scxml.pro index 1f5bc25..c3a6aff 100644 --- a/src/scxml/scxml.pro +++ b/src/scxml/scxml.pro @@ -1,5 +1,5 @@ TARGET = QtScxml -QT = core-private qml-private +QT = core-private MODULE_CONFIG += c++11 qscxmlc load(qt_module) @@ -17,8 +17,6 @@ HEADERS += \ qscxmlglobals.h \ qscxmlglobals_p.h \ qscxmlnulldatamodel.h \ - qscxmlecmascriptdatamodel.h \ - qscxmlecmascriptplatformproperties_p.h \ qscxmlexecutablecontent.h \ qscxmlexecutablecontent_p.h \ qscxmlevent.h \ @@ -38,8 +36,6 @@ SOURCES += \ qscxmlcompiler.cpp \ qscxmlstatemachine.cpp \ qscxmlnulldatamodel.cpp \ - qscxmlecmascriptdatamodel.cpp \ - qscxmlecmascriptplatformproperties.cpp \ qscxmlexecutablecontent.cpp \ qscxmlevent.cpp \ qscxmldatamodel.cpp \ @@ -49,6 +45,18 @@ SOURCES += \ qscxmltabledata.cpp \ qscxmlstatemachineinfo.cpp +qtConfig(scxml-ecmascriptdatamodel) { + QT += qml-private + + HEADERS += \ + qscxmlecmascriptdatamodel.h \ + qscxmlecmascriptplatformproperties_p.h + + SOURCES += \ + qscxmlecmascriptdatamodel.cpp \ + qscxmlecmascriptplatformproperties.cpp +} + FEATURES += ../../mkspecs/features/qscxmlc.prf features.files = $$FEATURES features.path = $$[QT_HOST_DATA]/mkspecs/features/ -- cgit v1.2.3