summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2017-06-21 13:14:34 +0200
committerDominik Holland <dominik.holland@pelagicore.com>2017-07-17 11:19:17 +0000
commit6eb0036cf56f63b3f80ca35a34fb0e173f2ed54d (patch)
tree6ee631e2a61ae22f5ed1f57f72aa4fb8312fd36d
parent3205b6e8f57273096ae60d8f6fcdbe597c350393 (diff)
downloadqtivi-6eb0036cf56f63b3f80ca35a34fb0e173f2ed54d.tar.gz
Handle building modules properly
Extra steps are needed for syncqt to find the headers. After the generation of the frontend files, the headers are copied in the src folder in qtbase. When building a module, rather than using CONFIG += ivigenerator, simply define the required qface and module related variables and load(ivigenerator_qt_module) This also handles the QFACE_MODULE_NAME variable: the generator has a --module option which optionaly indicates the name of the Qt Module that is generated by the project. This is needed by the backend templates to know which include paths to use to find the frontend base interface class. This also changes the generated files so that the generated .pri has the same base name (in lower case) as the input qface file. And updates the generator version to 2.0 Change-Id: I9d2716255affcb5c6f319a6f23202ae3bb6c115c Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--mkspecs/features/ivigenerator.prf22
-rw-r--r--mkspecs/features/ivigenerator_qt_module.prf29
-rwxr-xr-xsrc/tools/ivigenerator/generate.py8
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator.yaml2
-rw-r--r--src/tools/ivigenerator/templates_control_panel.yaml2
-rw-r--r--src/tools/ivigenerator/templates_frontend.yaml2
-rw-r--r--src/tools/ivigenerator/templates_generation_validator.yaml2
7 files changed, 56 insertions, 11 deletions
diff --git a/mkspecs/features/ivigenerator.prf b/mkspecs/features/ivigenerator.prf
index fcd2177..7652375 100644
--- a/mkspecs/features/ivigenerator.prf
+++ b/mkspecs/features/ivigenerator.prf
@@ -1,5 +1,7 @@
# Custom compiler for qface:
#
+# If building a module, use load(ivigenerator_qt_module) instead
+#
# Example input:
# QFACE_SOURCES += my.foo.qface [required]
# QFACE_MODULE_NAME = my_module_name
@@ -25,7 +27,6 @@ QFACE_ABS_PWD = $$absolute_path($$QFACE_PWD, $$_PRO_FILE_PWD_)
QFACE_FILE = $$basename(QFACE_SOURCES)
QFACE_BASE_NAME = $$replace(QFACE_FILE, .qface, )
QFACE_YAML = $$QFACE_ABS_PWD/$${QFACE_BASE_NAME}.yaml
-isEmpty(QFACE_MODULE_NAME): QFACE_MODULE_NAME = $$QFACE_BASE_NAME
# Detect whether we are using the feature inside the qtivi repository
VIRTUALENV_PATH = $$[QT_HOST_BINS]/ivigenerator/qtivi_qface_virtualenv
@@ -54,11 +55,12 @@ else: ENV = LC_ALL="en_US.UTF-8"
# Although this could be extra_compiler it is a normal EXTRA_TARGET for a reason.
# In the debug_and_release configuration, we want to have the generator executed
# during the run of the meta Makefile to only generate the code once.
-PRI_NAME = $$replace(QFACE_MODULE_NAME, "\." , "-")
-PRI = $$QFACE_OUTPUT_DIR/$${PRI_NAME}.pri
+PRI = $$QFACE_OUTPUT_DIR/$$lower($${QFACE_BASE_NAME}).pri
+IVI_GENERATOR_OPTIONS = --format=$$QFACE_FORMAT
+!isEmpty(QFACE_MODULE_NAME): IVI_GENERATOR_OPTIONS += --module=$$QFACE_MODULE
qface_sources.target = $$relative_path($$PRI, $$OUT_PWD)
-qface_sources.commands = $$ENV $$shell_path($$IVI_GENERATOR) -f $$QFACE_FORMAT $$shell_path($$QFACE_ABS_PWD/$${QFACE_FILE}) $$shell_path($$QFACE_OUTPUT_DIR)
+qface_sources.commands = $$ENV $$shell_path($$IVI_GENERATOR) $$IVI_GENERATOR_OPTIONS $$shell_path($$QFACE_ABS_PWD/$${QFACE_FILE}) $$shell_path($$QFACE_OUTPUT_DIR)
qface_sources.depends = $$IVI_GENERATOR_PATH/generate.py
# Add all templates of the generator format as dependency
@@ -73,6 +75,13 @@ exists($$QFACE_YAML) {
OTHER_FILES += $$QFACE_YAML
}
+!isEmpty(QFACE_HEADERS_OUTPUT_DIR) {
+ QFACE_HEADERS_OUTPUT_TARGET = $${QFACE_HEADERS_OUTPUT_DIR}/$$lower($${QFACE_MODULE_NAME})module.h
+ qface_headers.target = $$relative_path($$QFACE_HEADERS_OUTPUT_TARGET, $$OUT_PWD)
+ qface_headers.commands = $${QMAKE_COPY_FILE} $${QFACE_OUTPUT_DIR}/*.h $${QFACE_HEADERS_OUTPUT_DIR}
+ qface_headers.depends = $$relative_path($$PRI, $$OUT_PWD) $$IVI_GENERATOR_PATH/generate.py
+}
+
# Reevaluate the Makefile after the generation has finished
Makefile.target = Makefile
# The relative_path is needed here as qmake will use a relative_path for the output files
@@ -89,6 +98,11 @@ Makefile.depends = $$relative_path($$PRI, $$OUT_PWD)
Makefile.depends = $$shadowed($$IVI_GENERATOR_PATH)/forceRebuild
}
+!isEmpty(QFACE_HEADERS_OUTPUT_TARGET) {
+ Makefile.depends += $$relative_path($$QFACE_HEADERS_OUTPUT_TARGET, $$OUT_PWD)
+ QMAKE_EXTRA_TARGETS += qface_headers
+}
+
# After the generation, this should exists and qmake can create the correct build tree
exists($$PRI) {
# save the state and reset for SOURCES, HEADERS and OTHER_FILES
diff --git a/mkspecs/features/ivigenerator_qt_module.prf b/mkspecs/features/ivigenerator_qt_module.prf
new file mode 100644
index 0000000..bceff89
--- /dev/null
+++ b/mkspecs/features/ivigenerator_qt_module.prf
@@ -0,0 +1,29 @@
+# Custom compiler for qface base modules
+#
+# If not building a module, use CONFIG += ivigenerator instead
+#
+# Example input:
+# QFACE_SOURCES += my.foo.qface [required]
+# QFACE_MODULE_NAME = my_module_name
+# QFACE_FORMAT = frontend (or backend, simulator... -- defaults to "frontend")
+# QFACE_OUTPUT_DIR = my_output_dir (defaults to current build dir)
+#
+
+!contains(QFACE_SOURCES, .+\\.qface$) {
+ error("Invalid qface file provided: The file needs to end with .qface")
+}
+
+QFACE_PWD = $$dirname(QFACE_SOURCES)
+QFACE_ABS_PWD = $$absolute_path($$QFACE_PWD, $$_PRO_FILE_PWD_)
+
+load(qt_build_paths)
+!force_independent {
+ QFACE_HEADERS_REL_DIR = $$relative_path($$QFACE_ABS_PWD, $$QTIVI_ROOT)
+ QFACE_HEADERS_OUTPUT_DIR = $${MODULE_BASE_OUTDIR}/$${QFACE_HEADERS_REL_DIR}
+ !exists(QFACE_HEADERS_OUTPUT_DIR) {
+ mkpath($${QFACE_HEADERS_OUTPUT_DIR})
+ }
+}
+
+load(qt_module)
+load(ivigenerator)
diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py
index 550ea67..50a1918 100755
--- a/src/tools/ivigenerator/generate.py
+++ b/src/tools/ivigenerator/generate.py
@@ -38,6 +38,7 @@
# SPDX-License-Identifier: LGPL-3.0
import re
+import os
import click
import logging.config
import yaml
@@ -56,7 +57,7 @@ log = logging.getLogger(__file__)
Filters.classPrefix = ''
-QT_AS_VERSION = 1.2
+QT_AS_VERSION = 2.0
def tag_by_path(symbol, path, default_value=False):
"""
@@ -402,8 +403,9 @@ def generate(tplconfig, moduleConfig, src, dst):
generator.register_filter('qml_control', qml_control)
generator.register_filter('qml_binding_property', qml_binding_property)
-
- ctx = {'dst': dst, 'qtASVersion': QT_AS_VERSION}
+ srcFile = os.path.basename(src[0])
+ srcBase = os.path.splitext(srcFile)[0]
+ ctx = {'dst': dst, 'qtASVersion': QT_AS_VERSION, 'srcFile':srcFile, 'srcBase':srcBase}
gen_config = yaml.load(open(here / '{0}.yaml'.format(tplconfig)))
for module in system.modules:
log.debug('generate code for module %s', module)
diff --git a/src/tools/ivigenerator/templates_backend_simulator.yaml b/src/tools/ivigenerator/templates_backend_simulator.yaml
index 76441df..0c3708d 100644
--- a/src/tools/ivigenerator/templates_backend_simulator.yaml
+++ b/src/tools/ivigenerator/templates_backend_simulator.yaml
@@ -6,7 +6,7 @@ generate_rules:
template_file: "plugin.cpp.tpl"
- dest_file: "{{module.module_name|lower}}.json"
template_file: "plugin.json"
- - dest_file: "{{module|lower|replace('.', '-')}}.pri"
+ - dest_file: "{{srcBase|lower}}.pri"
template_file: "plugin.pri.tpl"
interface_rules:
- dest_file: '{{interface|lower}}backend.h'
diff --git a/src/tools/ivigenerator/templates_control_panel.yaml b/src/tools/ivigenerator/templates_control_panel.yaml
index ecf7661..e8297d8 100644
--- a/src/tools/ivigenerator/templates_control_panel.yaml
+++ b/src/tools/ivigenerator/templates_control_panel.yaml
@@ -6,7 +6,7 @@ generate_rules:
template_file: 'main.qml.tpl'
- dest_file: 'qml.qrc'
template_file: 'qml.qrc.tpl'
- - dest_file: "{{module|lower|replace('.', '-')}}.pri"
+ - dest_file: "{{srcBase|lower}}.pri"
template_file: "ui.pri.tpl"
- dest_file: "{{module.module_name|lower}}global.h"
template_file: "global.h.tpl"
diff --git a/src/tools/ivigenerator/templates_frontend.yaml b/src/tools/ivigenerator/templates_frontend.yaml
index 97245f2..f993e80 100644
--- a/src/tools/ivigenerator/templates_frontend.yaml
+++ b/src/tools/ivigenerator/templates_frontend.yaml
@@ -10,7 +10,7 @@ generate_rules:
template_file: "modulefactory.h.tpl"
- dest_file: "{{module.module_name|lower}}modulefactory.cpp"
template_file: "modulefactory.cpp.tpl"
- - dest_file: "{{module|lower|replace('.', '-')}}.pri"
+ - dest_file: "{{srcBase|lower}}.pri"
template_file: "module.pri.tpl"
interface_rules:
- dest_file: '{{interface|lower}}backendinterface.h'
diff --git a/src/tools/ivigenerator/templates_generation_validator.yaml b/src/tools/ivigenerator/templates_generation_validator.yaml
index 1dbffcb..aaf598c 100644
--- a/src/tools/ivigenerator/templates_generation_validator.yaml
+++ b/src/tools/ivigenerator/templates_generation_validator.yaml
@@ -6,7 +6,7 @@ generate_rules:
template_file: "main.qml.tpl"
- dest_file: "qml.qrc"
template_file: "qml.qrc.tpl"
- - dest_file: "{{module|lower|replace('.', '-')}}.pri"
+ - dest_file: "{{srcBase|lower}}.pri"
template_file: "ui.pri.tpl"
- dest_file: "generationstatusitem.cpp"
template_file: "generationstatusitem.cpp.tpl"