From 434fa38eb6f7e3562bdce5290370933175efb225 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 1 Aug 2019 11:04:50 +0200 Subject: 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 --- .../custom-template/custom-template.pro | 7 +++ .../ivigenerator/custom-template/custom-test.yaml | 10 ++++ .../custom-template/custom-test/module.pri.tpl | 49 +++++++++++++++++++ .../custom-template/custom-test/tst_custom.cpp.tpl | 55 ++++++++++++++++++++++ .../custom-template/custom-test/tst_custom.h.tpl | 53 +++++++++++++++++++++ tests/auto/core/ivigenerator/ivigenerator.pro | 3 +- 6 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 tests/auto/core/ivigenerator/custom-template/custom-template.pro create mode 100644 tests/auto/core/ivigenerator/custom-template/custom-test.yaml create mode 100644 tests/auto/core/ivigenerator/custom-template/custom-test/module.pri.tpl create mode 100644 tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.cpp.tpl create mode 100644 tests/auto/core/ivigenerator/custom-template/custom-test/tst_custom.h.tpl (limited to 'tests') 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 + +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 \ -- cgit v1.2.1