diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2019-08-01 11:04:50 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2019-08-01 16:50:24 +0200 |
commit | 434fa38eb6f7e3562bdce5290370933175efb225 (patch) | |
tree | 4952ea6228faf0e651597e99e6ca2cd459ac7d55 | |
parent | 4e9b53ecb262d90ea58c287325294b5c645d7ca0 (diff) |
ivigenerator: Add support for custom templates
The support for this was already partially available, but some checks
in the prf file as well as a limitation in generate.py prevented this
to be usable.
Also add a autotest for this to keep supporting it in the future
Change-Id: Iee0b7593d788d4ee30d3483ceaa141439f93a2c4
Fixes: AUTOSUITE-1162
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
8 files changed, 179 insertions, 2 deletions
diff --git a/mkspecs/features/ivigenerator.prf b/mkspecs/features/ivigenerator.prf index 8c8bd8e..90f04c5 100644 --- a/mkspecs/features/ivigenerator.prf +++ b/mkspecs/features/ivigenerator.prf @@ -98,6 +98,8 @@ qface_sources.depends += $$files($$IVI_GENERATOR_PATH/common/*) QFACE_TEMPLATE_PWD = $$IVI_GENERATOR_PATH/templates_$${QFACE_FORMAT} exists($$QFACE_TEMPLATE_PWD) { qface_sources.depends += $$files($${QFACE_TEMPLATE_PWD}/*) +} else: exists($${QFACE_FORMAT}) { + qface_sources.depends += $$files($${QFACE_FORMAT}/*) } else { error("Invalid QFACE_FORMAT: Couldn't find the template folder: $$QFACE_TEMPLATE_PWD") } diff --git a/src/tools/ivigenerator/generate.py b/src/tools/ivigenerator/generate.py index d374169..fe88334 100755 --- a/src/tools/ivigenerator/generate.py +++ b/src/tools/ivigenerator/generate.py @@ -804,7 +804,7 @@ def generate(tplconfig, moduleConfig, annotations, src, dst): global currentQFaceSrcFile currentQFaceSrcFile = src[0] ctx = {'dst': dst, 'qtASVersion': builtin_config["VERSION"], 'srcFile':srcFile, 'srcBase':srcBase, 'features': builtin_config["FEATURES"]} - gen_config = yaml.load(open(here / '{0}.yaml'.format(os.path.basename(tplconfig))), Loader=yaml.SafeLoader) + gen_config = yaml.load(open(os.path.dirname(tplconfig) + '/{0}.yaml'.format(os.path.basename(tplconfig))), Loader=yaml.SafeLoader) #Make sure the config tag is available for all our symbols for module in system.modules: diff --git a/tests/auto/core/ivigenerator/custom-template/custom-template.pro b/tests/auto/core/ivigenerator/custom-template/custom-template.pro new file mode 100644 index 0000000..dcda1ca --- /dev/null +++ b/tests/auto/core/ivigenerator/custom-template/custom-template.pro @@ -0,0 +1,7 @@ +TARGET = tst_custom-template + +QT += testlib +CONFIG += c++11 ivigenerator testcase + +QFACE_FORMAT = $$PWD/custom-test +QFACE_SOURCES = ../org.example.echo.qface diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test.yaml b/tests/auto/core/ivigenerator/custom-template/custom-test.yaml new file mode 100644 index 0000000..4c5cd17 --- /dev/null +++ b/tests/auto/core/ivigenerator/custom-template/custom-test.yaml @@ -0,0 +1,10 @@ +generate_rules: + module_rules: + - dest_file: "{{srcBase|lower}}.pri" + template_file: "module.pri.tpl" + - dest_file: 'tst_custom.cpp' + template_file: 'tst_custom.cpp.tpl' + - dest_file: 'tst_custom.h' + template_file: 'tst_custom.h.tpl' + interface_rules: + struct_rules: diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl new file mode 100644 index 0000000..067635e --- /dev/null +++ b/tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl @@ -0,0 +1,49 @@ +{# +# Copyright (C) 2019 Luxoft Sweden AB +# Copyright (C) 2018 Pelagicore AG. +# 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 +#} +############################################################################# +## This is an auto-generated file. +## Do not edit! All changes made to it will be lost. +############################################################################# + +HEADERS += \ + $$PWD/tst_custom.h \ + +SOURCES += \ + $$PWD/tst_custom.cpp \ diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl new file mode 100644 index 0000000..0ae002f --- /dev/null +++ b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl @@ -0,0 +1,55 @@ +{# +# Copyright (C) 2019 Luxoft Sweden AB +# Copyright (C) 2018 Pelagicore AG +# 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 +#} +{% include "common/generated_comment.cpp.tpl" %} + +#include "tst_custom.h" + +CustomTest::CustomTest() + : QObject() +{ +} + +void CustomTest::initTestCase() +{ + QVERIFY(true); + qInfo("Test successfully generated from 'custom template'"); +} + +QTEST_MAIN(CustomTest) diff --git a/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl new file mode 100644 index 0000000..f052e87 --- /dev/null +++ b/tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl @@ -0,0 +1,53 @@ +{# +# Copyright (C) 2019 Luxoft Sweden AB +# Copyright (C) 2018 Pelagicore AG +# 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 +#} +{% include "common/generated_comment.cpp.tpl" %} + +#include <QTest> + +class CustomTest : public QObject +{ + Q_OBJECT + +public: + CustomTest(); + +private slots: + void initTestCase(); +}; diff --git a/tests/auto/core/ivigenerator/ivigenerator.pro b/tests/auto/core/ivigenerator/ivigenerator.pro index b82cb50..00f5307 100644 --- a/tests/auto/core/ivigenerator/ivigenerator.pro +++ b/tests/auto/core/ivigenerator/ivigenerator.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs -SUBDIRS = projects +SUBDIRS = projects \ + custom-template \ OTHER_FILES = org.example.echo.qface \ org.example.echo.yaml \ |