aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-08-01 16:38:33 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-08-01 16:02:15 +0000
commit79b1d1282b95ccd1dd62f95c1a25813486339b47 (patch)
tree7a2c54d757fae7773ba100f53535c431bfa00428 /src
parent86747ff36bb162764fd8c2f741a1674d16b0b3cd (diff)
baremetal: Long live the IAR EW project generator for STM8
Right now it is possible to generate a native projects for the IAR Embedded Workbench IDE, e.g. using the following command: qbs generate -g iarew3 -d <path/to/build/directory> -f <path/to/qbs/project> profile:<your/qbs/profile> We need in a valid IAR EW QBS profile, from which the generator take a desired target architecture and other stuff. The IAR EW generator has a semi-intelligent logic, it parses a source QBS project and converts a compiler flags and other stuff to an appropriate configurations of the native IAR EW project. Currently it is supported only one 'iarew3' generator which allow to generate a projects for the IAR EW for STM8 for all versions of 3 series. Tested with the IAR EW for STM8 v3.11.1, using as the QBS bare-metal examples, and as other projects. Change-Id: I47880d62cd1e81ed7bbfba840a5af0c558065013 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/lib/corelib/generators/generatorutils.cpp2
-rw-r--r--src/lib/corelib/generators/generatorutils.h1
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp94
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h59
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp229
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h62
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp98
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h72
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp442
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h65
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp366
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h64
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp411
-rw-r--r--src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h73
-rw-r--r--src/plugins/generator/iarew/iarew.pro18
-rw-r--r--src/plugins/generator/iarew/iarew.qbs18
-rw-r--r--src/plugins/generator/iarew/iarewproject.cpp3
-rw-r--r--src/plugins/generator/iarew/iarewutils.cpp5
-rw-r--r--src/plugins/generator/iarew/iarewutils.h2
-rw-r--r--src/plugins/generator/iarew/iarewversioninfo.cpp1
20 files changed, 2085 insertions, 0 deletions
diff --git a/src/lib/corelib/generators/generatorutils.cpp b/src/lib/corelib/generators/generatorutils.cpp
index 4f76eab7f..872adbba2 100644
--- a/src/lib/corelib/generators/generatorutils.cpp
+++ b/src/lib/corelib/generators/generatorutils.cpp
@@ -60,6 +60,8 @@ Architecture architecture(const Project &qbsProject)
return Architecture::Avr;
if (qbsArch == QLatin1String("mcs51"))
return Architecture::Mcs51;
+ if (qbsArch == QLatin1String("stm8"))
+ return Architecture::Stm8;
return Architecture::Unknown;
}
diff --git a/src/lib/corelib/generators/generatorutils.h b/src/lib/corelib/generators/generatorutils.h
index e13740105..885315e4d 100644
--- a/src/lib/corelib/generators/generatorutils.h
+++ b/src/lib/corelib/generators/generatorutils.h
@@ -44,6 +44,7 @@ enum class Architecture {
Arm,
Avr,
Mcs51,
+ Stm8,
Unknown
};
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp
new file mode 100644
index 000000000..8a2ab0011
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8archiversettingsgroup_v3.h"
+
+#include "../../iarewutils.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+constexpr int kArchiverArchiveVersion = 3;
+constexpr int kArchiverDataVersion = 0;
+
+namespace {
+
+// Output page options.
+
+struct OutputPageOptions final
+{
+ explicit OutputPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ outputFile = QLatin1String("$PROJ_DIR$/")
+ + gen::utils::targetBinaryPath(baseDirectory, qbsProduct);
+ }
+
+ QString outputFile;
+};
+
+} // namespace
+
+// Stm8ArchiverSettingsGroup
+
+Stm8ArchiverSettingsGroup::Stm8ArchiverSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ Q_UNUSED(qbsProductDeps)
+
+ setName(QByteArrayLiteral("IARCHIVE"));
+ setArchiveVersion(kArchiverArchiveVersion);
+ setDataVersion(kArchiverDataVersion);
+ setDataDebugInfo(gen::utils::debugInformation(qbsProduct));
+
+ const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject);
+ buildOutputPage(buildRootDirectory, qbsProduct);
+}
+
+void Stm8ArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ const OutputPageOptions opts(baseDirectory, qbsProduct);
+ // Add 'IarchiveOverride' item (Override default).
+ addOptionsGroup(QByteArrayLiteral("IarchiveOverride"),
+ {}, {1});
+ // Add 'IarchiveOutput' item (Output filename).
+ addOptionsGroup(QByteArrayLiteral("IarchiveOutput"),
+ {}, {opts.outputFile});
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h
new file mode 100644
index 000000000..754add3cb
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H
+#define QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H
+
+#include "../../iarewsettingspropertygroup.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8ArchiverSettingsGroup final : public IarewSettingsPropertyGroup
+{
+public:
+ explicit Stm8ArchiverSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+private:
+ void buildOutputPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp
new file mode 100644
index 000000000..1e4e93706
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8assemblersettingsgroup_v3.h"
+
+#include "../../iarewutils.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+constexpr int kAssemblerArchiveVersion = 3;
+constexpr int kAssemblerDataVersion = 2;
+
+namespace {
+
+// Language page options.
+
+struct LanguagePageOptions final
+{
+ enum MacroQuoteCharacter {
+ AngleBracketsQuote,
+ RoundBracketsQuote,
+ SquareBracketsQuote,
+ FigureBracketsQuote
+ };
+
+ explicit LanguagePageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("assemblerFlags")});
+ enableSymbolsCaseSensitive = !flags.contains(
+ QLatin1String("--case_insensitive"));
+ enableMultibyteSupport = flags.contains(
+ QLatin1String("--enable_multibytes"));
+ allowFirstColumnMnemonics = flags.contains(
+ QLatin1String("--mnem_first"));
+ allowFirstColumnDirectives = flags.contains(
+ QLatin1String("--dir_first"));
+
+ if (flags.contains(QLatin1String("-M<>")))
+ macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote;
+ else if (flags.contains(QLatin1String("-M()")))
+ macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote;
+ else if (flags.contains(QLatin1String("-M[]")))
+ macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote;
+ else if (flags.contains(QLatin1String("-M{}")))
+ macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote;
+ }
+
+ int enableSymbolsCaseSensitive = 1;
+ int enableMultibyteSupport = 0;
+ int allowFirstColumnMnemonics = 0;
+ int allowFirstColumnDirectives = 0;
+
+ MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote;
+};
+
+// Output page options.
+
+struct OutputPageOptions final
+{
+ explicit OutputPageOptions(const ProductData &qbsProduct)
+ {
+ debugInfo = gen::utils::debugInformation(qbsProduct);
+ }
+
+ int debugInfo = 0;
+};
+
+// Preprocessor page options.
+
+struct PreprocessorPageOptions final
+{
+ explicit PreprocessorPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ defineSymbols = gen::utils::cppVariantModuleProperties(
+ qbsProps, {QStringLiteral("defines")});
+
+ const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct);
+ const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("includePaths"),
+ QStringLiteral("systemIncludePaths")});
+ for (const auto &fullIncludePath : fullIncludePaths) {
+ const QFileInfo includeFileInfo(fullIncludePath);
+ const QString includeFilePath = includeFileInfo.absoluteFilePath();
+ if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) {
+ const QString path = IarewUtils::toolkitRelativeFilePath(
+ toolkitPath, includeFilePath);
+ includePaths.push_back(path);
+ } else {
+ const QString path = IarewUtils::projectRelativeFilePath(
+ baseDirectory, includeFilePath);
+ includePaths.push_back(path);
+ }
+ }
+ }
+
+ QVariantList defineSymbols;
+ QVariantList includePaths;
+};
+
+// Diagnostics page options.
+
+struct DiagnosticsPageOptions final
+{
+ explicit DiagnosticsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ warningsAsErrors = gen::utils::cppIntegerModuleProperty(
+ qbsProps, QStringLiteral("treatWarningsAsErrors"));
+ }
+
+ int warningsAsErrors = 0;
+};
+
+} // namespace
+
+// Stm8AssemblerSettingsGroup
+
+Stm8AssemblerSettingsGroup::Stm8AssemblerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ Q_UNUSED(qbsProductDeps)
+
+ setName(QByteArrayLiteral("ASTM8"));
+ setArchiveVersion(kAssemblerArchiveVersion);
+ setDataVersion(kAssemblerDataVersion);
+ setDataDebugInfo(gen::utils::debugInformation(qbsProduct));
+
+ const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject);
+
+ buildLanguagePage(qbsProduct);
+ buildOutputPage(qbsProduct);
+ buildPreprocessorPage(buildRootDirectory, qbsProduct);
+ buildDiagnosticsPage(qbsProduct);
+}
+
+void Stm8AssemblerSettingsGroup::buildLanguagePage(
+ const ProductData &qbsProduct)
+{
+ const LanguagePageOptions opts(qbsProduct);
+ // Add 'AsmCaseSensitivity' item (User symbols are case sensitive).
+ addOptionsGroup(QByteArrayLiteral("AsmCaseSensitivity"),
+ {}, {opts.enableSymbolsCaseSensitive});
+ // Add 'AsmMultibyteSupport' item (Enable multibyte support).
+ addOptionsGroup(QByteArrayLiteral("AsmMultibyteSupport"),
+ {}, {opts.enableMultibyteSupport});
+ // Add 'AsmAllowMnemonics' item (Allow mnemonics in first column).
+ addOptionsGroup(QByteArrayLiteral("AsmAllowMnemonics"),
+ {}, {opts.allowFirstColumnMnemonics});
+ // Add 'AsmAllowDirectives' item (Allow directives in first column).
+ addOptionsGroup(QByteArrayLiteral("AsmAllowDirectives"),
+ {}, {opts.allowFirstColumnDirectives});
+
+ // Add 'AsmMacroChars' item (Macro quote characters: ()/[]/{}/<>).
+ addOptionsGroup(QByteArrayLiteral("AsmMacroChars"),
+ {0}, {opts.macroQuoteCharacter});
+}
+
+void Stm8AssemblerSettingsGroup::buildOutputPage(
+ const ProductData &qbsProduct)
+{
+ const OutputPageOptions opts(qbsProduct);
+ // Add 'AsmDebugInfo' item (Generate debug information).
+ addOptionsGroup(QByteArrayLiteral("AsmDebugInfo"),
+ {}, {opts.debugInfo});
+}
+
+void Stm8AssemblerSettingsGroup::buildPreprocessorPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ const PreprocessorPageOptions opts(baseDirectory, qbsProduct);
+ // Add 'AsmDefines' item (Defined symbols).
+ addOptionsGroup(QByteArrayLiteral("AsmDefines"),
+ {}, opts.defineSymbols);
+ // Add 'AsmIncludePath' item (Additional include directories).
+ addOptionsGroup(QByteArrayLiteral("AsmIncludePath"),
+ {}, opts.includePaths);
+}
+
+void Stm8AssemblerSettingsGroup::buildDiagnosticsPage(
+ const ProductData &qbsProduct)
+{
+ const DiagnosticsPageOptions opts(qbsProduct);
+ // Add 'AsmDiagnosticsWarningsAreErrors' item.
+ // (Treat all warnings as errors).
+ addOptionsGroup(QByteArrayLiteral("AsmDiagnosticsWarningsAreErrors"),
+ {}, {opts.warningsAsErrors});
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h
new file mode 100644
index 000000000..4d7d0485b
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H
+#define QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H
+
+#include "../../iarewsettingspropertygroup.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8AssemblerSettingsGroup final : public IarewSettingsPropertyGroup
+{
+public:
+ explicit Stm8AssemblerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+private:
+ void buildLanguagePage(const ProductData &qbsProduct);
+ void buildOutputPage(const ProductData &qbsProduct);
+ void buildPreprocessorPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+ void buildDiagnosticsPage(const ProductData &qbsProduct);
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp
new file mode 100644
index 000000000..06167f919
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8archiversettingsgroup_v3.h"
+#include "stm8assemblersettingsgroup_v3.h"
+#include "stm8buildconfigurationgroup_v3.h"
+#include "stm8compilersettingsgroup_v3.h"
+#include "stm8generalsettingsgroup_v3.h"
+#include "stm8linkersettingsgroup_v3.h"
+
+#include "../../iarewtoolchainpropertygroup.h"
+#include "../../iarewutils.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+Stm8BuildConfigurationGroup::Stm8BuildConfigurationGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+ : gen::xml::PropertyGroup("configuration")
+{
+ // Append configuration name item.
+ const QString cfgName = gen::utils::buildConfigurationName(qbsProject);
+ appendProperty("name", cfgName);
+
+ // Apend toolchain name group item.
+ appendChild<IarewToolchainPropertyGroup>("STM8");
+
+ // Append debug info item.
+ const int debugBuild = gen::utils::debugInformation(qbsProduct);
+ appendProperty("debug", debugBuild);
+
+ // Append settings group items.
+ appendChild<Stm8ArchiverSettingsGroup>(
+ qbsProject, qbsProduct, qbsProductDeps);
+ appendChild<Stm8AssemblerSettingsGroup>(
+ qbsProject, qbsProduct, qbsProductDeps);
+ appendChild<Stm8CompilerSettingsGroup>(
+ qbsProject, qbsProduct, qbsProductDeps);
+ appendChild<Stm8GeneralSettingsGroup>(
+ qbsProject, qbsProduct, qbsProductDeps);
+ appendChild<Stm8LinkerSettingsGroup>(
+ qbsProject, qbsProduct, qbsProductDeps);
+}
+
+bool Stm8BuildConfigurationGroupFactory::canCreate(
+ gen::utils::Architecture arch,
+ const Version &version) const
+{
+ return arch == gen::utils::Architecture::Stm8
+ && version.majorVersion() == 3;
+}
+
+std::unique_ptr<gen::xml::PropertyGroup>
+Stm8BuildConfigurationGroupFactory::create(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps) const
+{
+ const auto group = new Stm8BuildConfigurationGroup(
+ qbsProject, qbsProduct, qbsProductDeps);
+ return std::unique_ptr<Stm8BuildConfigurationGroup>(group);
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h
new file mode 100644
index 000000000..c47819fef
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H
+#define QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H
+
+#include <generators/generatorutils.h>
+#include <generators/xmlpropertygroup.h>
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8BuildConfigurationGroup final
+ : public gen::xml::PropertyGroup
+{
+private:
+ explicit Stm8BuildConfigurationGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+ friend class Stm8BuildConfigurationGroupFactory;
+};
+
+class Stm8BuildConfigurationGroupFactory final
+ : public gen::xml::PropertyGroupFactory
+{
+public:
+ bool canCreate(gen::utils::Architecture arch,
+ const Version &version) const final;
+
+ std::unique_ptr<gen::xml::PropertyGroup> create(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps) const final;
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp
new file mode 100644
index 000000000..23cb059a4
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp
@@ -0,0 +1,442 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8compilersettingsgroup_v3.h"
+
+#include "../../iarewutils.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+constexpr int kCompilerArchiveVersion = 3;
+constexpr int kCompilerDataVersion = 9;
+
+namespace {
+
+// Output page options.
+
+struct OutputPageOptions final
+{
+ explicit OutputPageOptions(const ProductData &qbsProduct)
+ {
+ debugInfo = gen::utils::debugInformation(qbsProduct);
+ }
+
+ int debugInfo = 0;
+};
+
+// Language one page options.
+
+struct LanguageOnePageOptions final
+{
+ enum LanguageExtension {
+ CLanguageExtension,
+ CxxLanguageExtension,
+ AutoLanguageExtension
+ };
+
+ enum CLanguageDialect {
+ C89LanguageDialect,
+ C99LanguageDialect
+ };
+
+ enum CxxLanguageDialect {
+ EmbeddedCPlusPlus,
+ ExtendedEmbeddedCPlusPlus
+ };
+
+ enum LanguageConformance {
+ AllowIarExtension,
+ RelaxedStandard,
+ StrictStandard
+ };
+
+ explicit LanguageOnePageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps);
+ // File extension based by default.
+ languageExtension = LanguageOnePageOptions::AutoLanguageExtension;
+ // C language dialect.
+ const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("cLanguageVersion")});
+ if (cLanguageVersion.contains(QLatin1String("c89")))
+ cLanguageDialect = LanguageOnePageOptions::C89LanguageDialect;
+ else if (cLanguageVersion.contains(QLatin1String("c99")))
+ cLanguageDialect = LanguageOnePageOptions::C99LanguageDialect;
+ // C++ language dialect.
+ if (flags.contains(QLatin1String("--ec++")))
+ cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus;
+ else if (flags.contains(QLatin1String("--eec++")))
+ cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus;
+ // Language conformance.
+ if (flags.contains(QLatin1String("-e")))
+ languageConformance = LanguageOnePageOptions::AllowIarExtension;
+ else if (flags.contains(QLatin1String("--strict")))
+ languageConformance = LanguageOnePageOptions::StrictStandard;
+ else
+ languageConformance = LanguageOnePageOptions::RelaxedStandard;
+
+ allowVla = flags.contains(QLatin1String("--vla"));
+ useCppInlineSemantics = flags.contains(
+ QLatin1String("--use_c++_inline"));
+ requirePrototypes = flags.contains(
+ QLatin1String("--require_prototypes"));
+ destroyStaticObjects = !flags.contains(
+ QLatin1String("--no_static_destruction"));
+ }
+
+ LanguageExtension languageExtension = AutoLanguageExtension;
+ CLanguageDialect cLanguageDialect = C99LanguageDialect;
+ CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus;
+ LanguageConformance languageConformance = AllowIarExtension;
+ int allowVla = 0;
+ int useCppInlineSemantics = 0;
+ int requirePrototypes = 0;
+ int destroyStaticObjects = 0;
+};
+
+// Language two page options.
+
+struct LanguageTwoPageOptions final
+{
+ enum PlainCharacter {
+ SignedCharacter,
+ UnsignedCharacter
+ };
+
+ enum FloatingPointSemantic {
+ StrictSemantic,
+ RelaxedSemantic
+ };
+
+ explicit LanguageTwoPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps);
+ plainCharacter = flags.contains(QLatin1String("--char_is_signed"))
+ ? LanguageTwoPageOptions::SignedCharacter
+ : LanguageTwoPageOptions::UnsignedCharacter;
+ floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp"))
+ ? LanguageTwoPageOptions::RelaxedSemantic
+ : LanguageTwoPageOptions::StrictSemantic;
+ enableMultibyteSupport = flags.contains(
+ QLatin1String("--enable_multibytes"));
+ }
+
+ PlainCharacter plainCharacter = UnsignedCharacter;
+ FloatingPointSemantic floatingPointSemantic = StrictSemantic;
+ int enableMultibyteSupport = 0;
+};
+
+// Optimizations page options.
+
+struct OptimizationsPageOptions final
+{
+ // Optimizations level radio-buttons with
+ // combo-box on "level" widget.
+ enum Strategy {
+ StrategyBalanced,
+ StrategySize,
+ StrategySpeed
+ };
+
+ enum Level {
+ LevelNone,
+ LevelLow,
+ LevelMedium,
+ LevelHigh
+ };
+
+ enum LevelSlave {
+ LevelSlave0,
+ LevelSlave1,
+ LevelSlave2,
+ LevelSlave3
+ };
+
+ enum VRegsNumber {
+ VRegs12,
+ VRegs16
+ };
+
+ explicit OptimizationsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QString optimization = gen::utils::cppStringModuleProperty(
+ qbsProps, QStringLiteral("optimization"));
+ if (optimization == QLatin1String("none")) {
+ optimizationStrategy = OptimizationsPageOptions::StrategyBalanced;
+ optimizationLevel = OptimizationsPageOptions::LevelNone;
+ optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0;
+ } else if (optimization == QLatin1String("fast")) {
+ optimizationStrategy = OptimizationsPageOptions::StrategySpeed;
+ optimizationLevel = OptimizationsPageOptions::LevelHigh;
+ optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3;
+ } else if (optimization == QLatin1String("small")) {
+ optimizationStrategy = OptimizationsPageOptions::StrategySize;
+ optimizationLevel = OptimizationsPageOptions::LevelHigh;
+ optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3;
+ }
+
+ const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps);
+
+ disableSizeConstraints = flags.contains(
+ QLatin1String("--no_size_constraints"));
+
+ enableCommonSubexpressionElimination = !flags.contains(
+ QLatin1String("--no_cse"));
+ enableLoopUnroll = !flags.contains(QLatin1String("--no_unroll"));
+ enableFunctionInlining = !flags.contains(QLatin1String("--no_inline"));
+ enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion"));
+ enableTypeBasedAliasAnalysis = !flags.contains(
+ QLatin1String("--no_tbaa"));
+ enableCrossCall = !flags.contains(QLatin1String("--no_cross_call"));
+
+ const auto vregsCount = IarewUtils::flagValue(
+ flags, QStringLiteral("--vregs")).toInt();
+ if (vregsCount == 12)
+ vregsNumber = VRegs12;
+ else if (vregsCount == 16)
+ vregsNumber = VRegs16;
+ }
+
+ Strategy optimizationStrategy = StrategyBalanced;
+ Level optimizationLevel = LevelNone;
+ LevelSlave optimizationLevelSlave = LevelSlave0;
+ // Separate "no size constraints" checkbox.
+ int disableSizeConstraints = 0;
+
+ // Six bit-field flags on "enabled transformations" widget.
+ int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination.
+ int enableLoopUnroll = 0; // Loop unrolling.
+ int enableFunctionInlining = 0; // Function inlining.
+ int enableCodeMotion = 0; // Code motion.
+ int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis.
+ int enableCrossCall = 0; // Cross call.
+
+ VRegsNumber vregsNumber = VRegs16;
+};
+
+// Preprocessor page options.
+
+struct PreprocessorPageOptions final
+{
+ explicit PreprocessorPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ defineSymbols = gen::utils::cppVariantModuleProperties(
+ qbsProps, {QStringLiteral("defines")});
+
+ const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct);
+ const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("includePaths"),
+ QStringLiteral("systemIncludePaths")});
+ for (const QString &fullIncludePath : fullIncludePaths) {
+ const QFileInfo includeFileInfo(fullIncludePath);
+ const QString includeFilePath = includeFileInfo.absoluteFilePath();
+ if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) {
+ const QString path = IarewUtils::toolkitRelativeFilePath(
+ toolkitPath, includeFilePath);
+ includePaths.push_back(path);
+ } else {
+ const QString path = IarewUtils::projectRelativeFilePath(
+ baseDirectory, includeFilePath);
+ includePaths.push_back(path);
+ }
+ }
+ }
+
+ QVariantList defineSymbols;
+ QVariantList includePaths;
+};
+
+// Diagnostics page options.
+
+struct DiagnosticsPageOptions final
+{
+ explicit DiagnosticsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ warningsAsErrors = gen::utils::cppIntegerModuleProperty(
+ qbsProps, QStringLiteral("treatWarningsAsErrors"));
+ }
+
+ int warningsAsErrors = 0;
+};
+
+} // namespace
+
+// Stm8CompilerSettingsGroup
+
+Stm8CompilerSettingsGroup::Stm8CompilerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ Q_UNUSED(qbsProductDeps)
+
+ setName(QByteArrayLiteral("ICCSTM8"));
+ setArchiveVersion(kCompilerArchiveVersion);
+ setDataVersion(kCompilerDataVersion);
+ setDataDebugInfo(gen::utils::debugInformation(qbsProduct));
+
+ const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject);
+
+ buildOutputPage(qbsProduct);
+ buildLanguageOnePage(qbsProduct);
+ buildLanguageTwoPage(qbsProduct);
+ buildOptimizationsPage(qbsProduct);
+ buildPreprocessorPage(buildRootDirectory, qbsProduct);
+ buildDiagnosticsPage(qbsProduct);
+}
+
+void Stm8CompilerSettingsGroup::buildOutputPage(
+ const ProductData &qbsProduct)
+{
+ const OutputPageOptions opts(qbsProduct);
+ // Add 'IccGenerateDebugInfo' item (Generate debug info).
+ addOptionsGroup(QByteArrayLiteral("IccGenerateDebugInfo"),
+ {}, {opts.debugInfo});
+}
+
+void Stm8CompilerSettingsGroup::buildLanguageOnePage(
+ const ProductData &qbsProduct)
+{
+ const LanguageOnePageOptions opts(qbsProduct);
+ // Add 'IccLang' item with 'auto-extension based'
+ // value (Language: C/C++/Auto).
+ addOptionsGroup(QByteArrayLiteral("IccLang"),
+ {}, {opts.languageExtension});
+ // Add 'IccCDialect' item (C dialect: c89/99/11).
+ addOptionsGroup(QByteArrayLiteral("IccCDialect"),
+ {}, {opts.cLanguageDialect});
+ // Add 'IccCppDialect' item (C++ dialect: embedded/extended).
+ addOptionsGroup(QByteArrayLiteral("IccCppDialect"),
+ {}, {opts.cxxLanguageDialect});
+ // Add 'IccLanguageConformance' item
+ // (Language conformance: IAR/relaxed/strict).
+ addOptionsGroup(QByteArrayLiteral("IccLanguageConformance"),
+ {}, {opts.languageConformance});
+ // Add 'IccAllowVLA' item (Allow VLA).
+ addOptionsGroup(QByteArrayLiteral("IccAllowVLA"),
+ {}, {opts.allowVla});
+ // Add 'IccCppInlineSemantics' item (C++ inline semantics).
+ addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"),
+ {}, {opts.useCppInlineSemantics});
+ // Add 'IccRequirePrototypes' item (Require prototypes).
+ addOptionsGroup(QByteArrayLiteral("IccRequirePrototypes"),
+ {}, {opts.requirePrototypes});
+ // Add 'IccStaticDestr' item (Destroy static objects).
+ addOptionsGroup(QByteArrayLiteral("IccStaticDestr"),
+ {}, {opts.destroyStaticObjects});
+}
+
+void Stm8CompilerSettingsGroup::buildLanguageTwoPage(
+ const ProductData &qbsProduct)
+{
+ const LanguageTwoPageOptions opts(qbsProduct);
+ // Add 'IccCharIs' item (Plain char is: signed/unsigned).
+ addOptionsGroup(QByteArrayLiteral("IccCharIs"),
+ {}, {opts.plainCharacter});
+ // Add 'IccFloatSemantics' item (Floatic-point
+ // semantics: strict/relaxed conformance).
+ addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"),
+ {}, {opts.floatingPointSemantic});
+ // Add 'IccMultibyteSupport' item (Enable multibyte support).
+ addOptionsGroup(QByteArrayLiteral("IccMultibyteSupport"),
+ {}, {opts.enableMultibyteSupport});
+}
+
+void Stm8CompilerSettingsGroup::buildOptimizationsPage(
+ const ProductData &qbsProduct)
+{
+ const OptimizationsPageOptions opts(qbsProduct);
+ // Add 'IccOptStrategy', 'IccOptLevel' and
+ // 'CCOptLevelSlave' items (Level).
+ addOptionsGroup(QByteArrayLiteral("IccOptStrategy"),
+ {}, {opts.optimizationStrategy});
+ addOptionsGroup(QByteArrayLiteral("IccOptLevel"),
+ {}, {opts.optimizationLevel});
+ addOptionsGroup(QByteArrayLiteral("IccOptLevelSlave"),
+ {}, {opts.optimizationLevelSlave});
+
+ // Add 'IccOptNoSizeConstraints' iten (no size constraints).
+ addOptionsGroup(QByteArrayLiteral("IccOptNoSizeConstraints"),
+ {}, {opts.disableSizeConstraints});
+
+ // Add 'IccOptAllowList' item
+ // (Enabled optimizations: 6 check boxes).
+ const QString bitflags = QStringLiteral("%1%2%3%4%5%6")
+ .arg(opts.enableCommonSubexpressionElimination)
+ .arg(opts.enableLoopUnroll)
+ .arg(opts.enableFunctionInlining)
+ .arg(opts.enableCodeMotion)
+ .arg(opts.enableTypeBasedAliasAnalysis)
+ .arg(opts.enableCrossCall);
+ addOptionsGroup(QByteArrayLiteral("IccOptAllowList"),
+ {}, {bitflags});
+
+ // Add 'IccNoVregs' item
+ // (Number of virtual registers (12/16).
+ addOptionsGroup(QByteArrayLiteral("IccNoVregs"),
+ {}, {opts.vregsNumber});
+}
+
+void Stm8CompilerSettingsGroup::buildPreprocessorPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ const PreprocessorPageOptions opts(baseDirectory, qbsProduct);
+ // Add 'CCDefines' item (Defines symbols).
+ addOptionsGroup(QByteArrayLiteral("CCDefines"),
+ {}, opts.defineSymbols);
+ // Add 'CCIncludePath2' item
+ // (Additional include directories).
+ addOptionsGroup(QByteArrayLiteral("CCIncludePath2"),
+ {}, opts.includePaths);
+}
+
+void Stm8CompilerSettingsGroup::buildDiagnosticsPage(
+ const ProductData &qbsProduct)
+{
+ const DiagnosticsPageOptions opts(qbsProduct);
+ // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors).
+ addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"),
+ {}, {opts.warningsAsErrors});
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h
new file mode 100644
index 000000000..48545b86d
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H
+#define QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H
+
+#include "../../iarewsettingspropertygroup.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8CompilerSettingsGroup final : public IarewSettingsPropertyGroup
+{
+public:
+ explicit Stm8CompilerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+private:
+ void buildOutputPage(const ProductData &qbsProduct);
+ void buildLanguageOnePage(const ProductData &qbsProduct);
+ void buildLanguageTwoPage(const ProductData &qbsProduct);
+ void buildOptimizationsPage(const ProductData &qbsProduct);
+ void buildPreprocessorPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+ void buildDiagnosticsPage(const ProductData &qbsProduct);
+ void buildCodePage(const ProductData &qbsProduct);
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp
new file mode 100644
index 000000000..8dff5a7dd
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp
@@ -0,0 +1,366 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8generalsettingsgroup_v3.h"
+
+#include "../../iarewutils.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+constexpr int kGeneralArchiveVersion = 4;
+constexpr int kGeneralDataVersion = 2;
+
+namespace {
+
+// Target page options.
+
+struct TargetPageOptions final
+{
+ enum CodeModel {
+ SmallCodeModel,
+ MediumCodeModel,
+ LargeCodeModel
+ };
+
+ enum DataModel {
+ SmallDataModel,
+ MediumDataModel,
+ LargeDataModel
+ };
+
+ explicit TargetPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("driverFlags")});
+ // Detect target code model.
+ const QString codeModelValue = IarewUtils::flagValue(
+ flags, QStringLiteral("--code_model"));
+ if (codeModelValue == QLatin1String("small"))
+ codeModel = TargetPageOptions::SmallCodeModel;
+ else if (codeModelValue == QLatin1String("medium"))
+ codeModel = TargetPageOptions::MediumCodeModel;
+ else if (codeModelValue == QLatin1String("large"))
+ codeModel = TargetPageOptions::LargeCodeModel;
+ // Detect target data model.
+ const QString dataModelValue = IarewUtils::flagValue(
+ flags, QStringLiteral("--code_model"));
+ if (dataModelValue == QLatin1String("small"))
+ dataModel = TargetPageOptions::SmallDataModel;
+ else if (dataModelValue == QLatin1String("medium"))
+ dataModel = TargetPageOptions::MediumDataModel;
+ else if (dataModelValue == QLatin1String("large"))
+ dataModel = TargetPageOptions::LargeDataModel;
+ }
+
+ CodeModel codeModel = MediumCodeModel;
+ DataModel dataModel = MediumDataModel;
+};
+
+// Output page options.
+
+struct OutputPageOptions final
+{
+ explicit OutputPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ binaryType = IarewUtils::outputBinaryType(qbsProduct);
+ binaryDirectory = gen::utils::binaryOutputDirectory(
+ baseDirectory, qbsProduct);
+ objectDirectory = gen::utils::objectsOutputDirectory(
+ baseDirectory, qbsProduct);
+ listingDirectory = gen::utils::listingOutputDirectory(
+ baseDirectory, qbsProduct);
+ }
+
+ IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType;
+ QString binaryDirectory;
+ QString objectDirectory;
+ QString listingDirectory;
+};
+
+// Library configuration page options.
+
+struct LibraryConfigPageOptions final
+{
+ enum RuntimeLibrary {
+ NoLibrary,
+ NormalLibrary,
+ FullLibrary,
+ CustomLibrary
+ };
+
+ explicit LibraryConfigPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps);
+
+ const QFileInfo configInfo(IarewUtils::flagValue(
+ flags,
+ QStringLiteral("--dlib_config")));
+ const QString configFilePath = configInfo.absoluteFilePath();
+
+ if (!configFilePath.isEmpty()) {
+ const QString libToolkitPath =
+ IarewUtils::libToolkitRootPath(qbsProduct);
+
+ if (configFilePath.startsWith(libToolkitPath,
+ Qt::CaseInsensitive)) {
+ if (configFilePath.endsWith(QLatin1String("n.h"),
+ Qt::CaseInsensitive)) {
+ libraryType = LibraryConfigPageOptions::NormalLibrary;
+ } else if (configFilePath.endsWith(QLatin1String("f.h"),
+ Qt::CaseInsensitive)) {
+ libraryType = LibraryConfigPageOptions::FullLibrary;
+ } else {
+ libraryType = LibraryConfigPageOptions::CustomLibrary;
+ }
+
+ configPath = IarewUtils::toolkitRelativeFilePath(
+ baseDirectory, configFilePath);
+ } else {
+ libraryType = LibraryConfigPageOptions::CustomLibrary;
+
+ configPath = configFilePath;
+ }
+ } else {
+ libraryType = LibraryConfigPageOptions::NoLibrary;
+ }
+ }
+
+ RuntimeLibrary libraryType = NoLibrary;
+ QString configPath;
+};
+
+// Library options page options.
+
+struct LibraryOptionsPageOptions final
+{
+ enum PrintfFormatter {
+ PrintfAutoFormatter = 0,
+ PrintfFullFormatter = 1,
+ PrintfFullNoMultibytesFormatter = 2,
+ PrintfLargeFormatter = 3,
+ PrintfLargeNoMultibytesFormatter = 4,
+ PrintfSmallFormatter = 5,
+ PrintfSmallNoMultibytesFormatter = 6,
+ PrintfTinyFormatter = 7
+ };
+
+ enum ScanfFormatter {
+ ScanfAutoFormatter = 0,
+ ScanfFullFormatter = 1,
+ ScanfFullNoMultibytesFormatter = 2,
+ ScanfLargeFormatter = 3,
+ ScanfLargeNoMultibytesFormatter = 4,
+ ScanfSmallFormatter = 5,
+ ScanfSmallNoMultibytesFormatter = 6
+ };
+
+ explicit LibraryOptionsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+ for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) {
+ if (*flagIt != QLatin1String("--redirect"))
+ continue;
+ ++flagIt;
+ if (flagIt->startsWith(QLatin1String("_printf="),
+ Qt::CaseInsensitive)) {
+ const QString prop = flagIt->split(
+ QLatin1Char('=')).at(1).toLower();
+ if (prop == QLatin1String("_printffull"))
+ printfFormatter = PrintfFullFormatter;
+ else if (prop == QLatin1String("_printffullnomb"))
+ printfFormatter = PrintfFullNoMultibytesFormatter;
+ else if (prop == QLatin1String("_printflarge"))
+ printfFormatter = PrintfLargeFormatter;
+ else if (prop == QLatin1String("_printflargenomb"))
+ printfFormatter = PrintfLargeFormatter;
+ else if (prop == QLatin1String("_printfsmall"))
+ printfFormatter = PrintfSmallFormatter;
+ else if (prop == QLatin1String("_printfsmallnomb"))
+ printfFormatter = PrintfSmallNoMultibytesFormatter;
+ else if (prop == QLatin1String("_printftiny"))
+ printfFormatter = PrintfTinyFormatter;
+ } else if (flagIt->startsWith(QLatin1String("_scanf="),
+ Qt::CaseInsensitive)) {
+ const QString prop = flagIt->split(
+ QLatin1Char('=')).at(1).toLower();
+ if (prop == QLatin1String("_scanffull"))
+ scanfFormatter = ScanfFullFormatter;
+ else if (prop == QLatin1String("_scanffullnomb"))
+ scanfFormatter = ScanfFullNoMultibytesFormatter;
+ else if (prop == QLatin1String("_scanflarge"))
+ scanfFormatter = ScanfLargeFormatter;
+ else if (prop == QLatin1String("_scanflargenomb"))
+ scanfFormatter = ScanfLargeFormatter;
+ else if (prop == QLatin1String("_scanfsmall"))
+ scanfFormatter = ScanfSmallFormatter;
+ else if (prop == QLatin1String("_scanfsmallnomb"))
+ scanfFormatter = ScanfSmallNoMultibytesFormatter;
+ }
+ }
+ }
+
+ PrintfFormatter printfFormatter = PrintfAutoFormatter;
+ ScanfFormatter scanfFormatter = ScanfAutoFormatter;
+};
+
+// Stack/heap page options.
+
+struct StackHeapPageOptions final
+{
+ explicit StackHeapPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+ const auto configDefs = IarewUtils::flagValues(
+ flags, QStringLiteral("--config_def"));
+ for (const auto &configDef : configDefs) {
+ const auto def = configDef.toString();
+ if (def.startsWith(QLatin1String("_CSTACK_SIZE="))) {
+ stackSize = def.split(QLatin1Char('=')).at(1);
+ } else if (def.startsWith(QLatin1String("_HEAP_SIZE="))) {
+ heapSize = def.split(QLatin1Char('=')).at(1);
+ }
+ }
+ }
+
+ QString stackSize;
+ QString heapSize;
+};
+
+} // namespace
+
+// Stm8GeneralSettingsGroup
+
+Stm8GeneralSettingsGroup::Stm8GeneralSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ Q_UNUSED(qbsProductDeps)
+
+ setName(QByteArrayLiteral("General"));
+ setArchiveVersion(kGeneralArchiveVersion);
+ setDataVersion(kGeneralDataVersion);
+ setDataDebugInfo(gen::utils::debugInformation(qbsProduct));
+
+ const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject);
+
+ buildTargetPage(qbsProduct);
+ buildOutputPage(buildRootDirectory, qbsProduct);
+ buildLibraryConfigPage(buildRootDirectory, qbsProduct);
+ buildLibraryOptionsPage(qbsProduct);
+ buildStackHeapPage(qbsProduct);
+}
+
+void Stm8GeneralSettingsGroup::buildTargetPage(
+ const ProductData &qbsProduct)
+{
+ const TargetPageOptions opts(qbsProduct);
+ // Add 'GenCodeModel' item
+ // (Code model: small/medium/large).
+ addOptionsGroup(QByteArrayLiteral("GenCodeModel"),
+ {}, {opts.codeModel});
+ // Add 'GenDataModel' item
+ // (Data model: small/medium/large).
+ addOptionsGroup(QByteArrayLiteral("GenDataModel"),
+ {}, {opts.dataModel});
+}
+
+void Stm8GeneralSettingsGroup::buildOutputPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ const OutputPageOptions opts(baseDirectory, qbsProduct);
+ // Add 'GOutputBinary' item (Output file: executable/library).
+ addOptionsGroup(QByteArrayLiteral("GOutputBinary"),
+ {}, {opts.binaryType});
+ // Add 'ExePath' item (Executable/binaries output directory).
+ addOptionsGroup(QByteArrayLiteral("ExePath"),
+ {}, {opts.binaryDirectory});
+ // Add 'ObjPath' item (Object files output directory).
+ addOptionsGroup(QByteArrayLiteral("ObjPath"),
+ {}, {opts.objectDirectory});
+ // Add 'ListPath' item (List files output directory).
+ addOptionsGroup(QByteArrayLiteral("ListPath"),
+ {}, {opts.listingDirectory});
+}
+
+void Stm8GeneralSettingsGroup::buildLibraryConfigPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ const LibraryConfigPageOptions opts(baseDirectory, qbsProduct);
+ // Add 'GenRuntimeLibSelect' and 'GenRuntimeLibSelectSlave' items
+ // (Link with runtime: none/normal/full/custom).
+ addOptionsGroup(QByteArrayLiteral("GenRuntimeLibSelect"),
+ {}, {opts.libraryType});
+ addOptionsGroup(QByteArrayLiteral("GenRuntimeLibSelectSlave"),
+ {}, {opts.libraryType});
+ // Add 'GenRTConfigPath' item (Runtime configuration file).
+ addOptionsGroup(QByteArrayLiteral("GenRTConfigPath"),
+ {}, {opts.configPath});
+}
+
+void Stm8GeneralSettingsGroup::buildLibraryOptionsPage(
+ const ProductData &qbsProduct)
+{
+ const LibraryOptionsPageOptions opts(qbsProduct);
+ // Add 'GenLibOutFormatter' item (Printf formatter).
+ addOptionsGroup(QByteArrayLiteral("GenLibOutFormatter"),
+ {}, {opts.printfFormatter});
+ // Add 'GenLibInFormatter' item (Scanf formatter).
+ addOptionsGroup(QByteArrayLiteral("GenLibInFormatter"),
+ {}, {opts.scanfFormatter});
+}
+
+void Stm8GeneralSettingsGroup::buildStackHeapPage(
+ const ProductData &qbsProduct)
+{
+ const StackHeapPageOptions opts(qbsProduct);
+ // Add 'GenStackSize' item (Stack size).
+ addOptionsGroup(QByteArrayLiteral("GenStackSize"),
+ {}, {opts.stackSize});
+ // Add 'GenHeapSize' item (Heap size).
+ addOptionsGroup(QByteArrayLiteral("GenHeapSize"),
+ {}, {opts.heapSize});
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h
new file mode 100644
index 000000000..20def0fd5
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H
+#define QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H
+
+#include "../../iarewsettingspropertygroup.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8GeneralSettingsGroup final : public IarewSettingsPropertyGroup
+{
+public:
+ explicit Stm8GeneralSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+private:
+ void buildTargetPage(const ProductData &qbsProduct);
+ void buildOutputPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+ void buildLibraryConfigPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+ void buildLibraryOptionsPage(const ProductData &qbsProduct);
+ void buildStackHeapPage(const ProductData &qbsProduct);
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp
new file mode 100644
index 000000000..dc74587d4
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp
@@ -0,0 +1,411 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "stm8linkersettingsgroup_v3.h"
+
+#include "../../iarewutils.h"
+
+#include <QtCore/qdir.h>
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+constexpr int kLinkerArchiveVersion = 5;
+constexpr int kLinkerDataVersion = 4;
+
+namespace {
+
+// Config page options.
+
+struct ConfigPageOptions final
+{
+ explicit ConfigPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct);
+
+ // Enumerate all product linker config files
+ // (which are set trough 'linkerscript' tag).
+ const auto qbsGroups = qbsProduct.groups();
+ for (const auto &qbsGroup : qbsGroups) {
+ const auto qbsArtifacts = qbsGroup.sourceArtifacts();
+ for (const auto &qbsArtifact : qbsArtifacts) {
+ const auto qbsTags = qbsArtifact.fileTags();
+ if (!qbsTags.contains(QLatin1String("linkerscript")))
+ continue;
+ const QString fullConfigPath = qbsArtifact.filePath();
+ if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) {
+ const QString path = IarewUtils::toolkitRelativeFilePath(
+ toolkitPath, fullConfigPath);
+ configFilePaths.push_back(path);
+ } else {
+ const QString path = IarewUtils::projectRelativeFilePath(
+ baseDirectory, fullConfigPath);
+ configFilePaths.push_back(path);
+ }
+ }
+ }
+
+ // Enumerate all product linker config files
+ // (which are set trough '-config' option).
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+ const QVariantList configPathValues = IarewUtils::flagValues(
+ flags, QStringLiteral("--config"));
+ for (const QVariant &configPathValue : configPathValues) {
+ const QString fullConfigPath = configPathValue.toString();
+ if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) {
+ const QString path = IarewUtils::toolkitRelativeFilePath(
+ toolkitPath, fullConfigPath);
+ if (!configFilePaths.contains(path))
+ configFilePaths.push_back(path);
+ } else {
+ const QString path = IarewUtils::projectRelativeFilePath(
+ baseDirectory, fullConfigPath);
+ if (!configFilePaths.contains(path))
+ configFilePaths.push_back(path);
+ }
+ }
+
+ // Enumerate all config definition symbols (except
+ // the CSTACK_SIZE and HEAP_SIZE which are handles
+ // on the general page).
+ configDefinitions = IarewUtils::flagValues(
+ flags, QStringLiteral("--config_def"));
+ configDefinitions.erase(std::remove_if(
+ configDefinitions.begin(),
+ configDefinitions.end(),
+ [](const auto &definition){
+ const auto def = definition.toString();
+ return def.startsWith(QLatin1String("_CSTACK_SIZE"))
+ || def.startsWith(QLatin1String("_HEAP_SIZE"));
+ }), configDefinitions.end());
+ }
+
+ QVariantList configFilePaths;
+ QVariantList configDefinitions;
+};
+
+struct LibraryPageOptions final
+{
+ explicit LibraryPageOptions(const QString &baseDirectory,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct);
+
+ entryPoint = gen::utils::cppStringModuleProperty(
+ qbsProps, QStringLiteral("entryPoint"));
+
+ // Add static libraries paths.
+ const QStringList staticLibrariesProps =
+ gen::utils::cppStringModuleProperties(
+ qbsProps, {QStringLiteral("staticLibraries")});
+ for (const QString &staticLibrary : staticLibrariesProps) {
+ const QFileInfo staticLibraryInfo(staticLibrary);
+ if (staticLibraryInfo.isAbsolute()) {
+ const QString fullStaticLibraryPath =
+ staticLibraryInfo.absoluteFilePath();
+ if (fullStaticLibraryPath.startsWith(toolkitPath,
+ Qt::CaseInsensitive)) {
+ const QString path = IarewUtils::toolkitRelativeFilePath(
+ toolkitPath, fullStaticLibraryPath);
+ staticLibraries.push_back(path);
+ } else {
+ const QString path = IarewUtils::projectRelativeFilePath(
+ baseDirectory, fullStaticLibraryPath);
+ staticLibraries.push_back(path);
+ }
+ } else {
+ staticLibraries.push_back(staticLibrary);
+ }
+ }
+
+ // Add static libraries from product dependencies.
+ for (const ProductData &qbsProductDep : qbsProductDeps) {
+ const QString depBinaryPath = QLatin1String("$PROJ_DIR$/")
+ + gen::utils::targetBinaryPath(baseDirectory,
+ qbsProductDep);
+ staticLibraries.push_back(depBinaryPath);
+ }
+ }
+
+ QString entryPoint;
+ QVariantList staticLibraries;
+};
+
+struct OptimizationsPageOptions final
+{
+ explicit OptimizationsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+
+ mergeDuplicateSections = flags.contains(
+ QLatin1String("--merge_duplicate_sections"));
+ }
+
+ bool mergeDuplicateSections = 0;
+};
+
+// Output page options.
+
+struct OutputPageOptions final
+{
+ explicit OutputPageOptions(const ProductData &qbsProduct)
+ {
+ outputFile = gen::utils::targetBinary(qbsProduct);
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+
+ enableDebugInfo = !flags.contains(QLatin1String("--strip"));
+ }
+
+ QString outputFile;
+ bool enableDebugInfo = 1;
+};
+
+// List page options.
+
+struct ListPageOptions final
+{
+ enum ListingAction {
+ NoListing,
+ GenerateListing
+ };
+
+ explicit ListPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ generateMap = gen::utils::cppBooleanModuleProperty(
+ qbsProps, QStringLiteral("generateMapFile"))
+ ? ListPageOptions::GenerateListing
+ : ListPageOptions::NoListing;
+ }
+
+ ListingAction generateMap = NoListing;
+};
+
+// Define page options.
+
+struct DefinePageOptions final
+{
+ explicit DefinePageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps);
+
+ defineSymbols = IarewUtils::flagValues(
+ flags, QStringLiteral("--define_symbol"));
+ }
+
+ QVariantList defineSymbols;
+};
+
+// Diagnostics page options.
+
+struct DiagnosticsPageOptions final
+{
+ explicit DiagnosticsPageOptions(const ProductData &qbsProduct)
+ {
+ const auto &qbsProps = qbsProduct.moduleProperties();
+ warningsAsErrors = gen::utils::cppIntegerModuleProperty(
+ qbsProps, QStringLiteral("treatWarningsAsErrors"));
+ }
+
+ int warningsAsErrors = 0;
+};
+
+} // namespace
+
+// Stm8LinkerSettingsGroup
+
+Stm8LinkerSettingsGroup::Stm8LinkerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ setName(QByteArrayLiteral("ILINK"));
+ setArchiveVersion(kLinkerArchiveVersion);
+ setDataVersion(kLinkerDataVersion);
+ setDataDebugInfo(gen::utils::debugInformation(qbsProduct));
+
+ const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject);
+
+ buildConfigPage(buildRootDirectory, qbsProduct);
+ buildLibraryPage(buildRootDirectory, qbsProduct, qbsProductDeps);
+ buildOptimizationsPage(qbsProduct);
+ buildOutputPage(qbsProduct);
+ buildListPage(qbsProduct);
+ buildDefinePage(qbsProduct);
+ buildDiagnosticsPage(qbsProduct);
+
+ // Should be called as latest stage!
+ buildExtraOptionsPage(qbsProduct);
+}
+
+void Stm8LinkerSettingsGroup::buildConfigPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct)
+{
+ ConfigPageOptions opts(baseDirectory, qbsProduct);
+
+ if (opts.configFilePaths.count() > 0) {
+ // Note: IAR IDE does not allow to specify a multiple config files,
+ // although the IAR linker support it. So, we use followig 'trick':
+ // we take a first config file and to add it as usual to required items;
+ // and then an other remainders we forward to the "Extra options page".
+ const QVariant configPath = opts.configFilePaths.takeFirst();
+ // Add 'IlinkIcfOverride' item (Override default).
+ addOptionsGroup(QByteArrayLiteral("IlinkIcfOverride"),
+ {}, {1});
+ // Add 'IlinkIcfFile' item (Linke configuration file).
+ addOptionsGroup(QByteArrayLiteral("IlinkIcfFile"),
+ {}, {configPath});
+
+ // Add remainder configuration files to the "Extra options page".
+ if (!opts.configFilePaths.isEmpty()) {
+ for (QVariant &configPath : opts.configFilePaths)
+ configPath = QLatin1String("--config ") + configPath.toString();
+
+ m_extraOptions << opts.configFilePaths;
+ }
+ }
+
+ // Add 'IlinkConfigDefines' item (Configuration file
+ // symbol definitions).
+ addOptionsGroup(QByteArrayLiteral("IlinkConfigDefines"),
+ {}, opts.configDefinitions);
+}
+
+void Stm8LinkerSettingsGroup::buildLibraryPage(
+ const QString &baseDirectory,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps)
+{
+ LibraryPageOptions opts(baseDirectory, qbsProduct, qbsProductDeps);
+
+ // Add 'IlinkOverrideProgramEntryLabel' item
+ // (Override default program entry).
+ addOptionsGroup(QByteArrayLiteral("IlinkOverrideProgramEntryLabel"),
+ {}, {1});
+
+ if (opts.entryPoint.isEmpty()) {
+ // Add 'IlinkProgramEntryLabelSelect' item
+ // (Defined by application).
+ addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabelSelect"),
+ {}, {1});
+ } else {
+ // Add 'IlinkProgramEntryLabel' item
+ // (Entry symbol).
+ addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabel"),
+ {}, {opts.entryPoint});
+ }
+
+ // Add 'IlinkAdditionalLibs' item (Additional libraries).
+ addOptionsGroup(QByteArrayLiteral("IlinkAdditionalLibs"),
+ {}, {opts.staticLibraries});
+}
+
+void Stm8LinkerSettingsGroup::buildOptimizationsPage(
+ const ProductData &qbsProduct)
+{
+ OptimizationsPageOptions opts(qbsProduct);
+
+ // Add 'IlinkOptMergeDuplSections' item
+ // (Merge duplicate sections).
+ addOptionsGroup(QByteArrayLiteral("IlinkOptMergeDuplSections"),
+ {}, {opts.mergeDuplicateSections});
+}
+
+void Stm8LinkerSettingsGroup::buildOutputPage(
+ const ProductData &qbsProduct)
+{
+ const OutputPageOptions opts(qbsProduct);
+
+ // Add 'IlinkOutputFile' item (Output file name).
+ addOptionsGroup(QByteArrayLiteral("IlinkOutputFile"),
+ {}, {opts.outputFile});
+ // Add 'IlinkDebugInfoEnable' item
+ // (Include debug information in output).
+ addOptionsGroup(QByteArrayLiteral("IlinkDebugInfoEnable"),
+ {}, {opts.enableDebugInfo});
+}
+
+void Stm8LinkerSettingsGroup::buildListPage(
+ const ProductData &qbsProduct)
+{
+ const ListPageOptions opts(qbsProduct);
+ // Add 'IlinkMapFile' item (Generate linker map file).
+ addOptionsGroup(QByteArrayLiteral("IlinkMapFile"),
+ {}, {opts.generateMap});
+}
+
+void Stm8LinkerSettingsGroup::buildDefinePage(
+ const ProductData &qbsProduct)
+{
+ const DefinePageOptions opts(qbsProduct);
+ // Add 'IlinkDefines' item (Defined symbols).
+ addOptionsGroup(QByteArrayLiteral("IlinkDefines"),
+ {}, opts.defineSymbols);
+}
+
+void Stm8LinkerSettingsGroup::buildDiagnosticsPage(
+ const ProductData &qbsProduct)
+{
+ const DiagnosticsPageOptions opts(qbsProduct);
+ // Add 'IlinkWarningsAreErrors' item (Treat all warnings as errors).
+ addOptionsGroup(QByteArrayLiteral("IlinkWarningsAreErrors"),
+ {}, {opts.warningsAsErrors});
+}
+
+void Stm8LinkerSettingsGroup::buildExtraOptionsPage(
+ const ProductData &qbsProduct)
+{
+ Q_UNUSED(qbsProduct)
+
+ if (m_extraOptions.isEmpty())
+ return;
+
+ // Add 'IlinkUseExtraOptions' (Use command line options).
+ addOptionsGroup(QByteArrayLiteral("IlinkUseExtraOptions"),
+ {}, {1});
+ // Add 'IlinkExtraOptions' item (Command line options).
+ addOptionsGroup(QByteArrayLiteral("IlinkExtraOptions"),
+ {}, m_extraOptions);
+}
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
diff --git a/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h
new file mode 100644
index 000000000..b214ebe35
--- /dev/null
+++ b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** 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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://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 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H
+#define QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H
+
+#include "../../iarewsettingspropertygroup.h"
+
+namespace qbs {
+namespace iarew {
+namespace stm8 {
+namespace v3 {
+
+class Stm8LinkerSettingsGroup final : public IarewSettingsPropertyGroup
+{
+public:
+ explicit Stm8LinkerSettingsGroup(
+ const Project &qbsProject,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+
+private:
+ void buildConfigPage(const QString &baseDirectory,
+ const ProductData &qbsProduct);
+ void buildLibraryPage(const QString &baseDirectory,
+ const ProductData &qbsProduct,
+ const std::vector<ProductData> &qbsProductDeps);
+ void buildOptimizationsPage(const ProductData &qbsProduct);
+
+
+
+ void buildOutputPage(const ProductData &qbsProduct);
+ void buildListPage(const ProductData &qbsProduct);
+ void buildDefinePage(const ProductData &qbsProduct);
+ void buildDiagnosticsPage(const ProductData &qbsProduct);
+ void buildExtraOptionsPage(const ProductData &qbsProduct);
+
+ QVariantList m_extraOptions;
+};
+
+} // namespace v3
+} // namespace stm8
+} // namespace iarew
+} // namespace qbs
+
+#endif // QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H
diff --git a/src/plugins/generator/iarew/iarew.pro b/src/plugins/generator/iarew/iarew.pro
index ec61f758f..d931f365f 100644
--- a/src/plugins/generator/iarew/iarew.pro
+++ b/src/plugins/generator/iarew/iarew.pro
@@ -95,3 +95,21 @@ SOURCES += \
$$PWD/archs/mcs51/mcs51compilersettingsgroup_v10.cpp \
$$PWD/archs/mcs51/mcs51generalsettingsgroup_v10.cpp \
$$PWD/archs/mcs51/mcs51linkersettingsgroup_v10.cpp
+
+# For STM8 architecture.
+
+HEADERS += \
+ $$PWD/archs/stm8/stm8archiversettingsgroup_v3.h \
+ $$PWD/archs/stm8/stm8assemblersettingsgroup_v3.h \
+ $$PWD/archs/stm8/stm8buildconfigurationgroup_v3.h \
+ $$PWD/archs/stm8/stm8compilersettingsgroup_v3.h \
+ $$PWD/archs/stm8/stm8generalsettingsgroup_v3.h \
+ $$PWD/archs/stm8/stm8linkersettingsgroup_v3.h
+
+SOURCES += \
+ $$PWD/archs/stm8/stm8archiversettingsgroup_v3.cpp \
+ $$PWD/archs/stm8/stm8assemblersettingsgroup_v3.cpp \
+ $$PWD/archs/stm8/stm8buildconfigurationgroup_v3.cpp \
+ $$PWD/archs/stm8/stm8compilersettingsgroup_v3.cpp \
+ $$PWD/archs/stm8/stm8generalsettingsgroup_v3.cpp \
+ $$PWD/archs/stm8/stm8linkersettingsgroup_v3.cpp
diff --git a/src/plugins/generator/iarew/iarew.qbs b/src/plugins/generator/iarew/iarew.qbs
index 46ab43160..bfa2093fa 100644
--- a/src/plugins/generator/iarew/iarew.qbs
+++ b/src/plugins/generator/iarew/iarew.qbs
@@ -93,4 +93,22 @@ QbsPlugin {
"mcs51linkersettingsgroup_v10.h",
]
}
+ Group {
+ name: "IAR EW generator for STM8"
+ prefix: "archs/stm8/"
+ files: [
+ "stm8archiversettingsgroup_v3.cpp",
+ "stm8archiversettingsgroup_v3.h",
+ "stm8assemblersettingsgroup_v3.cpp",
+ "stm8assemblersettingsgroup_v3.h",
+ "stm8buildconfigurationgroup_v3.cpp",
+ "stm8buildconfigurationgroup_v3.h",
+ "stm8compilersettingsgroup_v3.cpp",
+ "stm8compilersettingsgroup_v3.h",
+ "stm8generalsettingsgroup_v3.cpp",
+ "stm8generalsettingsgroup_v3.h",
+ "stm8linkersettingsgroup_v3.cpp",
+ "stm8linkersettingsgroup_v3.h",
+ ]
+ }
}
diff --git a/src/plugins/generator/iarew/iarewproject.cpp b/src/plugins/generator/iarew/iarewproject.cpp
index 7fbad251f..17e69fa31 100644
--- a/src/plugins/generator/iarew/iarewproject.cpp
+++ b/src/plugins/generator/iarew/iarewproject.cpp
@@ -37,6 +37,7 @@
#include "archs/arm/armbuildconfigurationgroup_v8.h"
#include "archs/avr/avrbuildconfigurationgroup_v7.h"
#include "archs/mcs51/mcs51buildconfigurationgroup_v10.h"
+#include "archs/stm8/stm8buildconfigurationgroup_v3.h"
#include <logging/translator.h>
@@ -56,6 +57,8 @@ IarewProject::IarewProject(const GeneratableProject &genProject,
iarew::avr::v7::AvrBuildConfigurationGroupFactory>());
m_factories.push_back(std::make_unique<
iarew::mcs51::v10::Mcs51BuildConfigurationGroupFactory>());
+ m_factories.push_back(std::make_unique<
+ iarew::stm8::v3::Stm8BuildConfigurationGroupFactory>());
// Construct file version item.
appendChild<IarewFileVersionProperty>(versionInfo);
diff --git a/src/plugins/generator/iarew/iarewutils.cpp b/src/plugins/generator/iarew/iarewutils.cpp
index da6237df7..f00fce026 100644
--- a/src/plugins/generator/iarew/iarewutils.cpp
+++ b/src/plugins/generator/iarew/iarewutils.cpp
@@ -55,6 +55,11 @@ QString clibToolkitRootPath(const ProductData &qbsProduct)
return toolkitRootPath(qbsProduct) + QLatin1String("/lib/clib");
}
+QString libToolkitRootPath(const ProductData &qbsProduct)
+{
+ return toolkitRootPath(qbsProduct) + QLatin1String("/lib");
+}
+
QString toolkitRelativeFilePath(const QString &basePath,
const QString &fullFilePath)
{
diff --git a/src/plugins/generator/iarew/iarewutils.h b/src/plugins/generator/iarew/iarewutils.h
index 6599c27e3..2d32ac188 100644
--- a/src/plugins/generator/iarew/iarewutils.h
+++ b/src/plugins/generator/iarew/iarewutils.h
@@ -51,6 +51,8 @@ QString dlibToolkitRootPath(const ProductData &qbsProduct);
QString clibToolkitRootPath(const ProductData &qbsProduct);
+QString libToolkitRootPath(const ProductData &qbsProduct);
+
QString toolkitRelativeFilePath(const QString &basePath,
const QString &fullFilePath);
diff --git a/src/plugins/generator/iarew/iarewversioninfo.cpp b/src/plugins/generator/iarew/iarewversioninfo.cpp
index 7191948ad..2fc14d515 100644
--- a/src/plugins/generator/iarew/iarewversioninfo.cpp
+++ b/src/plugins/generator/iarew/iarewversioninfo.cpp
@@ -56,6 +56,7 @@ std::set<IarewVersionInfo> IarewVersionInfo::knownVersions()
{Version(8), {gen::utils::Architecture::Arm}},
{Version(7), {gen::utils::Architecture::Avr}},
{Version(10), {gen::utils::Architecture::Mcs51}},
+ {Version(3), {gen::utils::Architecture::Stm8}},
};
return known;
}