diff options
-rw-r--r-- | src/ivicore/doc/src/external-resources.qdoc | 5 | ||||
-rw-r--r-- | src/ivicore/doc/src/ivigenerator/generator-usage.qdoc | 30 | ||||
-rw-r--r-- | src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc | 2 | ||||
-rwxr-xr-x | src/tools/ivigenerator/generate.py | 60 | ||||
-rw-r--r-- | src/tools/ivigenerator/generator/rule_generator.py | 133 | ||||
-rw-r--r-- | src/tools/ivigenerator/ivigenerator.pro | 3 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/backend_qtro.yaml | 30 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/backend_simulator.yaml | 52 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/frontend.yaml | 59 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/frontend/module.cpp.tpl | 2 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/frontend/module.h.tpl | 2 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/qmlplugin.yaml | 25 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/server_qtro.yaml | 21 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/server_qtro_simulator.yaml | 60 | ||||
-rw-r--r-- | src/tools/ivigenerator/templates/test.yaml | 21 |
15 files changed, 272 insertions, 233 deletions
diff --git a/src/ivicore/doc/src/external-resources.qdoc b/src/ivicore/doc/src/external-resources.qdoc index 6541ff5..6e1911f 100644 --- a/src/ivicore/doc/src/external-resources.qdoc +++ b/src/ivicore/doc/src/external-resources.qdoc @@ -34,3 +34,8 @@ \externalpage https://doc.qt.io/qt-5/qabstractlistmodel.html#subclassing \title QAbstractListModel - Subclassing */ + +/*! + \externalpage https://qface.readthedocs.io/en/latest/extending.html#rule-base-generation + \title QFace - Rule Base Generation +*/ diff --git a/src/ivicore/doc/src/ivigenerator/generator-usage.qdoc b/src/ivicore/doc/src/ivigenerator/generator-usage.qdoc index 287dc99..7d870d9 100644 --- a/src/ivicore/doc/src/ivigenerator/generator-usage.qdoc +++ b/src/ivicore/doc/src/ivigenerator/generator-usage.qdoc @@ -153,23 +153,25 @@ This YAML file must have the following structure: \code - generate_rules: - module_rules: - - dest_file: "{{module.module_name|lower}}plugin.h" - template_file: "plugin.h.tpl" - interface_rules: - - dest_file: '{{interface|lower}}backend.h' - template_file: 'backend.h.tpl' - struct_rules: + frontend: + module: + documents: + - "{{module.module_name|lower}}plugin.h": "plugin.h.tpl" + interface: + documents: + - '{{interface|lower}}backend.h': 'backend.h.tpl' \endcode For every entity, there's a list of templates that must be called, when traversing this entity - in the domain model tree. Here, \e{dest_file} is a name of the file that needs to be created, - as specified in the \l {Jinja template syntax}{Jinja template language} format. The value of - the object property used in the template's name is processed and substituted into the template, - thus forming the final name of the file to create. \e{dest_file} is the name of the template to - use. For the IVI generator, you must specify rules for three kinds of entities: modules, - interfaces and structures. + in the domain model tree. Here, the YAML file defines a list of documents, which need to be + generated for all modules and a list for all interfaces. Every list entry consists of two + parts; the first part is the name of the file that needs to be created, as specified in the \l + {Jinja template syntax}{Jinja template language} format. The value of the object property used + in the template's name is processed and substituted into the template, thus forming the final + name of the file to create. The second part is the name of the template to use. For the IVI + generator, you must specify rules for three kinds of entities: modules, interfaces and + structures. See the \l{QFace - Rule Base Generation}{QFace Rule Base Generation Documentation} + for more information. \section2 Annotations YAML diff --git a/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc b/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc index 5ff1c97..b174b43 100644 --- a/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc +++ b/src/ivicore/doc/src/ivigenerator/ivigenerator.qdoc @@ -54,8 +54,6 @@ Currently, Qt IVI generator has the following limitations: QGeoCoordinate inside a QFace IDL. \li The \c map<> type is not supported. \li Any default values provided directly in the QFace file are currently ignored. - \li The \c ivigenerator uses it's own YAML template, that's incorporated with QFace's YAML to - define the generation rules. \endlist */ diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py index 8f06566..6d6963d 100755 --- a/src/tools/ivigenerator/generate.py +++ b/src/tools/ivigenerator/generate.py @@ -48,7 +48,7 @@ import yaml import sys from path import Path -from qface.generator import FileSystem, Generator +from qface.generator import FileSystem, Generator, RuleGenerator from qface.watch import monitor from qface.idl.domain import Module, Interface, Property, Parameter, Field, Struct @@ -58,12 +58,12 @@ import inspect import generator.builtin_config as builtin_config from generator.global_functions import register_global_functions from generator.filters import register_filters +from generator.rule_generator import CustomRuleGenerator here = Path(__file__).dirname() log = logging.getLogger(__file__) -currentQFaceSrcFile = '' builtinTemplatesPath = Path(here / 'templates') builtinTemplates = [os.path.splitext(f)[0] for f in os.listdir(builtinTemplatesPath) if fnmatch.fnmatch(f, '*.yaml')] @@ -89,22 +89,22 @@ def generate(tplconfig, moduleConfig, annotations, imports, src, dst): print('no such annotation file: {0}'.format(annotations_file)) exit(1) FileSystem.merge_annotations(system, Path(annotations_file)) - generator = Generator(search_path=[tplconfig, builtinTemplatesPath]) - generator.env.keep_trailing_newline = True - register_global_functions(generator) - register_filters(generator) srcFile = os.path.basename(src[0]) srcBase = os.path.splitext(srcFile)[0] - global currentQFaceSrcFile - currentQFaceSrcFile = src[0] - ctx = {'dst': dst, 'qtASVersion': builtin_config.config["VERSION"], 'srcFile':srcFile, 'srcBase':srcBase, 'features': builtin_config.config["FEATURES"]} - gen_config = yaml.load(open(os.path.dirname(tplconfig) + '/{0}.yaml'.format(os.path.basename(tplconfig))), Loader=yaml.SafeLoader) + ctx = {'qtASVersion': builtin_config.config["VERSION"], 'srcFile':srcFile, 'srcBase':srcBase} + generator = CustomRuleGenerator(search_path=[tplconfig, builtinTemplatesPath], destination=dst, context = ctx, modules=module_names) + generator.env.keep_trailing_newline = True + + register_global_functions(generator) + register_filters(generator) #Make sure the config tag is available for all our symbols for module in system.modules: module.add_tag('config') + for val, key in moduleConfig.items(): + module.add_attribute('config', val, key) for interface in module.interfaces: interface.add_tag('config') for property in interface.properties: @@ -122,46 +122,8 @@ def generate(tplconfig, moduleConfig, annotations, imports, src, dst): for member in enum.members: member.add_tag('config') - ctx.update({'modules': system.modules}) - for module in system.modules: - # Only generate files for the modules detected from the first parse run - if not module.name in module_names: - continue - - log.debug('generate code for module %s', module) - - # Report early if we cannot find the imported modules - for imp in module._importMap: - if imp not in system._moduleMap: - sys.exit("{0}: Couldn't resolve import '{1}'".format(currentQFaceSrcFile, imp)) + generator.process_rules(os.path.dirname(tplconfig) + '/{0}.yaml'.format(os.path.basename(tplconfig)), system) - for val, key in moduleConfig.items(): - module.add_attribute('config', val, key) - ctx.update({'module': module}) - # TODO: refine that, probably just use plain output folder - dst = generator.apply('{{dst}}', ctx) - generator.destination = dst - module_rules = gen_config['generate_rules']['module_rules'] - force = moduleConfig['force'] - if module_rules is None: module_rules = [] - for rule in module_rules: - preserve = rule['preserve'] if 'preserve' in rule else False - generator.write(rule['dest_file'], rule['template_file'], ctx, preserve, force) - for interface in module.interfaces: - log.debug('generate backend code for interface %s', interface) - ctx.update({'interface': interface}) - interface_rules = gen_config['generate_rules']['interface_rules'] - if interface_rules is None: interface_rules = [] - for rule in interface_rules: - preserve = rule['preserve'] if 'preserve' in rule else False - generator.write(rule['dest_file'], rule['template_file'], ctx, preserve, force) - if 'struct_rules' in gen_config['generate_rules'] and isinstance(gen_config['generate_rules']['struct_rules'], list): - for struct in module.structs: - log.debug('generate code for struct %s', struct) - ctx.update({'struct': struct}) - for rule in gen_config['generate_rules']['struct_rules']: - preserve = rule['preserve'] if 'preserve' in rule else False - generator.write(rule['dest_file'], rule['template_file'], ctx, preserve, force) def run(format, moduleConfig, annotations, imports, src, dst): diff --git a/src/tools/ivigenerator/generator/rule_generator.py b/src/tools/ivigenerator/generator/rule_generator.py new file mode 100644 index 0000000..fbeef28 --- /dev/null +++ b/src/tools/ivigenerator/generator/rule_generator.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 +# Copyright (C) 2019 The Qt Company Ltd. +# Contact: https://www.qt.io/licensing/ +# +# This file is part of the QtIvi module of the Qt Toolkit. +# +# $QT_BEGIN_LICENSE:LGPL-QTAS$ +# Commercial License Usage +# Licensees holding valid commercial Qt Automotive Suite licenses may use +# this file in accordance with the commercial license agreement provided +# with the Software or, alternatively, in accordance with the terms +# contained in a written agreement between you and The Qt Company. For +# licensing terms and conditions see https://www.qt.io/terms-conditions. +# For further information use the contact form at https://www.qt.io/contact-us. +# +# GNU Lesser General Public License Usage +# Alternatively, this file may be used under the terms of the GNU Lesser +# General Public License version 3 as published by the Free Software +# Foundation and appearing in the file LICENSE.LGPL3 included in the +# packaging of this file. Please review the following information to +# ensure the GNU Lesser General Public License version 3 requirements +# will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +# +# GNU General Public License Usage +# Alternatively, this file may be used under the terms of the GNU +# General Public License version 2.0 or (at your option) the GNU General +# Public license version 3 or any later version approved by the KDE Free +# Qt Foundation. The licenses are as published by the Free Software +# Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +# included in the packaging of this file. Please review the following +# information to ensure the GNU General Public License requirements will +# be met: https://www.gnu.org/licenses/gpl-2.0.html and +# https://www.gnu.org/licenses/gpl-3.0.html. +# +# $QT_END_LICENSE$ +# +# SPDX-License-Identifier: LGPL-3.0 + +import click +import logging.config +import sys +import yaml +from path import Path + +from qface.generator import RuleGenerator +from qface.idl.domain import Module, Interface, Property, Parameter, Field, Struct + +log = logging.getLogger(__file__) + +class CustomRuleGenerator(RuleGenerator): + """Extended RuleGenerator to only generate the wanted modules instead of all""" + def __init__(self, search_path: str, destination:Path, modules:[], context:dict={}, features:set=set(), force=False): + super().__init__(search_path, destination, context, features, force) + self.module_names = modules + + def process_rules(self, path: Path, system): + gen_config = yaml.load(open(path), Loader=yaml.SafeLoader) + if 'generate_rules' in gen_config: + self._process_legacy(gen_config, system) + else: + super().process_rules(path, system) + + def _process_rules(self, rules: dict, system): + self._source = None # reset the template source + if not self._shall_proceed(rules): + return + self.context.update(rules.get('context', {})) + self.path = rules.get('path', '') + self.source = rules.get('source', None) + self._process_rule(rules.get('system', None), {'system': system}) + for module in system.modules: + #Only generate files for the modules detected from the first parse run + if not module.name in self.module_names: + continue + + log.debug('generate code for module %s', module) + + # Report early if we cannot find the imported modules + for imp in module._importMap: + if imp not in system._moduleMap: + sys.exit("Couldn't resolve import '{0}'".format(imp)) + + self._process_rule(rules.get('module', None), {'module': module}) + for interface in module.interfaces: + self._process_rule(rules.get('interface', None), {'interface': interface}) + for struct in module.structs: + self._process_rule(rules.get('struct', None), {'struct': struct}) + for enum in module.enums: + self._process_rule(rules.get('enum', None), {'enum': enum}) + + + def _process_legacy(self, gen_config, system): + + click.secho('Using the legacy Generation YAML Parser. Please consider porting to the new ' + 'Rule based Generation provided by QFace 2.0', fg='yellow') + + for module in system.modules: + # Only generate files for the modules detected from the first parse run + if not module.name in self.module_names: + continue + + log.debug('generate code for module %s', module) + + # Report early if we cannot find the imported modules + for imp in module._importMap: + if imp not in system._moduleMap: + sys.exit("Couldn't resolve import '{0}'".format(imp)) + + self.context.update({'module': module}) + dst = self.apply('{{dst}}', self.context) + self.destination = dst + module_rules = gen_config['generate_rules']['module_rules'] + force = True #moduleConfig['force'] + if module_rules is None: module_rules = [] + for rule in module_rules: + preserve = rule['preserve'] if 'preserve' in rule else False + self.write(rule['dest_file'], rule['template_file'], self.context, preserve, force) + for interface in module.interfaces: + log.debug('generate backend code for interface %s', interface) + self.context.update({'interface': interface}) + interface_rules = gen_config['generate_rules']['interface_rules'] + if interface_rules is None: interface_rules = [] + for rule in interface_rules: + preserve = rule['preserve'] if 'preserve' in rule else False + self.write(rule['dest_file'], rule['template_file'], self.context, preserve, force) + if 'struct_rules' in gen_config['generate_rules'] and isinstance(gen_config['generate_rules']['struct_rules'], list): + for struct in module.structs: + log.debug('generate code for struct %s', struct) + self.context.update({'struct': struct}) + for rule in gen_config['generate_rules']['struct_rules']: + preserve = rule['preserve'] if 'preserve' in rule else False + self.write(rule['dest_file'], rule['template_file'], ctx, preserve, force) + diff --git a/src/tools/ivigenerator/ivigenerator.pro b/src/tools/ivigenerator/ivigenerator.pro index 1ffd7bf..ae1a748 100644 --- a/src/tools/ivigenerator/ivigenerator.pro +++ b/src/tools/ivigenerator/ivigenerator.pro @@ -103,7 +103,8 @@ templates_yaml.path = $$[QT_HOST_BINS]/ivigenerator/templates generator_module.files += \ generator/global_functions.py \ generator/builtin_config.py \ - generator/filters.py + generator/filters.py \ + generator/rule_generator.py generator_module.path = $$[QT_HOST_BINS]/ivigenerator/generator generator.files += \ diff --git a/src/tools/ivigenerator/templates/backend_qtro.yaml b/src/tools/ivigenerator/templates/backend_qtro.yaml index c0acde6..1769ef0 100644 --- a/src/tools/ivigenerator/templates/backend_qtro.yaml +++ b/src/tools/ivigenerator/templates/backend_qtro.yaml @@ -1,18 +1,12 @@ -generate_rules: - module_rules: - - dest_file: "{{module.module_name|lower}}plugin.h" - template_file: "plugin.h.tpl" - - dest_file: "{{module.module_name|lower}}plugin.cpp" - template_file: "plugin.cpp.tpl" - - dest_file: "{{module.module_name|lower}}.json" - template_file: "plugin.json" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "plugin.pri.tpl" - interface_rules: - - dest_file: '{{interface|lower}}backend.h' - template_file: 'backend.h.tpl' - - dest_file: '{{interface|lower}}backend.cpp' - template_file: 'backend.cpp.tpl' - - dest_file: "{{interface|lower}}.rep" - template_file: "common/interface.rep.tpl" - struct_rules: +backend_qtro: + module: + documents: + - "{{module.module_name|lower}}plugin.h": "plugin.h.tpl" + - "{{module.module_name|lower}}plugin.cpp": "plugin.cpp.tpl" + - "{{module.module_name|lower}}.json": "plugin.json" + - "{{srcBase|lower}}.pri": "plugin.pri.tpl" + interface: + documents: + - '{{interface|lower}}backend.h': 'backend.h.tpl' + - '{{interface|lower}}backend.cpp': 'backend.cpp.tpl' + - "{{interface|lower}}.rep": "common/interface.rep.tpl" diff --git a/src/tools/ivigenerator/templates/backend_simulator.yaml b/src/tools/ivigenerator/templates/backend_simulator.yaml index 4c47848..6c7e8aa 100644 --- a/src/tools/ivigenerator/templates/backend_simulator.yaml +++ b/src/tools/ivigenerator/templates/backend_simulator.yaml @@ -1,33 +1,19 @@ -generate_rules: - module_rules: - - dest_file: "{{module.module_name|lower}}plugin.h" - template_file: "plugin.h.tpl" - - dest_file: "{{module.module_name|lower}}plugin.cpp" - template_file: "plugin.cpp.tpl" - - dest_file: "{{module.module_name|lower}}_simulation.qml" - template_file: "common/module_simulation.qml.tpl" - - dest_file: "{{module.module_name|lower}}.json" - template_file: "plugin.json" - - dest_file: "{{module.module_name|lower}}_simulation_data.json" - template_file: "common/simulation_data.json.tpl" - - dest_file: "{{module.module_name|lower}}_simulation.qrc" - template_file: "common/simulation.qrc.tpl" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "plugin.pri.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/simulation/plugins.qmltypes" - template_file: "common/simulation.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/simulation/qmldir" - template_file: "common/qmldir.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes" - template_file: "common/plugins.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/qmldir" - template_file: "common/qmldir.tpl" - interface_rules: - - dest_file: '{{interface|lower}}backend.h' - template_file: 'common/backend_simulation.h.tpl' - - dest_file: '{{interface|lower}}backend.cpp' - template_file: 'common/backend_simulation.cpp.tpl' - - dest_file: '{{interface|upperfirst}}Simulation.qml' - template_file: 'common/backend_simulation.qml.tpl' - struct_rules: - +backend_simulator: + module: + documents: + - "{{module.module_name|lower}}plugin.h": "plugin.h.tpl" + - "{{module.module_name|lower}}plugin.cpp": "plugin.cpp.tpl" + - "{{module.module_name|lower}}_simulation.qml": "common/module_simulation.qml.tpl" + - "{{module.module_name|lower}}.json": "plugin.json" + - "{{module.module_name|lower}}_simulation_data.json": "common/simulation_data.json.tpl" + - "{{module.module_name|lower}}_simulation.qrc": "common/simulation.qrc.tpl" + - "{{srcBase|lower}}.pri": "plugin.pri.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/simulation/plugins.qmltypes": "common/simulation.qmltypes.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/simulation/qmldir": "common/qmldir.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes": "common/plugins.qmltypes.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/qmldir": "common/qmldir.tpl" + interface: + documents: + - '{{interface|lower}}backend.h': 'common/backend_simulation.h.tpl' + - '{{interface|lower}}backend.cpp': 'common/backend_simulation.cpp.tpl' + - '{{interface|upperfirst}}Simulation.qml': 'common/backend_simulation.qml.tpl' diff --git a/src/tools/ivigenerator/templates/frontend.yaml b/src/tools/ivigenerator/templates/frontend.yaml index c455e21..fdab347 100644 --- a/src/tools/ivigenerator/templates/frontend.yaml +++ b/src/tools/ivigenerator/templates/frontend.yaml @@ -1,36 +1,23 @@ -generate_rules: - module_rules: - - dest_file: "{{module.module_name|lower}}global.h" - template_file: "global.h.tpl" - - dest_file: "{{module.module_name|lower}}module.h" - template_file: "module.h.tpl" - - dest_file: "{{module.module_name|lower}}module.cpp" - template_file: "module.cpp.tpl" - - dest_file: "{{module.module_name|lower}}module_enum.qdocinc" - template_file: "module_qml_enum.qdocinc.tpl" - - dest_file: "{{module.module_name|lower}}modulefactory.h" - template_file: "modulefactory.h.tpl" - - dest_file: "{{module.module_name|lower}}modulefactory.cpp" - template_file: "modulefactory.cpp.tpl" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "module.pri.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes" - template_file: "common/plugins.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/qmldir" - template_file: "common/qmldir.tpl" - interface_rules: - - dest_file: '{{interface|lower}}backendinterface.h' - template_file: 'backendinterface.h.tpl' - - dest_file: '{{interface|lower}}backendinterface.cpp' - template_file: 'backendinterface.cpp.tpl' - - dest_file: '{{interface|lower}}.h' - template_file: 'interface.h.tpl' - - dest_file: '{{interface|lower}}_p.h' - template_file: 'interface_p.h.tpl' - - dest_file: '{{interface|lower}}.cpp' - template_file: 'interface.cpp.tpl' - struct_rules: - - dest_file: '{{struct|lower}}.h' - template_file: 'struct.h.tpl' - - dest_file: '{{struct|lower}}.cpp' - template_file: 'struct.cpp.tpl' +frontend: + module: + documents: + - '{{module.module_name|lower}}global.h': 'global.h.tpl' + - '{{module.module_name|lower}}module.h': 'module.h.tpl' + - '{{module.module_name|lower}}module.cpp': 'module.cpp.tpl' + - '{{module.module_name|lower}}module_enum.qdocinc': 'module_qml_enum.qdocinc.tpl' + - '{{module.module_name|lower}}modulefactory.h': 'modulefactory.h.tpl' + - '{{module.module_name|lower}}modulefactory.cpp': 'modulefactory.cpp.tpl' + - '{{srcBase|lower}}.pri': 'module.pri.tpl' + - 'qml/{{module|qml_type|replace(".", "/")}}/plugins.qmltypes': 'common/plugins.qmltypes.tpl' + - 'qml/{{module|qml_type|replace(".", "/")}}/qmldir': 'common/qmldir.tpl' + interface: + documents: + - '{{interface|lower}}backendinterface.h': 'backendinterface.h.tpl' + - '{{interface|lower}}backendinterface.cpp': 'backendinterface.cpp.tpl' + - '{{interface|lower}}.h': 'interface.h.tpl' + - '{{interface|lower}}_p.h': 'interface_p.h.tpl' + - '{{interface|lower}}.cpp': 'interface.cpp.tpl' + struct: + documents: + - '{{struct|lower}}.h': 'struct.h.tpl' + - '{{struct|lower}}.cpp': 'struct.cpp.tpl' diff --git a/src/tools/ivigenerator/templates/frontend/module.cpp.tpl b/src/tools/ivigenerator/templates/frontend/module.cpp.tpl index 1e17757..9d42137 100644 --- a/src/tools/ivigenerator/templates/frontend/module.cpp.tpl +++ b/src/tools/ivigenerator/templates/frontend/module.cpp.tpl @@ -119,7 +119,7 @@ void {{class}}::registerTypes() See https://github.com/Pelagicore/qface/issues/87 #} {% set name = import.split(' ')[0] %} -{% for mod in modules %} +{% for mod in system.modules %} {% if mod.name == name %} {{mod.module_name|upperfirst}}Module::registerTypes(); {% endif %} diff --git a/src/tools/ivigenerator/templates/frontend/module.h.tpl b/src/tools/ivigenerator/templates/frontend/module.h.tpl index a203e92..859cf51 100644 --- a/src/tools/ivigenerator/templates/frontend/module.h.tpl +++ b/src/tools/ivigenerator/templates/frontend/module.h.tpl @@ -57,7 +57,7 @@ See https://github.com/Pelagicore/qface/issues/87 #} {% set name = import.split(' ')[0] %} -{% for mod in modules %} +{% for mod in system.modules %} {% if mod.name == name %} #include <{{mod.module_name|lower}}module.h> {% endif %} diff --git a/src/tools/ivigenerator/templates/qmlplugin.yaml b/src/tools/ivigenerator/templates/qmlplugin.yaml index 136f3cd..ba6d505 100644 --- a/src/tools/ivigenerator/templates/qmlplugin.yaml +++ b/src/tools/ivigenerator/templates/qmlplugin.yaml @@ -1,16 +1,9 @@ -generate_rules: - module_rules: - - dest_file: "plugin.cpp" - template_file: "plugin.cpp.tpl" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "module.pri.tpl" - - dest_file: "plugins.qmltypes" - template_file: "common/plugins.qmltypes.tpl" - - dest_file: "qmldir" - template_file: "qmldir_plugin.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes" - template_file: "common/plugins.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/qmldir" - template_file: "qmldir_plugin.tpl" - interface_rules: - struct_rules: +qmlplugin: + module: + documents: + - "plugin.cpp": "plugin.cpp.tpl" + - "{{srcBase|lower}}.pri": "module.pri.tpl" + - "plugins.qmltypes": "common/plugins.qmltypes.tpl" + - "qmldir": "qmldir_plugin.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes": "common/plugins.qmltypes.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/qmldir": "qmldir_plugin.tpl" diff --git a/src/tools/ivigenerator/templates/server_qtro.yaml b/src/tools/ivigenerator/templates/server_qtro.yaml index 3dec840..0c8024e 100644 --- a/src/tools/ivigenerator/templates/server_qtro.yaml +++ b/src/tools/ivigenerator/templates/server_qtro.yaml @@ -1,12 +1,9 @@ -generate_rules: - module_rules: - - dest_file: "core.cpp" - template_file: "core.cpp.tpl" - - dest_file: "core.h" - template_file: "core.h.tpl" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "server.pri.tpl" - interface_rules: - - dest_file: "{{interface|lower}}.rep" - template_file: "common/interface.rep.tpl" - struct_rules: +server_qtro: + module: + documents: + - "core.cpp": "core.cpp.tpl" + - "core.h": "core.h.tpl" + - "{{srcBase|lower}}.pri": "server.pri.tpl" + interface: + documents: + - "{{interface|lower}}.rep": "common/interface.rep.tpl" diff --git a/src/tools/ivigenerator/templates/server_qtro_simulator.yaml b/src/tools/ivigenerator/templates/server_qtro_simulator.yaml index 06bd8e9..b85de86 100644 --- a/src/tools/ivigenerator/templates/server_qtro_simulator.yaml +++ b/src/tools/ivigenerator/templates/server_qtro_simulator.yaml @@ -1,38 +1,22 @@ -generate_rules: - module_rules: - - dest_file: "core.cpp" - template_file: "core.cpp.tpl" - - dest_file: "core.h" - template_file: "core.h.tpl" - - dest_file: "{{srcBase|lower}}.pri" - template_file: "server.pri.tpl" - - dest_file: "main.cpp" - template_file: "main.cpp.tpl" - - dest_file: "{{module.module_name|lower}}_simulation.qml" - template_file: "common/module_simulation.qml.tpl" - - dest_file: "{{module.module_name|lower}}_simulation_data.json" - template_file: "common/simulation_data.json.tpl" - - dest_file: "{{module.module_name|lower}}_simulation.qrc" - template_file: "common/simulation.qrc.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/simulation/plugins.qmltypes" - template_file: "common/simulation.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/simulation/qmldir" - template_file: "common/qmldir.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes" - template_file: "common/plugins.qmltypes.tpl" - - dest_file: "qml/{{module|qml_type|replace('.', '/')}}/qmldir" - template_file: "common/qmldir.tpl" - interface_rules: - - dest_file: "{{interface|lower}}.rep" - template_file: "common/interface.rep.tpl" - - dest_file: '{{interface|lower}}adapter.h' - template_file: 'adapter.h.tpl' - - dest_file: '{{interface|lower}}adapter.cpp' - template_file: 'adapter.cpp.tpl' - - dest_file: '{{interface|lower}}backend.h' - template_file: 'common/backend_simulation.h.tpl' - - dest_file: '{{interface|lower}}backend.cpp' - template_file: 'common/backend_simulation.cpp.tpl' - - dest_file: '{{interface|upperfirst}}Simulation.qml' - template_file: 'common/backend_simulation.qml.tpl' - struct_rules: +server_qtro_simulator: + module: + documents: + - "core.cpp": "core.cpp.tpl" + - "core.h": "core.h.tpl" + - "{{srcBase|lower}}.pri": "server.pri.tpl" + - "main.cpp": "main.cpp.tpl" + - "{{module.module_name|lower}}_simulation.qml": "common/module_simulation.qml.tpl" + - "{{module.module_name|lower}}_simulation_data.json": "common/simulation_data.json.tpl" + - "{{module.module_name|lower}}_simulation.qrc": "common/simulation.qrc.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/simulation/plugins.qmltypes": "common/simulation.qmltypes.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/simulation/qmldir": "common/qmldir.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/plugins.qmltypes": "common/plugins.qmltypes.tpl" + - "qml/{{module|qml_type|replace('.', '/')}}/qmldir": "common/qmldir.tpl" + interface: + documents: + - "{{interface|lower}}.rep": "common/interface.rep.tpl" + - '{{interface|lower}}adapter.h': 'adapter.h.tpl' + - '{{interface|lower}}adapter.cpp': 'adapter.cpp.tpl' + - '{{interface|lower}}backend.h': 'common/backend_simulation.h.tpl' + - '{{interface|lower}}backend.cpp': 'common/backend_simulation.cpp.tpl' + - '{{interface|upperfirst}}Simulation.qml': 'common/backend_simulation.qml.tpl' diff --git a/src/tools/ivigenerator/templates/test.yaml b/src/tools/ivigenerator/templates/test.yaml index f7b6b64..fbd2801 100644 --- a/src/tools/ivigenerator/templates/test.yaml +++ b/src/tools/ivigenerator/templates/test.yaml @@ -1,12 +1,9 @@ -generate_rules: - module_rules: - - dest_file: "{{srcBase|lower}}.pri" - template_file: "module.pri.tpl" - - dest_file: 'main.cpp' - template_file: 'main.cpp.tpl' - interface_rules: - - dest_file: 'tst_{{interface|lower}}.cpp' - template_file: 'tst_test.cpp.tpl' - - dest_file: 'tst_{{interface|lower}}.h' - template_file: 'tst_test.h.tpl' - struct_rules: +test: + module: + documents: + - "{{srcBase|lower}}.pri": "module.pri.tpl" + - 'main.cpp': 'main.cpp.tpl' + interface: + documents: + - 'tst_{{interface|lower}}.cpp': 'tst_test.cpp.tpl' + - 'tst_{{interface|lower}}.h': 'tst_test.h.tpl' |