aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2016-10-17 12:20:01 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2016-10-20 15:33:38 +0000
commitd07c24c701963ac0eaf1e7fb1774efcf2ee4dee3 (patch)
treeba12bff89306ad9e13f110b182a7c2b272c26303
parent91242e37603bab2c2adcfbc34fd9731b668ae6f6 (diff)
Add support for the QtScxml module
[ChangeLog] Added support for QtScxml module. Change-Id: I1ad8d51a3d9532d4a24270e4cc13f26f51620b07 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r--doc/reference/modules/qt-modules.qdoc52
-rw-r--r--src/lib/qtprofilesetup/qtprofilesetup.cpp2
-rw-r--r--src/lib/qtprofilesetup/templates.qrc1
-rw-r--r--src/lib/qtprofilesetup/templates/scxml.qbs68
-rw-r--r--tests/auto/blackbox/testdata/qtscxml/dummystatemachine.scxml3
-rw-r--r--tests/auto/blackbox/testdata/qtscxml/main.cpp15
-rw-r--r--tests/auto/blackbox/testdata/qtscxml/qtscxml.qbs52
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp10
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
9 files changed, 204 insertions, 0 deletions
diff --git a/doc/reference/modules/qt-modules.qdoc b/doc/reference/modules/qt-modules.qdoc
index f0e2c8954..d9704b8d0 100644
--- a/doc/reference/modules/qt-modules.qdoc
+++ b/doc/reference/modules/qt-modules.qdoc
@@ -153,6 +153,14 @@
\li Qt Script
\li
\row
+ \li scxml
+ \li Qt Scxml
+ \li For more information on the properties you can specify, see
+ \l{scxml Properties}.
+
+ For more information on the relevant file tags, see
+ \l {scxml File Tags}.
+ \row
\li sql
\li Qt SQL
\li
@@ -452,6 +460,33 @@
\endtable
+ \section2 scxml Properties
+
+ \table
+ \header
+ \li Property
+ \li Type
+ \li Default
+ \li Description
+ \row
+ \li className
+ \li \c{string}
+ \li \c undefined
+ \li The class name of the generated state machine. By default, the compiler will use the
+ \c name attribute of the input file's \c{<scxml>} tag.
+ \row
+ \li namespace
+ \li \c{string}
+ \li \c undefined
+ \li The C++ namespace in which to put the generated class. By default, the compiler will
+ place the class in the global namespace.
+ \row
+ \li qscxmlcName
+ \li \c{string}
+ \li \c{"qscxmlc"}
+ \li The base name of the Qt SCXML compiler. Set this if your system uses a different name.
+ \endtable
+
\section1 Relevant File Tags
The following sections describe the file tags that are relevant for the Qt
@@ -559,4 +594,21 @@
\li 1.0
\li Source files with this tag serve as inputs to the rule running the \c uic tool.
\endtable
+
+ \section2 scxml File Tags
+
+ \table
+ \header
+ \li Tag
+ \li Auto-tagged File Names
+ \li Since
+ \li Description
+ \row
+ \li \c{"qt.scxml.compilable"}
+ \li -
+ \li 1.7
+ \li Source files with this tag serve as inputs to the rule running the Qt SCXML compiler,
+ which will create a C++ class representing a state machine.
+ \endtable
+
*/
diff --git a/src/lib/qtprofilesetup/qtprofilesetup.cpp b/src/lib/qtprofilesetup/qtprofilesetup.cpp
index ca45bfa86..23aa658af 100644
--- a/src/lib/qtprofilesetup/qtprofilesetup.cpp
+++ b/src/lib/qtprofilesetup/qtprofilesetup.cpp
@@ -222,6 +222,8 @@ static void createModules(Profile &profile, Settings *settings,
&allFiles);
} else if (module.qbsName == QLatin1String("gui")) {
moduleTemplateFileName = QLatin1String("gui.qbs");
+ } else if (module.qbsName == QLatin1String("scxml")) {
+ moduleTemplateFileName = QLatin1String("scxml.qbs");
} else if (module.qbsName == QLatin1String("dbus")) {
moduleTemplateFileName = QLatin1String("dbus.qbs");
copyTemplateFile(QLatin1String("dbus.js"), qbsQtModuleDir, profile, qtEnvironment,
diff --git a/src/lib/qtprofilesetup/templates.qrc b/src/lib/qtprofilesetup/templates.qrc
index 257e89a54..bcbf2bd67 100644
--- a/src/lib/qtprofilesetup/templates.qrc
+++ b/src/lib/qtprofilesetup/templates.qrc
@@ -11,5 +11,6 @@
<file>templates/QtPlugin.qbs</file>
<file>templates/dbus.js</file>
<file>templates/dbus.qbs</file>
+ <file>templates/scxml.qbs</file>
</qresource>
</RCC>
diff --git a/src/lib/qtprofilesetup/templates/scxml.qbs b/src/lib/qtprofilesetup/templates/scxml.qbs
new file mode 100644
index 000000000..206d914a2
--- /dev/null
+++ b/src/lib/qtprofilesetup/templates/scxml.qbs
@@ -0,0 +1,68 @@
+import qbs 1.0
+import qbs.FileInfo
+import "../QtModule.qbs" as QtModule
+
+QtModule {
+ qtModuleName: "Scxml"
+
+ property string qscxmlcName: "qscxmlc"
+ property string className
+ property string namespace
+
+ Rule {
+ inputs: ["qt.scxml.compilable"]
+
+ Artifact {
+ filePath: FileInfo.joinPaths(product.moduleProperty("Qt.core", "generatedHeadersDir"),
+ input.baseName + ".h")
+ fileTags: ["hpp", "unmocable"]
+ }
+ Artifact {
+ filePath: input.baseName + ".cpp"
+ fileTags: ["cpp"]
+ }
+
+ prepare: {
+ var compilerName = product.moduleProperty("Qt.scxml", "qscxmlcName");
+ var compilerPath = FileInfo.joinPaths(input.moduleProperty("Qt.core", "binPath"),
+ compilerName);
+ var args = ["--header", outputs["hpp"][0].filePath,
+ "--impl", outputs["cpp"][0].filePath];
+ var cxx98 = input.moduleProperty("cpp", "cxxLanguageVersion") === "c++98";
+ if (cxx98)
+ args.push("-no-c++11");
+ var className = input.moduleProperty("Qt.scxml", "className");
+ if (className)
+ args.push("--classname", className);
+ var namespace = input.moduleProperty("Qt.scxml", "namespace");
+ if (namespace)
+ args.push("--namespace", namespace);
+ args.push(input.filePath);
+ var cmd = new Command(compilerPath, args);
+ cmd.description = "compiling " + input.fileName;
+ cmd.highlight = "codegen";
+ return [cmd];
+ }
+ }
+
+ staticLibsDebug: @staticLibsDebug@
+ staticLibsRelease: @staticLibsRelease@
+ dynamicLibsDebug: @dynamicLibsDebug@
+ dynamicLibsRelease: @dynamicLibsRelease@
+ linkerFlagsDebug: @linkerFlagsDebug@
+ linkerFlagsRelease: @linkerFlagsRelease@
+ frameworksDebug: @frameworksDebug@
+ frameworksRelease: @frameworksRelease@
+ frameworkPathsDebug: @frameworkPathsDebug@
+ frameworkPathsRelease: @frameworkPathsRelease@
+ libNameForLinkerDebug: @libNameForLinkerDebug@
+ libNameForLinkerRelease: @libNameForLinkerRelease@
+ libFilePathDebug: @libFilePathDebug@
+ libFilePathRelease: @libFilePathRelease@
+
+ cpp.defines: @defines@
+ cpp.includePaths: @includes@
+ cpp.libraryPaths: @libraryPaths@
+
+ @special_properties@
+}
diff --git a/tests/auto/blackbox/testdata/qtscxml/dummystatemachine.scxml b/tests/auto/blackbox/testdata/qtscxml/dummystatemachine.scxml
new file mode 100644
index 000000000..6c751866f
--- /dev/null
+++ b/tests/auto/blackbox/testdata/qtscxml/dummystatemachine.scxml
@@ -0,0 +1,3 @@
+<?xml version="1.0" ?>
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="qbs_test_machine">
+</scxml>
diff --git a/tests/auto/blackbox/testdata/qtscxml/main.cpp b/tests/auto/blackbox/testdata/qtscxml/main.cpp
new file mode 100644
index 000000000..c9a7d7741
--- /dev/null
+++ b/tests/auto/blackbox/testdata/qtscxml/main.cpp
@@ -0,0 +1,15 @@
+#ifdef HAS_QTSCXML
+#include <dummystatemachine.h>
+#endif
+
+#include <iostream>
+
+int main()
+{
+#ifdef HAS_QTSCXML
+ QbsTest::QbsStateMachine machine;
+ std::cout << "state machine name: " << qPrintable(machine.name()) << std::endl;
+#else
+ std::cout << "QtScxml not present" << std::endl;
+#endif
+}
diff --git a/tests/auto/blackbox/testdata/qtscxml/qtscxml.qbs b/tests/auto/blackbox/testdata/qtscxml/qtscxml.qbs
new file mode 100644
index 000000000..af96b8594
--- /dev/null
+++ b/tests/auto/blackbox/testdata/qtscxml/qtscxml.qbs
@@ -0,0 +1,52 @@
+import qbs
+import qbs.FileInfo
+
+Project {
+ QtApplication {
+ name: "app"
+ Depends { name: "Qt.scxml"; required: false }
+
+ Properties {
+ condition: Qt.scxml.present
+ cpp.defines: ["HAS_QTSCXML"]
+ }
+
+ Qt.scxml.className: "QbsStateMachine"
+ Qt.scxml.namespace: "QbsTest"
+
+ files: ["main.cpp"]
+ Group {
+ files: ["dummystatemachine.scxml"]
+ fileTags: ["qt.scxml.compilable"]
+ }
+ }
+
+ Product {
+ name: "runner"
+ type: ["runner"]
+ Depends { name: "app" }
+ Rule {
+ inputsFromDependencies: ["application"]
+ Artifact {
+ filePath: "dummy"
+ fileTags: ["runner"]
+ }
+ prepare: {
+ var cmd = new Command(input.filePath);
+ cmd.description = "running " + input.filePath;
+ var pathVar;
+ var pathValue;
+ if (product.moduleProperty("qbs", "hostOS").contains("windows")) {
+ pathVar = "PATH";
+ pathValue = FileInfo.toWindowsSeparators(
+ input.moduleProperty("Qt.core", "binPath"));
+ } else {
+ pathVar = "LD_LIBRARY_PATH";
+ pathValue = input.moduleProperty("Qt.core", "libPath");
+ }
+ cmd.environment = [pathVar + '=' + pathValue];
+ return [cmd];
+ }
+ }
+ }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 4f41cd6ea..03c1df6b0 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2191,6 +2191,16 @@ void TestBlackbox::qtBug51237()
QCOMPARE(runQbs(params), 0);
}
+void TestBlackbox::qtScxml()
+{
+ QDir::setCurrent(testDataDir + "/qtscxml");
+ QCOMPARE(runQbs(), 0);
+ if (m_qbsStdout.contains("QtScxml not present"))
+ QSKIP("QtScxml module not present");
+ QVERIFY2(m_qbsStdout.contains("state machine name: qbs_test_machine"),
+ m_qbsStdout.constData());
+}
+
void TestBlackbox::dynamicMultiplexRule()
{
const QString testDir = testDataDir + "/dynamicMultiplexRule";
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 182221b78..c7a344e60 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -146,6 +146,7 @@ private slots:
void qmlDebugging();
void qobjectInObjectiveCpp();
void qtBug51237();
+ void qtScxml();
void radAfterIncompleteBuild();
void radAfterIncompleteBuild_data();
void recursiveRenaming();