diff options
author | Dominik Holland <dominik.holland@qt.io> | 2019-10-07 16:38:48 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2019-10-29 17:26:28 +0100 |
commit | 25ba2939cace6bfbc065f3c8ea8cfe6d72eb5c17 (patch) | |
tree | d2475a26e8ed1332ee9abd83f70b17d05f52234a /tests | |
parent | 25b1d344d1f5b5fe791f9c9893adfc59a8db60e5 (diff) | |
download | qtivi-25ba2939cace6bfbc065f3c8ea8cfe6d72eb5c17.tar.gz |
ivigenerator: Add support to import other modules
When importing another module from within a QFace file, the
generator now searches within the QFace import path. If this
module is found, the information is then used to generate
code that includes types from this module.
The QFace import path can be set in the autogenerator similar
to qmlscene by using the -I option; in qmake it can be set
using QFACE_IMPORT_PATH.
The generator makes sure to generate correct code, but the
developer still needs to setup the .pro files correctly to
add the imported module to the INCLUDEPATH and also link
to the generated library.
Fixes: AUTOSUITE-1158
Change-Id: I0e9fa714d4c893a4bf17c5f7db34c62d84932c94
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'tests')
12 files changed, 266 insertions, 1 deletions
diff --git a/tests/auto/core/ivigenerator/include-test.qface b/tests/auto/core/ivigenerator/include-test.qface new file mode 100644 index 0000000..dd13fe3 --- /dev/null +++ b/tests/auto/core/ivigenerator/include-test.qface @@ -0,0 +1,115 @@ +/** + * module + */ +module include.test 1.0 + +import Common 1.0 + +/** + * \brief the brief + * the description + * continues \l http://qt.io + */ +interface IncludeTester { + readonly string lastMessage; + int intValue; + var varValue; + @config_simulator: {minimum: 10.} + real floatValue1; + @config_simulator: {maximum: 10.} + real floatValue2; + string stringValue; + + model<NestedStruct> nestedStructModel; + model<NestedImportedStruct> nestedImportedStructModel; + list<int> intList; + list<Common.CommonStruct> commonStructList; + list<NestedImportedStruct> nestedImportedStructList; + TestEnum testEnum; + Common.CommonEnum commonEnum; + + string echo(string msg); + string id() const; + NestedStruct getNestedStruct(); + NestedImportedStruct getNestedImportedStruct(); + Common.CommonStruct getCommonStruct(); + void voidSlot(); + void voidSlot2(int param); + void timer(int interval); + Common.CommonFlag flagMethod(Common.CommonFlag testFlag); + Common.CommonEnum enumMethod(Common.CommonEnum testEnum); + + signal anotherChanged(NestedImportedStruct another); + signal foobar(string foo); + signal somethingHappened(); + signal newValueAvailable(var newValue); +} + +@config: { zoned: true } +interface IncludeTesterZoned { + readonly string lastMessage; + int intValue; + var varValue; + @config_simulator: {minimum: 10.} + real floatValue1; + @config_simulator: {maximum: 10.} + real floatValue2; + string stringValue; + + model<NestedStruct> nestedStructModel; + model<NestedImportedStruct> nestedImportedStructModel; + list<int> intList; + list<Common.CommonStruct> commonStructList; + list<NestedImportedStruct> nestedImportedStructList; + TestEnum testEnum; + Common.CommonEnum commonEnum; + + string echo(string msg); + string id() const; + NestedStruct getNestedStruct(); + NestedImportedStruct getNestedImportedStruct(); + Common.CommonStruct getCommonStruct(); + void voidSlot(); + void voidSlot2(int param); + void timer(int interval); + Common.CommonFlag flagMethod(Common.CommonFlag testFlag); + Common.CommonEnum enumMethod(Common.CommonEnum testEnum); + + signal anotherChanged(NestedImportedStruct another); + signal foobar(string foo); + signal somethingHappened(); + signal newValueAvailable(var newValue); +} + +/** + * \brief A TestFlag + */ +flag TestFlag { + /** + * \brief The first value + */ + TestFlagValue = 1, + /** + * \brief The second value + */ + TestFlagValue = 2, +} + +enum TestEnum { + FirstEnumValue = 1, + SecondEnumValue = 2 +} + +struct NestedStruct { + AnotherStruct anotherStruct; + TestEnum testEnum; +} + +struct AnotherStruct { + int justANumber; +} + +struct NestedImportedStruct { + Common.CommonStruct commonStruct; + TestFlag testFlag; +} diff --git a/tests/auto/core/ivigenerator/ivigenerator.pro b/tests/auto/core/ivigenerator/ivigenerator.pro index 00f5307..26f1401 100644 --- a/tests/auto/core/ivigenerator/ivigenerator.pro +++ b/tests/auto/core/ivigenerator/ivigenerator.pro @@ -6,4 +6,5 @@ SUBDIRS = projects \ OTHER_FILES = org.example.echo.qface \ org.example.echo.yaml \ org.example.echo.noannotation.qface \ - no-private.yaml + no-private.yaml \ + include-test.qface \ diff --git a/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro new file mode 100644 index 0000000..ce0da0f --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro @@ -0,0 +1,16 @@ +TEMPLATE=lib +TARGET = $$qtLibraryTarget(include_test_qtro) +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) +DESTDIR = ../qtivi + +CONFIG += warn_off ivigenerator plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +PLUGIN_TYPE = qtivi +PLUGIN_CLASS_NAME = IncludeTestPlugin + +QT += core ivicore + +QFACE_FORMAT = backend_qtro +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..819898e --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro @@ -0,0 +1,16 @@ +TEMPLATE=lib +TARGET = $$qtLibraryTarget(include_test_simulator) +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) +DESTDIR = ../qtivi + +CONFIG += warn_off ivigenerator plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +PLUGIN_TYPE = qtivi +PLUGIN_CLASS_NAME = IncludeTestPlugin + +QT += core ivicore + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/common/common.pro b/tests/auto/core/ivigenerator/projects/include-test/common/common.pro new file mode 100644 index 0000000..306669a --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/common/common.pro @@ -0,0 +1,14 @@ +TEMPLATE=lib +TARGET= $$qtLibraryTarget(include_test_common) +DESTDIR = ../ + +CONFIG += ivigenerator + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_COMMON_LIB + +macos: QMAKE_SONAME_PREFIX = @rpath + +QFACE_SOURCES = "../../../qface imports/common.qface" + diff --git a/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro b/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro new file mode 100644 index 0000000..e287e47 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro @@ -0,0 +1,17 @@ +TEMPLATE=lib +TARGET= $$qtLibraryTarget(include_test_frontend) +DESTDIR = ../ + +CONFIG += ivigenerator + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_INCLUDE_TEST_LIB +INCLUDEPATH += $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_common) + +macos: QMAKE_SONAME_PREFIX = @rpath + +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" + diff --git a/tests/auto/core/ivigenerator/projects/include-test/include-test.pro b/tests/auto/core/ivigenerator/projects/include-test/include-test.pro new file mode 100644 index 0000000..3febe98 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/include-test.pro @@ -0,0 +1,22 @@ +TEMPLATE = subdirs + +SUBDIRS = common \ + frontend \ + qmlplugin \ + backend_simulator \ + test \ + +frontend.depends = common +backend_simulator.depends = frontend +test.depends = frontend +qmlplugin.depends = frontend + +QT_FOR_CONFIG += ivicore + +qtConfig(remoteobjects) { + SUBDIRS += backend_qtro \ + simulation_server_qtro + + backend_qtro.depends = frontend + simulation_server_qtro.depends = frontend +} diff --git a/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro b/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro new file mode 100644 index 0000000..b0a45d8 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +QT = ivicore +CONFIG += c++11 plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" + +load(ivigenerator) diff --git a/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro b/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro new file mode 100644 index 0000000..2618076 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +TARGET = org-example-echo-qtro-simulation-server +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +DESTDIR = .. + +CONFIG += c++11 ivigenerator +CONFIG -= app_bundle + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common + +QT += qml quick core ivicore + +QFACE_FORMAT = server_qtro_simulator +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/test/test.pro b/tests/auto/core/ivigenerator/projects/include-test/test/test.pro new file mode 100644 index 0000000..6b7e344 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/test/test.pro @@ -0,0 +1,15 @@ +TARGET = tst_include +QMAKE_PROJECT_NAME = $$TARGET +DESTDIR = ../ + +QT += testlib core ivicore +CONFIG += c++11 ivigenerator testcase + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +QMAKE_RPATHDIR += $$OUT_PWD/.. + +QFACE_FORMAT = test +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/projects.pro b/tests/auto/core/ivigenerator/projects/projects.pro index bc349a5..eb8d2b7 100644 --- a/tests/auto/core/ivigenerator/projects/projects.pro +++ b/tests/auto/core/ivigenerator/projects/projects.pro @@ -5,6 +5,7 @@ QT_FOR_CONFIG += ivicore SUBDIRS = org-example-echo \ org-example-echo-noprivate \ org-example-echo-noannotation \ + include-test \ qtConfig(remoteobjects) { SUBDIRS += org-example-echo-qtro diff --git a/tests/auto/core/ivigenerator/qface imports/common.qface b/tests/auto/core/ivigenerator/qface imports/common.qface new file mode 100644 index 0000000..b9cee0c --- /dev/null +++ b/tests/auto/core/ivigenerator/qface imports/common.qface @@ -0,0 +1,20 @@ +module Common 1.0; + +struct CommonStruct { + string name + OtherCommonStruct otherStruct +} + +struct OtherCommonStruct { + bool checked +} + +enum CommonEnum { + CommonValue1, + CommonValue2 +} + +flag CommonFlag { + FlagValue1 = 1, + FlagValue2 = 2 +} |