aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-01-05 16:27:55 +0300
committerIvan Komissarov <ABBAPOH@gmail.com>2020-01-08 10:23:42 +0000
commit4e7b3044cf92d970cbc99277f672f3cd95853952 (patch)
treec8cdcbe8d8436011cff846aa5d6a91d92ce6801b /src
parent96557b5ed7fc002f6674c97dd7819ff463bbc6be (diff)
generators: Use constexpr arrays for iar/keil knownVersions
This places all data in the RO section and makes code simpler Change-Id: I7a4e8afbe2558aa2aee8f15302128101eb4c0f7e Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/generator/iarew/iarew.pro1
-rw-r--r--src/plugins/generator/iarew/iarew.qbs1
-rw-r--r--src/plugins/generator/iarew/iarewfileversionproperty.cpp4
-rw-r--r--src/plugins/generator/iarew/iarewfileversionproperty.h5
-rw-r--r--src/plugins/generator/iarew/iarewgenerator.cpp2
-rw-r--r--src/plugins/generator/iarew/iarewgenerator.h4
-rw-r--r--src/plugins/generator/iarew/iarewgeneratorplugin.cpp2
-rw-r--r--src/plugins/generator/iarew/iarewproject.cpp2
-rw-r--r--src/plugins/generator/iarew/iarewproject.h4
-rw-r--r--src/plugins/generator/iarew/iarewversioninfo.cpp65
-rw-r--r--src/plugins/generator/iarew/iarewversioninfo.h15
-rw-r--r--src/plugins/generator/keiluv/keiluv.pro1
-rw-r--r--src/plugins/generator/keiluv/keiluv.qbs1
-rw-r--r--src/plugins/generator/keiluv/keiluvgenerator.cpp2
-rw-r--r--src/plugins/generator/keiluv/keiluvgenerator.h4
-rw-r--r--src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp2
-rw-r--r--src/plugins/generator/keiluv/keiluvproject.cpp7
-rw-r--r--src/plugins/generator/keiluv/keiluvproject.h4
-rw-r--r--src/plugins/generator/keiluv/keiluvversioninfo.cpp64
-rw-r--r--src/plugins/generator/keiluv/keiluvversioninfo.h15
20 files changed, 34 insertions, 171 deletions
diff --git a/src/plugins/generator/iarew/iarew.pro b/src/plugins/generator/iarew/iarew.pro
index 074635047..542449510 100644
--- a/src/plugins/generator/iarew/iarew.pro
+++ b/src/plugins/generator/iarew/iarew.pro
@@ -37,7 +37,6 @@ SOURCES += \
$$PWD/iarewsourcefilespropertygroup.cpp \
$$PWD/iarewtoolchainpropertygroup.cpp \
$$PWD/iarewutils.cpp \
- $$PWD/iarewversioninfo.cpp \
$$PWD/iarewworkspace.cpp \
$$PWD/iarewworkspacewriter.cpp
diff --git a/src/plugins/generator/iarew/iarew.qbs b/src/plugins/generator/iarew/iarew.qbs
index 7b2270426..82c95ea5d 100644
--- a/src/plugins/generator/iarew/iarew.qbs
+++ b/src/plugins/generator/iarew/iarew.qbs
@@ -31,7 +31,6 @@ QbsPlugin {
"iarewtoolchainpropertygroup.h",
"iarewutils.cpp",
"iarewutils.h",
- "iarewversioninfo.cpp",
"iarewversioninfo.h",
"iarewworkspace.cpp",
"iarewworkspace.h",
diff --git a/src/plugins/generator/iarew/iarewfileversionproperty.cpp b/src/plugins/generator/iarew/iarewfileversionproperty.cpp
index b84f37301..4324405a1 100644
--- a/src/plugins/generator/iarew/iarewfileversionproperty.cpp
+++ b/src/plugins/generator/iarew/iarewfileversionproperty.cpp
@@ -33,7 +33,7 @@
namespace qbs {
-static QByteArray buildFileVersion(const IarewVersionInfo &versionInfo)
+static QByteArray buildFileVersion(const gen::VersionInfo &versionInfo)
{
switch (versionInfo.marketingVersion()) {
case 3:
@@ -47,7 +47,7 @@ static QByteArray buildFileVersion(const IarewVersionInfo &versionInfo)
}
IarewFileVersionProperty::IarewFileVersionProperty(
- const IarewVersionInfo &versionInfo)
+ const gen::VersionInfo &versionInfo)
{
setName(QByteArrayLiteral("fileVersion"));
const QByteArray fileVersion = buildFileVersion(versionInfo);
diff --git a/src/plugins/generator/iarew/iarewfileversionproperty.h b/src/plugins/generator/iarew/iarewfileversionproperty.h
index d377979fa..2ed56c1e6 100644
--- a/src/plugins/generator/iarew/iarewfileversionproperty.h
+++ b/src/plugins/generator/iarew/iarewfileversionproperty.h
@@ -31,17 +31,16 @@
#ifndef QBS_IAREWFILEVERSIONPROPERTY_H
#define QBS_IAREWFILEVERSIONPROPERTY_H
+#include <generators/generatorversioninfo.h>
#include <generators/xmlproperty.h>
namespace qbs {
-class IarewVersionInfo;
-
class IarewFileVersionProperty final : public gen::xml::Property
{
public:
explicit IarewFileVersionProperty(
- const IarewVersionInfo &versionInfo);
+ const gen::VersionInfo &versionInfo);
};
} // namespace qbs
diff --git a/src/plugins/generator/iarew/iarewgenerator.cpp b/src/plugins/generator/iarew/iarewgenerator.cpp
index e6b308182..c5345a6dd 100644
--- a/src/plugins/generator/iarew/iarewgenerator.cpp
+++ b/src/plugins/generator/iarew/iarewgenerator.cpp
@@ -96,7 +96,7 @@ static void writeWorkspace(const std::shared_ptr<IarewWorkspace> &wokspace,
QFileInfo(workspaceFilePath).fileName());
}
-IarewGenerator::IarewGenerator(const IarewVersionInfo &versionInfo)
+IarewGenerator::IarewGenerator(const gen::VersionInfo &versionInfo)
: m_versionInfo(versionInfo)
{
}
diff --git a/src/plugins/generator/iarew/iarewgenerator.h b/src/plugins/generator/iarew/iarewgenerator.h
index f8c1298f0..fa1d93bc3 100644
--- a/src/plugins/generator/iarew/iarewgenerator.h
+++ b/src/plugins/generator/iarew/iarewgenerator.h
@@ -44,7 +44,7 @@ class IarewWorkspace;
class IarewGenerator final : public ProjectGenerator, private IGeneratableProjectVisitor
{
public:
- explicit IarewGenerator(const IarewVersionInfo &versionInfo);
+ explicit IarewGenerator(const gen::VersionInfo &versionInfo);
QString generatorName() const final;
void generate() final;
@@ -59,7 +59,7 @@ private:
const GeneratableProjectData &projectData,
const GeneratableProductData &productData) final;
- const IarewVersionInfo m_versionInfo;
+ const gen::VersionInfo m_versionInfo;
std::shared_ptr<IarewWorkspace> m_workspace;
QString m_workspaceFilePath;
std::map<QString, std::shared_ptr<IarewProject>> m_projects;
diff --git a/src/plugins/generator/iarew/iarewgeneratorplugin.cpp b/src/plugins/generator/iarew/iarewgeneratorplugin.cpp
index bd75c7ad5..bdd15c485 100644
--- a/src/plugins/generator/iarew/iarewgeneratorplugin.cpp
+++ b/src/plugins/generator/iarew/iarewgeneratorplugin.cpp
@@ -45,7 +45,7 @@
static void QbsIarewGeneratorPluginLoad()
{
- for (const auto &info : qbs::IarewVersionInfo::knownVersions()) {
+ for (const auto &info : qbs::IarewVersionInfo::knownVersions) {
qbs::ProjectGeneratorManager::registerGenerator(
std::make_shared<qbs::IarewGenerator>(info));
}
diff --git a/src/plugins/generator/iarew/iarewproject.cpp b/src/plugins/generator/iarew/iarewproject.cpp
index 3e6a03ac2..f33ae4fcb 100644
--- a/src/plugins/generator/iarew/iarewproject.cpp
+++ b/src/plugins/generator/iarew/iarewproject.cpp
@@ -46,7 +46,7 @@ namespace qbs {
IarewProject::IarewProject(const GeneratableProject &genProject,
const GeneratableProductData &genProduct,
- const IarewVersionInfo &versionInfo)
+ const gen::VersionInfo &versionInfo)
{
Q_ASSERT(genProject.projects.size() == genProject.commandLines.size());
Q_ASSERT(genProject.projects.size() == genProduct.data.size());
diff --git a/src/plugins/generator/iarew/iarewproject.h b/src/plugins/generator/iarew/iarewproject.h
index 567a58c55..df260fcd8 100644
--- a/src/plugins/generator/iarew/iarewproject.h
+++ b/src/plugins/generator/iarew/iarewproject.h
@@ -39,14 +39,12 @@
namespace qbs {
-class IarewVersionInfo;
-
class IarewProject final : public gen::xml::Project
{
public:
explicit IarewProject(const GeneratableProject &genProject,
const GeneratableProductData &genProduct,
- const IarewVersionInfo &versionInfo);
+ const gen::VersionInfo &versionInfo);
private:
std::vector<std::unique_ptr<gen::xml::PropertyGroupFactory>> m_factories;
};
diff --git a/src/plugins/generator/iarew/iarewversioninfo.cpp b/src/plugins/generator/iarew/iarewversioninfo.cpp
deleted file mode 100644
index 5b5dc7fb8..000000000
--- a/src/plugins/generator/iarew/iarewversioninfo.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qbs.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt 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$
-**
-****************************************************************************/
-
-#include "iarewversioninfo.h"
-
-#include <QtCore/qdebug.h>
-
-namespace qbs {
-
-IarewVersionInfo::IarewVersionInfo(
- const Version &version,
- gen::utils::ArchitectureFlags archs)
- : gen::VersionInfo(version, archs)
-{
-}
-
-std::set<IarewVersionInfo> IarewVersionInfo::knownVersions()
-{
- static const std::set<IarewVersionInfo> known = {
- {Version(8), {gen::utils::Architecture::Arm}},
- {Version(7), {gen::utils::Architecture::Avr,
- gen::utils::Architecture::Msp430}},
- {Version(10), {gen::utils::Architecture::Mcs51}},
- {Version(3), {gen::utils::Architecture::Stm8}},
- };
- return known;
-}
-
-} // namespace qbs
diff --git a/src/plugins/generator/iarew/iarewversioninfo.h b/src/plugins/generator/iarew/iarewversioninfo.h
index 65e2f08d9..3dc459557 100644
--- a/src/plugins/generator/iarew/iarewversioninfo.h
+++ b/src/plugins/generator/iarew/iarewversioninfo.h
@@ -44,16 +44,17 @@
#include <generators/generatorversioninfo.h>
namespace qbs {
+namespace IarewVersionInfo {
-class IarewVersionInfo final : public gen::VersionInfo
-{
-public:
- IarewVersionInfo(const Version &version,
- gen::utils::ArchitectureFlags archs);
-
- static std::set<IarewVersionInfo> knownVersions();
+constexpr gen::VersionInfo knownVersions[] = {
+ {Version(8), {gen::utils::Architecture::Arm}},
+ {Version(7), {gen::utils::Architecture::Avr,
+ gen::utils::Architecture::Msp430}},
+ {Version(10), {gen::utils::Architecture::Mcs51}},
+ {Version(3), {gen::utils::Architecture::Stm8}},
};
+} // namespace IarewVersionInfo
} // namespace qbs
#endif // QBS_IAREWVERSIONINFO_H
diff --git a/src/plugins/generator/keiluv/keiluv.pro b/src/plugins/generator/keiluv/keiluv.pro
index 52d7c0ed4..052277ef8 100644
--- a/src/plugins/generator/keiluv/keiluv.pro
+++ b/src/plugins/generator/keiluv/keiluv.pro
@@ -28,7 +28,6 @@ SOURCES += \
$$PWD/keiluvproject.cpp \
$$PWD/keiluvprojectwriter.cpp \
$$PWD/keiluvutils.cpp \
- $$PWD/keiluvversioninfo.cpp \
$$PWD/keiluvworkspace.cpp \
$$PWD/keiluvworkspacewriter.cpp
diff --git a/src/plugins/generator/keiluv/keiluv.qbs b/src/plugins/generator/keiluv/keiluv.qbs
index 65bf6d65b..65f8fa029 100644
--- a/src/plugins/generator/keiluv/keiluv.qbs
+++ b/src/plugins/generator/keiluv/keiluv.qbs
@@ -21,7 +21,6 @@ QbsPlugin {
"keiluvprojectwriter.h",
"keiluvutils.cpp",
"keiluvutils.h",
- "keiluvversioninfo.cpp",
"keiluvversioninfo.h",
"keiluvworkspace.cpp",
"keiluvworkspace.h",
diff --git a/src/plugins/generator/keiluv/keiluvgenerator.cpp b/src/plugins/generator/keiluv/keiluvgenerator.cpp
index e3c959e8d..f98f55abe 100644
--- a/src/plugins/generator/keiluv/keiluvgenerator.cpp
+++ b/src/plugins/generator/keiluv/keiluvgenerator.cpp
@@ -84,7 +84,7 @@ static void writeWorkspace(const std::shared_ptr<KeiluvWorkspace> &wokspace,
QFileInfo(workspaceFilePath).fileName());
}
-KeiluvGenerator::KeiluvGenerator(const KeiluvVersionInfo &versionInfo)
+KeiluvGenerator::KeiluvGenerator(const gen::VersionInfo &versionInfo)
: m_versionInfo(versionInfo)
{
}
diff --git a/src/plugins/generator/keiluv/keiluvgenerator.h b/src/plugins/generator/keiluv/keiluvgenerator.h
index 769519562..25b89b9c8 100644
--- a/src/plugins/generator/keiluv/keiluvgenerator.h
+++ b/src/plugins/generator/keiluv/keiluvgenerator.h
@@ -45,7 +45,7 @@ class KeiluvGenerator final : public ProjectGenerator,
private IGeneratableProjectVisitor
{
public:
- explicit KeiluvGenerator(const KeiluvVersionInfo &versionInfo);
+ explicit KeiluvGenerator(const gen::VersionInfo &versionInfo);
QString generatorName() const final;
void generate() final;
@@ -60,7 +60,7 @@ private:
const GeneratableProjectData &projectData,
const GeneratableProductData &productData) final;
- const KeiluvVersionInfo m_versionInfo;
+ const gen::VersionInfo m_versionInfo;
std::shared_ptr<KeiluvWorkspace> m_workspace;
QString m_workspaceFilePath;
std::map<QString, std::shared_ptr<KeiluvProject>> m_projects;
diff --git a/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp b/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp
index 91b73ef71..abbccc3da 100644
--- a/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp
+++ b/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp
@@ -45,7 +45,7 @@
static void QbsKeiluvGeneratorPluginLoad()
{
- for (const auto &info : qbs::KeiluvVersionInfo::knownVersions()) {
+ for (const auto &info : qbs::KeiluvVersionInfo::knownVersions) {
qbs::ProjectGeneratorManager::registerGenerator(
std::make_shared<qbs::KeiluvGenerator>(info));
}
diff --git a/src/plugins/generator/keiluv/keiluvproject.cpp b/src/plugins/generator/keiluv/keiluvproject.cpp
index 476ce8e69..89db73b1f 100644
--- a/src/plugins/generator/keiluv/keiluvproject.cpp
+++ b/src/plugins/generator/keiluv/keiluvproject.cpp
@@ -40,7 +40,7 @@
namespace qbs {
-static QString keilProjectSchema(const KeiluvVersionInfo &info)
+static QString keilProjectSchema(const gen::VersionInfo &info)
{
const auto v = info.marketingVersion();
switch (v) {
@@ -51,10 +51,9 @@ static QString keilProjectSchema(const KeiluvVersionInfo &info)
}
}
-KeiluvProject::KeiluvProject(
- const qbs::GeneratableProject &genProject,
+KeiluvProject::KeiluvProject(const qbs::GeneratableProject &genProject,
const qbs::GeneratableProductData &genProduct,
- const KeiluvVersionInfo &versionInfo)
+ const gen::VersionInfo &versionInfo)
{
Q_ASSERT(genProject.projects.size() == genProject.commandLines.size());
Q_ASSERT(genProject.projects.size() == genProduct.data.size());
diff --git a/src/plugins/generator/keiluv/keiluvproject.h b/src/plugins/generator/keiluv/keiluvproject.h
index 98b2815ed..da86f71fd 100644
--- a/src/plugins/generator/keiluv/keiluvproject.h
+++ b/src/plugins/generator/keiluv/keiluvproject.h
@@ -40,15 +40,13 @@
namespace qbs {
-class KeiluvVersionInfo;
-
class KeiluvProject final : public gen::xml::Project
{
public:
explicit KeiluvProject(
const qbs::GeneratableProject &genProject,
const qbs::GeneratableProductData &genProduct,
- const KeiluvVersionInfo &versionInfo);
+ const gen::VersionInfo &versionInfo);
private:
std::vector<std::unique_ptr<gen::xml::PropertyGroupFactory>> m_factories;
};
diff --git a/src/plugins/generator/keiluv/keiluvversioninfo.cpp b/src/plugins/generator/keiluv/keiluvversioninfo.cpp
deleted file mode 100644
index a0d264f49..000000000
--- a/src/plugins/generator/keiluv/keiluvversioninfo.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qbs.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt 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$
-**
-****************************************************************************/
-
-#include "keiluvconstants.h"
-#include "keiluvversioninfo.h"
-
-#include <QtCore/qdebug.h>
-
-namespace qbs {
-
-KeiluvVersionInfo::KeiluvVersionInfo(
- const Version &version,
- gen::utils::ArchitectureFlags archs)
- : gen::VersionInfo(version, archs)
-{
-}
-
-std::set<KeiluvVersionInfo> KeiluvVersionInfo::knownVersions()
-{
- static const std::set<KeiluvVersionInfo> known = {
- {Version(KeiluvConstants::v5::kUVisionVersion),
- {gen::utils::Architecture::Mcs51,
- gen::utils::Architecture::Arm}},
- };
- return known;
-}
-
-} // namespace qbs
diff --git a/src/plugins/generator/keiluv/keiluvversioninfo.h b/src/plugins/generator/keiluv/keiluvversioninfo.h
index 03eacfc09..cc379c3d7 100644
--- a/src/plugins/generator/keiluv/keiluvversioninfo.h
+++ b/src/plugins/generator/keiluv/keiluvversioninfo.h
@@ -40,20 +40,21 @@
#ifndef QBS_KEILUVVERSIONINFO_H
#define QBS_KEILUVVERSIONINFO_H
+#include "keiluvconstants.h"
+
#include <generators/generatorutils.h>
#include <generators/generatorversioninfo.h>
namespace qbs {
+namespace KeiluvVersionInfo {
-class KeiluvVersionInfo final : public gen::VersionInfo
-{
-public:
- KeiluvVersionInfo(const Version &version,
- gen::utils::ArchitectureFlags archs);
-
- static std::set<KeiluvVersionInfo> knownVersions();
+constexpr gen::VersionInfo knownVersions[] = {
+ {Version(KeiluvConstants::v5::kUVisionVersion),
+ {gen::utils::Architecture::Mcs51,
+ gen::utils::Architecture::Arm}},
};
+} // namespace KeiluvVersionInfo
} // namespace qbs
#endif // QBS_KEILUVVERSIONINFO_H