From d26435fcadb71161caa1789e5ef26ace2e035073 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 8 Jul 2019 14:53:32 +0300 Subject: baremetal: Long live the IAR EW project generator for AVR Right now it is possible to generate a native projects for the IAR Embedded Workbench IDE for Microchip AVR architecture, e.g. using the following command: qbs generate -g iarew7 -d -f 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 'iarew7' generator which allow to generate a projects for the IAR EW for AVR for all versions of 7 series. Tested with the IAR EW for AVR v7.20.1, using as the QBS bare-metal examples, and as other projects. Change-Id: Ic5811e579e86b868d5946637db9d8780ef47968b Reviewed-by: Ivan Komissarov Reviewed-by: Christian Kandeler --- doc/qbs.qdoc | 1 + .../archs/avr/avrarchiversettingsgroup_v7.cpp | 91 +++ .../iarew/archs/avr/avrarchiversettingsgroup_v7.h | 54 ++ .../archs/avr/avrassemblersettingsgroup_v7.cpp | 222 ++++++ .../iarew/archs/avr/avrassemblersettingsgroup_v7.h | 57 ++ .../archs/avr/avrbuildconfigurationgroup_v7.cpp | 93 +++ .../archs/avr/avrbuildconfigurationgroup_v7.h | 64 ++ .../archs/avr/avrcompilersettingsgroup_v7.cpp | 470 +++++++++++++ .../iarew/archs/avr/avrcompilersettingsgroup_v7.h | 60 ++ .../iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp | 764 +++++++++++++++++++++ .../iarew/archs/avr/avrgeneralsettingsgroup_v7.h | 59 ++ .../iarew/archs/avr/avrlinkersettingsgroup_v7.cpp | 383 +++++++++++ .../iarew/archs/avr/avrlinkersettingsgroup_v7.h | 62 ++ src/plugins/generator/iarew/iarew.pro | 18 + src/plugins/generator/iarew/iarew.qbs | 18 + src/plugins/generator/iarew/iarewproject.cpp | 2 + src/plugins/generator/iarew/iarewversioninfo.cpp | 1 + 17 files changed, 2419 insertions(+) create mode 100644 src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc index d0129005b..56eea0e92 100644 --- a/doc/qbs.qdoc +++ b/doc/qbs.qdoc @@ -1767,6 +1767,7 @@ \table \header \li Generator \li IAR EW Version \li Target Architecture \row \li iarew8 \li All 8.x.y versions \li ARM + \row \li iarew7 \li All 7.x.y versions \li AVR \endtable \section1 Generating Clang Compilation Databases diff --git a/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp new file mode 100644 index 000000000..2769e8a0d --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrarchiversettingsgroup_v7.h" + +#include "../../iarewproperty.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace v7 { + +constexpr int kArchiverArchiveVersion = 2; +constexpr int kArchiverDataVersion = 0; + +namespace ArmArchiver { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + IarewUtils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace ArmArchiver + +// AvrArchiverSettingsGroup + +AvrArchiverSettingsGroup::AvrArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XAR")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(IarewUtils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = IarewUtils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void AvrArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const ArmArchiver::OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'XAROutOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XAROutOverride"), + {}, {1}); + // Add 'OutputFile' item (Output filename). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {}, {opts.outputFile}); +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h new file mode 100644 index 000000000..fca1ec328 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRARCHIVERSETTINGSGROUP_V7_H +#define QBS_AVRARCHIVERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrArchiverSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace qbs + +#endif // QBS_AVRARCHIVERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp new file mode 100644 index 000000000..93233d041 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrassemblersettingsgroup_v7.h" + +#include "../../iarewproperty.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace v7 { + +constexpr int kAssemblerArchiveVersion = 5; +constexpr int kAssemblerDataVersion = 11; + +namespace AvrAssembler { + +// 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 = IarewUtils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = flags.contains(QLatin1String("-s+")); + enableMultibyteSupport = flags.contains(QLatin1String("-n")); + + 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; + } + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; + int enableSymbolsCaseSensitive = 0; + int enableMultibyteSupport = 0; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = IarewUtils::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 = IarewUtils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = IarewUtils::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(); + const QString warningLevel = IarewUtils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (warningLevel == QLatin1String("all")) { + enableWarnings = 0; + enableAllWarnings = 0; + } else if (warningLevel == QLatin1String("none")) { + enableWarnings = 1; + enableAllWarnings = 0; + } else { + enableWarnings = 0; + enableAllWarnings = 1; + } + } + + int enableWarnings = 0; + int enableAllWarnings = 0; +}; + +} // namespace AvrAssembler + +// AvrAssemblerSettingsGroup + +AvrAssemblerSettingsGroup::AvrAssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("AAVR")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(IarewUtils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = IarewUtils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void AvrAssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const AvrAssembler::LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {}, {opts.enableSymbolsCaseSensitive}); + // Add 'AsmMultiByteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("AsmMultiByteSupport"), + {}, {opts.enableMultibyteSupport}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {0}, {opts.macroQuoteCharacter}); +} + +void AvrAssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const AvrAssembler::OutputPageOptions opts(qbsProduct); + // Add 'CDebug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("CDebug"), + {}, {opts.debugInfo}); +} + +void AvrAssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const AvrAssembler::PreprocessorPageOptions opts(baseDirectory, + qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + {}, opts.defineSymbols); + // Add 'AUserIncludes' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("ANewIncludes"), + {}, opts.includePaths); +} + +void AvrAssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const AvrAssembler::DiagnosticsPageOptions opts(qbsProduct); + // Add 'AWarnEnable' item (Enable/disable warnings). + addOptionsGroup(QByteArrayLiteral("AWarnEnable"), + {}, {opts.enableWarnings}); + // Add 'AWarnWhat' item (Enable/disable all warnings). + addOptionsGroup(QByteArrayLiteral("AWarnWhat"), + {}, {opts.enableAllWarnings}); +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h new file mode 100644 index 000000000..8cc47d0c1 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRASSEMBLERSETTINGSGROUP_V7_H +#define QBS_AVRASSEMBLERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrAssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrAssemblerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &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 v7 +} // namespace qbs + +#endif // QBS_AVRASSEMBLERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp new file mode 100644 index 000000000..32350550c --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrarchiversettingsgroup_v7.h" +#include "avrassemblersettingsgroup_v7.h" +#include "avrbuildconfigurationgroup_v7.h" +#include "avrcompilersettingsgroup_v7.h" +#include "avrgeneralsettingsgroup_v7.h" +#include "avrlinkersettingsgroup_v7.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace v7 { + +AvrBuildConfigurationGroup::AvrBuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : IarewPropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = IarewUtils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("AVR"); + + // Append debug info item. + const int debugBuild = IarewUtils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool AvrBuildConfigurationGroupFactory::canCreate( + IarewUtils::Architecture architecture, + const Version &version) const +{ + return architecture == IarewUtils::Architecture::AvrArchitecture + && version.majorVersion() == 7; +} + +std::unique_ptr AvrBuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new AvrBuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h new file mode 100644 index 000000000..026fc5d01 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRBUILDCONFIGURATIONGROUP_V7_H +#define QBS_AVRBUILDCONFIGURATIONGROUP_V7_H + +#include "../../iarewpropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrBuildConfigurationGroup final : public IarewPropertyGroup +{ +private: + explicit AvrBuildConfigurationGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class AvrBuildConfigurationGroupFactory; +}; + +class AvrBuildConfigurationGroupFactory final : public IarewPropertyGroupFactory +{ +public: + bool canCreate(IarewUtils::Architecture architecture, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v7 +} // namespace qbs + +#endif // QBS_AVRBUILDCONFIGURATIONGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp new file mode 100644 index 000000000..41bd77e31 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp @@ -0,0 +1,470 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrcompilersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace v7 { + +constexpr int kCompilerArchiveVersion = 6; +constexpr int kCompilerDataVersion = 17; + +namespace AvrCompiler { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + moduleType = flags.contains(QLatin1String("--library_module")) + ? OutputPageOptions::LibraryModule + : OutputPageOptions::ProgramModule; + debugInfo = IarewUtils::debugInformation(qbsProduct); + disableErrorMessages = flags.contains( + QLatin1String("--no_ubrof_messages")); + } + + int debugInfo = 0; + int disableErrorMessages = 0; + enum ModuleType { ProgramModule, LibraryModule}; + ModuleType moduleType = ProgramModule; +}; + +// 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 = IarewUtils::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 = C89LanguageDialect; + 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 = SignedCharacter; + 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 }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = IarewUtils::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); + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableCrossCall = !flags.contains(QLatin1String("--no_cross_call")); + enableVariableClustering = !flags.contains( + QLatin1String("--no_clustering")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + enableForceCrossCall = flags.contains( + QLatin1String("--do_cross_call")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Six bit-field flags on "enabled optimizations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableCrossCall = 0; // Cross call optimization. + int enableVariableClustering = 0; // Variable clustering. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. + // Force cross-call optimization. + int enableForceCrossCall = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = IarewUtils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = IarewUtils::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 = IarewUtils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + placeConstantsInRam = flags.contains(QLatin1String("-y")); + placeInitializiersInFlash = flags.contains( + QLatin1String("--initializiers_in_flash")); + forceVariablesGeneration = flags.contains( + QLatin1String("--root_variables")); + useIccA90CallingConvention = flags.contains( + QLatin1String("--version1_calls")); + lockRegistersCount = IarewUtils::flagValue( + flags, QStringLiteral("--lock_regs")).toInt(); + } + + int placeConstantsInRam = 0; + int placeInitializiersInFlash = 0; + int forceVariablesGeneration = 0; + int useIccA90CallingConvention = 0; + int lockRegistersCount = 0; +}; + +} // namespace AvrCompiler + +// AvrCompilerSettingsGroup + +AvrCompilerSettingsGroup::AvrCompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICCAVR")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(IarewUtils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = IarewUtils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void AvrCompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const AvrCompiler::OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {}, {opts.debugInfo}); + // Add 'CCNoErrorMsg' item (No error messages in output files). + addOptionsGroup(QByteArrayLiteral("CCNoErrorMsg"), + {}, {opts.disableErrorMessages}); + // Add 'CCOverrideModuleTypeDefault' item + // (Override default module type). + addOptionsGroup(QByteArrayLiteral("CCOverrideModuleTypeDefault"), + {}, {1}); + // Add 'CCRadioModuleType' item (Module type: program/library). + addOptionsGroup(QByteArrayLiteral("CCRadioModuleType"), + {}, {opts.moduleType}); +} + +void AvrCompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const AvrCompiler::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 'CCExt' item (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("CCExt"), + {}, {opts.languageConformance}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {}, {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {}, {opts.useCppInlineSemantics}); + // Add 'CCRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {}, {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {}, {opts.destroyStaticObjects}); +} + +void AvrCompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const AvrCompiler::LanguageTwoPageOptions opts(qbsProduct); + // Add 'CCCharIs' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("CCCharIs"), + {}, {opts.plainCharacter}); + // Add 'IccFloatSemantics' item (Floatic-point + // semantics: strict/relaxed conformance). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {}, {opts.floatingPointSemantic}); + // Add 'CCMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("CCMultibyteSupport"), + {}, {opts.enableMultibyteSupport}); +} + +void AvrCompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const AvrCompiler::OptimizationsPageOptions opts(qbsProduct); + // Add 'CCOptStrategy', 'CCOptLevel' and + // 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("CCOptStrategy"), + {}, {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("CCOptLevel"), + {}, {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("CCOptLevelSlave"), + {}, {opts.optimizationLevelSlave}); + // Add 'CCAllowList' item + // (Enabled optimizations: 6 check boxes). + const QString bitflags = QStringLiteral("%1%2%3%4%5%6") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableCrossCall) + .arg(opts.enableVariableClustering) + .arg(opts.enableTypeBasedAliasAnalysis); + addOptionsGroup(QByteArrayLiteral("CCAllowList"), + {}, {bitflags}); + // Add 'CCOptForceCrossCall' item + // (Always do cross call optimization). + addOptionsGroup(QByteArrayLiteral("CCOptForceCrossCall"), + {}, {opts.enableForceCrossCall}); +} + +void AvrCompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const AvrCompiler::PreprocessorPageOptions opts(baseDirectory, + qbsProduct); + // Add 'CCDefines' item (Defines symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + {}, opts.defineSymbols); + // Add 'newCCIncludePaths' item + // (Additional include directories). + addOptionsGroup(QByteArrayLiteral("newCCIncludePaths"), + {}, opts.includePaths); +} + +void AvrCompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const AvrCompiler::DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCWarnAsError' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCWarnAsError"), + {}, {opts.warningsAsErrors}); +} + +void AvrCompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const AvrCompiler::CodePageOptions opts(qbsProduct); + // Add 'CCConstInRAM' item (Place string literals + // and constants in initialized RAM). + addOptionsGroup(QByteArrayLiteral("CCConstInRAM"), + {}, {opts.placeConstantsInRam}); + // Add 'CCInitInFlash' item (Place aggregate + // initializiers in flash memory). + addOptionsGroup(QByteArrayLiteral("CCInitInFlash"), + {}, {opts.placeInitializiersInFlash}); + // Add 'CCForceVariables' item (Force generation of + // all global and static variables). + addOptionsGroup(QByteArrayLiteral("CCForceVariables"), + {}, {opts.forceVariablesGeneration}); + // Add 'CCOldCallConv' item (Use ICCA90 1.x + // calling convention). + addOptionsGroup(QByteArrayLiteral("CCOldCallConv"), + {}, {opts.useIccA90CallingConvention}); + // Add 'CCLockRegs' item (Number of registers to + // lock for global variables). + addOptionsGroup(QByteArrayLiteral("CCLockRegs"), + {}, {opts.lockRegistersCount}); +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h new file mode 100644 index 000000000..06e623f2f --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRCOMPILERSETTINGSGROUP_V7_H +#define QBS_AVRCOMPILERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrCompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrCompilerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &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 v7 +} // namespace qbs + +#endif // QBS_AVRCOMPILERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp new file mode 100644 index 000000000..a69e2c2ed --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp @@ -0,0 +1,764 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrgeneralsettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace v7 { + +constexpr int kGeneralArchiveVersion = 12; +constexpr int kGeneralDataVersion = 10; + +namespace AvrGeneral { + +struct TargetMcuEntry final +{ + QByteArray targetName; + QByteArray targetFlag; +}; + +// Dictionary of known AVR MCU's and its compiler options. +static const TargetMcuEntry mcusDict[] = { + {"AT43USB320A", "at43usb320a"}, + {"AT43USB325", "at43usb325"}, + {"AT43USB326", "at43usb326"}, + {"AT43USB351M", "at43usb351m"}, + {"AT43USB353M", "at43usb353m"}, + {"AT43USB355", "at43usb355"}, + {"AT76C712", "at76c712"}, + {"AT76C713", "at76c713"}, + {"AT86RF401", "at86rf401"}, + {"AT90CAN128", "can128"}, + {"AT90CAN32", "can32"}, + {"AT90CAN64", "can64"}, + {"AT90PWM1", "pwm1"}, + {"AT90PWM161", "pwm161"}, + {"AT90PWM2", "pwm2"}, + {"AT90PWM216", "pwm216"}, + {"AT90PWM2B", "pwm2b"}, + {"AT90PWM3", "pwm3"}, + {"AT90PWM316", "pwm316"}, + {"AT90PWM3B", "pwm3b"}, + {"AT90PWM81", "pwm81"}, + {"AT90S1200", "1200"}, + {"AT90S2313", "2313"}, + {"AT90S2323", "2323"}, + {"AT90S2333", "2333"}, + {"AT90S2343", "2343"}, + {"AT90S4414", "4414"}, + {"AT90S4433", "4433"}, + {"AT90S4434", "4434"}, + {"AT90S8515", "8515"}, + {"AT90S8534", "8534"}, + {"AT90S8535", "8535"}, + {"AT90SCR050", "scr050"}, + {"AT90SCR075", "scr075"}, + {"AT90SCR100", "scr100"}, + {"AT90SCR200", "scr200"}, + {"AT90SCR400", "scr400"}, + {"AT90USB128", "usb128"}, + {"AT90USB1286", "usb1286"}, + {"AT90USB1287", "usb1287"}, + {"AT90USB162", "usb162"}, + {"AT90USB64", "usb64"}, + {"AT90USB646", "usb646"}, + {"AT90USB647", "usb647"}, + {"AT90USB82", "usb82"}, + {"AT94Kxx", "at94k"}, + {"ATA5272", "ata5272"}, + {"ATA5505", "ata5505"}, + {"ATA5700M322", "ata5700m322"}, + {"ATA5702M322", "ata5702m322"}, + {"ATA5781", "ata5781"}, + {"ATA5782", "ata5782"}, + {"ATA5783", "ata5783"}, + {"ATA5785", "ata5785"}, + {"ATA5787", "ata5787"}, + {"ATA5790", "ata5790"}, + {"ATA5790N", "ata5790n"}, + {"ATA5795", "ata5795"}, + {"ATA5830", "ata5830"}, + {"ATA5831", "ata5831"}, + {"ATA5832", "ata5832"}, + {"ATA5833", "ata5833"}, + {"ATA5835", "ata5835"}, + {"ATA6285", "ata6285"}, + {"ATA6286", "ata6286"}, + {"ATA6289", "ata6289"}, + {"ATA8210", "ata8210"}, + {"ATA8215", "ata8215"}, + {"ATA8510", "ata8510"}, + {"ATA8515", "ata8515"}, + {"ATmX224E", "mx224e"}, + {"ATmXT112SL", "mxt112sl"}, + {"ATmXT224", "mxt224"}, + {"ATmXT224E", "mxt224e"}, + {"ATmXT336S", "mxt336s"}, + {"ATmXT540S", "mxt540s"}, + {"ATmXT540S_RevA", "mxt540s_reva"}, + {"ATmXTS200", "mxts200"}, + {"ATmXTS220", "mxts220"}, + {"ATmXTS220E", "mxts220e"}, + {"ATmega007", "m007"}, + {"ATmega103", "m103"}, + {"ATmega128", "m128"}, + {"ATmega1280", "m1280"}, + {"ATmega1281", "m1281"}, + {"ATmega1284", "m1284"}, + {"ATmega1284P", "m1284p"}, + {"ATmega1284RFR2", "m1284rfr2"}, + {"ATmega128A", "m128a"}, + {"ATmega128RFA1", "m128rfa1"}, + {"ATmega128RFA2", "m128rfa2"}, + {"ATmega128RFR2", "m128rfr2"}, + {"ATmega16", "m16"}, + {"ATmega1608", "m1608"}, + {"ATmega1609", "m1609"}, + {"ATmega161", "m161"}, + {"ATmega162", "m162"}, + {"ATmega163", "m163"}, + {"ATmega164", "m164"}, + {"ATmega164A", "m164a"}, + {"ATmega164P", "m164p"}, + {"ATmega164PA", "m164pa"}, + {"ATmega165", "m165"}, + {"ATmega165A", "m165a"}, + {"ATmega165P", "m165p"}, + {"ATmega165PA", "m165pa"}, + {"ATmega168", "m168"}, + {"ATmega168A", "m168a"}, + {"ATmega168P", "m168p"}, + {"ATmega168PA", "m168pa"}, + {"ATmega168PB", "m168pb"}, + {"ATmega169", "m169"}, + {"ATmega169A", "m169a"}, + {"ATmega169P", "m169p"}, + {"ATmega169PA", "m169pa"}, + {"ATmega16A", "m16a"}, + {"ATmega16HVA", "m16hva"}, + {"ATmega16HVA2", "m16hva2"}, + {"ATmega16HVB", "m16hvb"}, + {"ATmega16M1", "m16m1"}, + {"ATmega16U2", "m16u2"}, + {"ATmega16U4", "m16u4"}, + {"ATmega2560", "m2560"}, + {"ATmega2561", "m2561"}, + {"ATmega2564RFR2", "m2564rfr2"}, + {"ATmega256RFA2", "m256rfa2"}, + {"ATmega256RFR2", "m256rfr2"}, + {"ATmega26HVG", "m26hvg"}, + {"ATmega32", "m32"}, + {"ATmega3208", "m3208"}, + {"ATmega3209", "m3209"}, + {"ATmega323", "m323"}, + {"ATmega324", "m324"}, + {"ATmega324A", "m324a"}, + {"ATmega324P", "m324p"}, + {"ATmega324PA", "m324pa"}, + {"ATmega324PB", "m324pb"}, + {"ATmega325", "m325"}, + {"ATmega3250", "m3250"}, + {"ATmega3250A", "m3250a"}, + {"ATmega3250P", "m3250p"}, + {"ATmega3250PA", "m3250pa"}, + {"ATmega325A", "m325a"}, + {"ATmega325P", "m325p"}, + {"ATmega325PA", "m325pa"}, + {"ATmega328", "m328"}, + {"ATmega328P", "m328p"}, + {"ATmega328PB", "m328pb"}, + {"ATmega329", "m329"}, + {"ATmega3290", "m3290"}, + {"ATmega3290A", "m3290a"}, + {"ATmega3290P", "m3290p"}, + {"ATmega3290PA", "m3290pa"}, + {"ATmega329A", "m329a"}, + {"ATmega329P", "m329p"}, + {"ATmega329PA", "m329pa"}, + {"ATmega32A", "m32a"}, + {"ATmega32C1", "m32c1"}, + {"ATmega32HVB", "m32hvb"}, + {"ATmega32M1", "m32m1"}, + {"ATmega32U2", "m32u2"}, + {"ATmega32U4", "m32u4"}, + {"ATmega32U6", "m32u6"}, + {"ATmega406", "m406"}, + {"ATmega48", "m48"}, + {"ATmega4808", "m4808"}, + {"ATmega4809", "m4809"}, + {"ATmega48A", "m48a"}, + {"ATmega48HVF", "m48hvf"}, + {"ATmega48P", "m48p"}, + {"ATmega48PA", "m48pa"}, + {"ATmega48PB", "m48pb"}, + {"ATmega4HVD", "m4hvd"}, + {"ATmega603", "m603"}, + {"ATmega64", "m64"}, + {"ATmega640", "m640"}, + {"ATmega644", "m644"}, + {"ATmega644A", "m644a"}, + {"ATmega644P", "m644p"}, + {"ATmega644PA", "m644pa"}, + {"ATmega644RFR2", "m644rfr2"}, + {"ATmega645", "m645"}, + {"ATmega6450", "m6450"}, + {"ATmega6450A", "m6450a"}, + {"ATmega6450P", "m6450p"}, + {"ATmega645A", "m645a"}, + {"ATmega645P", "m645p"}, + {"ATmega649", "m649"}, + {"ATmega6490", "m6490"}, + {"ATmega6490A", "m6490a"}, + {"ATmega6490P", "m6490p"}, + {"ATmega649A", "m649a"}, + {"ATmega649P", "m649p"}, + {"ATmega64A", "m64a"}, + {"ATmega64C1", "m64c1"}, + {"ATmega64HVE", "m256rfa2"}, + {"ATmega64HVE", "m64hve"}, + {"ATmega64HVE2", "m64hve2"}, + {"ATmega64M1", "m64m1"}, + {"ATmega64RFA2", "m64rfa2"}, + {"ATmega64RFR2", "m64rfr2"}, + {"ATmega8", "m8"}, + {"ATmega808", "m808"}, + {"ATmega809", "m809"}, + {"ATmega83", "m83"}, + {"ATmega8515", "m8515"}, + {"ATmega8535", "m8535"}, + {"ATmega88", "m88"}, + {"ATmega88A", "m88a"}, + {"ATmega88P", "m88p"}, + {"ATmega88PA", "m88pa"}, + {"ATmega88PB", "m88pb"}, + {"ATmega8A", "m8a"}, + {"ATmega8HVA", "m8hva"}, + {"ATmega8HVD", "m8hvd"}, + {"ATmega8U2", "m8u2"}, + {"ATtiny10", "tiny10"}, + {"ATtiny102", "tiny102"}, + {"ATtiny104", "tiny104"}, + {"ATtiny11", "tiny11"}, + {"ATtiny12", "tiny12"}, + {"ATtiny13", "tiny13"}, + {"ATtiny13A", "tiny13a"}, + {"ATtiny15", "tiny15"}, + {"ATtiny1604", "tiny1604"}, + {"ATtiny1606", "tiny1606"}, + {"ATtiny1607", "tiny1607"}, + {"ATtiny1614", "tiny1614"}, + {"ATtiny1616", "tiny1616"}, + {"ATtiny1617", "tiny1617"}, + {"ATtiny1634", "tiny1634"}, + {"ATtiny167", "tiny167"}, + {"ATtiny20", "tiny20"}, + {"ATtiny202", "tiny202"}, + {"ATtiny204", "tiny204"}, + {"ATtiny212", "tiny212"}, + {"ATtiny214", "tiny214"}, + {"ATtiny22", "tiny22"}, + {"ATtiny2313", "tiny2313"}, + {"ATtiny2313A", "tiny2313a"}, + {"ATtiny23U", "tiny23u"}, + {"ATtiny24", "tiny24"}, + {"ATtiny24A", "tiny24a"}, + {"ATtiny25", "tiny25"}, + {"ATtiny26", "tiny26"}, + {"ATtiny261", "tiny261"}, + {"ATtiny261A", "tiny261a"}, + {"ATtiny28", "tiny28"}, + {"ATtiny3214", "tiny3214"}, + {"ATtiny3216", "tiny3216"}, + {"ATtiny3217", "tiny3217"}, + {"ATtiny4", "tiny4"}, + {"ATtiny40", "tiny40"}, + {"ATtiny402", "tiny402"}, + {"ATtiny404", "tiny404"}, + {"ATtiny406", "tiny406"}, + {"ATtiny412", "tiny412"}, + {"ATtiny414", "tiny414"}, + {"ATtiny416", "tiny416"}, + {"ATtiny417", "tiny417"}, + {"ATtiny4313", "tiny4313"}, + {"ATtiny43U", "tiny43u"}, + {"ATtiny44", "tiny44"}, + {"ATtiny441", "tiny441"}, + {"ATtiny44A", "tiny44a"}, + {"ATtiny45", "tiny45"}, + {"ATtiny461", "tiny461"}, + {"ATtiny461A", "tiny461a"}, + {"ATtiny474", "tiny474"}, + {"ATtiny48", "tiny48"}, + {"ATtiny5", "tiny5"}, + {"ATtiny80", "tiny80"}, + {"ATtiny804", "tiny804"}, + {"ATtiny806", "tiny806"}, + {"ATtiny807", "tiny807"}, + {"ATtiny80_pre_2015", "tiny80_pre_2015"}, + {"ATtiny814", "tiny814"}, + {"ATtiny816", "tiny816"}, + {"ATtiny817", "tiny817"}, + {"ATtiny828", "tiny828"}, + {"ATtiny84", "tiny84"}, + {"ATtiny840", "tiny840"}, + {"ATtiny841", "tiny841"}, + {"ATtiny84A", "tiny84a"}, + {"ATtiny85", "tiny85"}, + {"ATtiny861", "tiny861"}, + {"ATtiny861A", "tiny861a"}, + {"ATtiny87", "tiny87"}, + {"ATtiny88", "tiny88"}, + {"ATtiny9", "tiny9"}, + {"ATxmega128A1", "xm128a1"}, + {"ATxmega128A1U", "xm128a1u"}, + {"ATxmega128A3", "xm128a3"}, + {"ATxmega128A3U", "xm128a3u"}, + {"ATxmega128A4", "xm128a4"}, + {"ATxmega128A4U", "xm128a4u"}, + {"ATxmega128B1", "xm128b1"}, + {"ATxmega128B3", "xm128b3"}, + {"ATxmega128C3", "xm128c3"}, + {"ATxmega128D3", "xm128d3"}, + {"ATxmega128D4", "xm128d4"}, + {"ATxmega16A4", "xm16a4"}, + {"ATxmega16A4U", "xm16a4u"}, + {"ATxmega16C4", "xm16c4"}, + {"ATxmega16D4", "xm16d4"}, + {"ATxmega16E5", "xm16e5"}, + {"ATxmega192A1", "xm192a1"}, + {"ATxmega192A3", "xm192a3"}, + {"ATxmega192A3U", "xm192a3u"}, + {"ATxmega192C3", "xm192c3"}, + {"ATxmega192D3", "xm192d3"}, + {"ATxmega256A1", "xm256a1"}, + {"ATxmega256A3", "xm256a3"}, + {"ATxmega256A3B", "xm256a3b"}, + {"ATxmega256A3BU", "xm256a3bu"}, + {"ATxmega256A3U", "xm256a3u"}, + {"ATxmega256B1", "xm256b1"}, + {"ATxmega256C3", "xm256c3"}, + {"ATxmega256D3", "xm256d3"}, + {"ATxmega32A4", "xm32a4"}, + {"ATxmega32A4U", "xm32a4u"}, + {"ATxmega32C3", "xm32c3"}, + {"ATxmega32C4", "xm32c4"}, + {"ATxmega32D3", "xm32d3"}, + {"ATxmega32D4", "xm32d4"}, + {"ATxmega32D4P", "xm32d4p"}, + {"ATxmega32E5", "xm32e5"}, + {"ATxmega32X1", "xm32x1"}, + {"ATxmega384A1", "xm384a1"}, + {"ATxmega384C3", "xm384c3"}, + {"ATxmega384D3", "xm384d3"}, + {"ATxmega64A1", "xm64a1"}, + {"ATxmega64A1U", "xm64a1u"}, + {"ATxmega64A3", "xm64a3"}, + {"ATxmega64A3U", "xm64a3u"}, + {"ATxmega64A4", "xm64a4"}, + {"ATxmega64A4U", "xm64a4u"}, + {"ATxmega64B1", "xm64b1"}, + {"ATxmega64B3", "xm64b3"}, + {"ATxmega64C3", "xm64c3"}, + {"ATxmega64D3", "xm64d3"}, + {"ATxmega64D4", "xm64d4"}, + {"ATxmega8E5", "xm8e5"}, + {"M3000", "m3000"}, + {"MaxBSE", "maxbse"}, +}; + +// Target page options. + +struct TargetPageOptions final +{ + enum MemoryModel { TinyModel, + SmallModel, + LargeModel, + HugeModel }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target MCU record. + const QString mcuValue = IarewUtils::flagValue( + flags, QStringLiteral("--cpu")).toLower(); + targetMcu = mcuStringFromFlagValue(mcuValue); + // Detect target memory model. + const QString modelValue = IarewUtils::flagValue( + flags, QStringLiteral("-m")); + if (modelValue == QLatin1Char('t')) + memoryModel = TargetPageOptions::TinyModel; + else if (modelValue == QLatin1Char('s')) + memoryModel = TargetPageOptions::SmallModel; + else if (modelValue == QLatin1Char('l')) + memoryModel = TargetPageOptions::LargeModel; + else if (modelValue == QLatin1Char('h')) + memoryModel = TargetPageOptions::HugeModel; + // Detect target EEPROM util size. + eepromUtilSize = IarewUtils::flagValue( + flags, QStringLiteral("--eeprom_size")).toInt(); + } + + static QString mcuStringFromFlagValue(const QString &mcuValue) + { + const auto targetBegin = std::cbegin(mcusDict); + const auto targetEnd = std::cend(mcusDict); + const auto targetIt = std::find_if(targetBegin, targetEnd, + [mcuValue]( + const TargetMcuEntry &entry) { + return entry.targetFlag == mcuValue.toLatin1(); + }); + if (targetIt != targetEnd) { + return QStringLiteral("%1\t%2") + .arg(QString::fromLatin1(targetIt->targetFlag), + QString::fromLatin1(targetIt->targetName)); + } + return {}; + } + + QString targetMcu; + MemoryModel memoryModel = TinyModel; + int eepromUtilSize = 0; +}; + +// System page options. + +struct SystemPageOptions final +{ + explicit SystemPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags"), + QStringLiteral("defines")}); + cstackSize = IarewUtils::flagValue( + flags, QStringLiteral("_..X_CSTACK_SIZE")).toInt(); + rstackSize = IarewUtils::flagValue( + flags, QStringLiteral("_..X_RSTACK_SIZE")).toInt(); + } + + int cstackSize = 0; + int rstackSize = 0; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { PrintfAutoFormatter = 0, + PrintfFullFormatter = 1, + PrintfFullNoMultibytesFormatter = 2, + PrintfLargeFormatter = 3, + PrintfLargeNoMultibytesFormatter = 4, + PrintfSmallFormatter = 6, + PrintfSmallNoMultibytesFormatter = 7, + PrintfTinyFormatter = 8 }; + + enum ScanfFormatter { ScanfAutoFormatter = 0, + ScanfFullFormatter = 1, + ScanfFullNoMultibytesFormatter = 2, + ScanfLargeFormatter = 3, + ScanfLargeNoMultibytesFormatter = 4, + ScanfSmallFormatter = 6, + ScanfSmallNoMultibytesFormatter = 7 }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (const QString &flag : flags) { + if (flag.endsWith(QLatin1String("_printf"), Qt::CaseInsensitive)) { + const QString prop = flag.split(QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("-e_printffull")) + printfFormatter = LibraryOptionsPageOptions::PrintfFullFormatter; + else if (prop == QLatin1String("-e_printffullnomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfFullNoMultibytesFormatter; + else if (prop == QLatin1String("-e_printflarge")) + printfFormatter = LibraryOptionsPageOptions::PrintfLargeFormatter; + else if (prop == QLatin1String("-e_printflargenomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfLargeNoMultibytesFormatter; + else if (prop == QLatin1String("-e_printfsmall")) + printfFormatter = LibraryOptionsPageOptions::PrintfSmallFormatter; + else if (prop == QLatin1String("-e_printfsmallnomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfSmallNoMultibytesFormatter; + else if (prop == QLatin1String("-printftiny")) + printfFormatter = LibraryOptionsPageOptions::PrintfTinyFormatter; + } else if (flag.endsWith(QLatin1String("_scanf"), Qt::CaseInsensitive)) { + const QString prop = flag.split(QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("-e_scanffull")) + scanfFormatter = LibraryOptionsPageOptions::ScanfFullFormatter; + else if (prop == QLatin1String("-e_scanffullnomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfFullNoMultibytesFormatter; + else if (prop == QLatin1String("-e_scanflarge")) + scanfFormatter = LibraryOptionsPageOptions::ScanfLargeFormatter; + else if (prop == QLatin1String("-e_scanflargenomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfLargeNoMultibytesFormatter; + else if (prop == QLatin1String("-e_scanfsmall")) + scanfFormatter = LibraryOptionsPageOptions::ScanfSmallFormatter; + else if (prop == QLatin1String("-e_scanfsmallnomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfSmallNoMultibytesFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { NoLibrary, + NormalDlibLibrary, + FullDlibLibrary, + CustomDlibLibrary, + ClibLibrary, + CustomClibLibrary, + ThirdPartyLibrary }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QStringList libraryPaths = IarewUtils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + const auto libraryBegin = libraryPaths.cbegin(); + const auto libraryEnd = libraryPaths.cend(); + + if (flags.contains(QLatin1String("--dlib"))) { + const QString dlibToolkitPath = + IarewUtils::dlibToolkitRootPath(qbsProduct); + const QFileInfo configInfo(IarewUtils::flagValue( + flags, + QStringLiteral("--dlib_config"))); + const QString configFilePath = configInfo.absoluteFilePath(); + if (configFilePath.startsWith(dlibToolkitPath, + Qt::CaseInsensitive)) { + if (configFilePath.endsWith(QLatin1String("-n.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalDlibLibrary; + } else if (configFilePath.endsWith(QLatin1String("-f.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::FullDlibLibrary; + } else { + libraryType = LibraryConfigPageOptions::CustomDlibLibrary; + } + + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, configFilePath); + + // Find dlib library inside of IAR toolkit directory. + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [dlibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(dlibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that dlib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } + } else { + // This means that dlib library is 'custom' + // (but we don't know its path). + libraryType = LibraryConfigPageOptions::CustomDlibLibrary; + configPath = IarewUtils::projectRelativeFilePath( + baseDirectory, configFilePath); + } + } else if (flags.contains(QLatin1String("--clib"))) { + const QString clibToolkitPath = + IarewUtils::clibToolkitRootPath(qbsProduct); + // Find clib library inside of IAR toolkit directory. + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [clibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(clibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that clib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryType = LibraryConfigPageOptions::ClibLibrary; + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } else { + // This means that clib library is 'custom' + // (but we don't know its path). + libraryType = LibraryConfigPageOptions::CustomClibLibrary; + } + } else { + libraryType = LibraryConfigPageOptions::NoLibrary; + } + } + + RuntimeLibrary libraryType = NoLibrary; + QString configPath; + QString libraryPath; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = IarewUtils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = IarewUtils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = IarewUtils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +} // namespace AvrGeneral + +// AvrGeneralSettingsGroup + +AvrGeneralSettingsGroup::AvrGeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(IarewUtils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = IarewUtils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildSystemPage(qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void AvrGeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const AvrGeneral::TargetPageOptions opts(qbsProduct); + // Add 'GenDeviceSelectMenu' item + // (Processor configuration chooser). + addOptionsGroup(QByteArrayLiteral("GenDeviceSelectMenu"), + {}, {opts.targetMcu}); + // Add 'Variant Memory' item + // (Memory model: tiny/small/large/huge). + addOptionsGroup(QByteArrayLiteral("Variant Memory"), + {}, {opts.memoryModel}); + // Add 'GGEepromUtilSize' item + // (Utilize inbuilt EEPROM size, in bytes). + addOptionsGroup(QByteArrayLiteral("GGEepromUtilSize"), + {}, {opts.eepromUtilSize}); +} + +void AvrGeneralSettingsGroup::buildSystemPage( + const ProductData &qbsProduct) +{ + const AvrGeneral::SystemPageOptions opts (qbsProduct); + // Add 'SCCStackSize' item (Data stack + // - CSTACK size in bytes). + addOptionsGroup(QByteArrayLiteral("SCCStackSize"), + {}, {opts.cstackSize}); + // Add 'SCRStackSize' item (Return address stack + // - RSTACK depth in bytes). + addOptionsGroup(QByteArrayLiteral("SCRStackSize"), + {}, {opts.rstackSize}); +} + +void AvrGeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const AvrGeneral::LibraryOptionsPageOptions opts(qbsProduct); + // Add 'Output variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Output variant"), + {}, {opts.printfFormatter}); + // Add 'Input variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Input variant"), + {}, {opts.scanfFormatter}); +} + +void AvrGeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const AvrGeneral::LibraryConfigPageOptions opts(baseDirectory, + qbsProduct); + // Add 'GRuntimeLibSelect' and 'GRuntimeLibSelectSlave' items + // (Link with runtime: none/dlib/clib/etc). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelect"), + {}, {opts.libraryType}); + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelectSlave"), + {}, {opts.libraryType}); + // Add 'RTConfigPath' item (Runtime configuration file). + addOptionsGroup(QByteArrayLiteral("RTConfigPath"), + {}, {opts.configPath}); + // Add 'RTLibraryPath' item (Runtime library file). + addOptionsGroup(QByteArrayLiteral("RTLibraryPath"), + {}, {opts.libraryPath}); +} + +void AvrGeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const AvrGeneral::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}); +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h new file mode 100644 index 000000000..8a0d54ee6 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRGENERALSETTINGSGROUP_V7_H +#define QBS_AVRGENERALSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrGeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrGeneralSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildSystemPage(const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace qbs + +#endif // QBS_AVRGENERALSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp new file mode 100644 index 000000000..5fe286198 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp @@ -0,0 +1,383 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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 "avrlinkersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace v7 { + +constexpr int kLinkerArchiveVersion = 3; +constexpr int kLinkerDataVersion = 16; + +namespace AvrLinker { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + entryPoint = IarewUtils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + + // 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 '-f' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("-f")); + 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); + } + } + + // Add libraries search paths. + const QStringList libraryPaths = IarewUtils::cppStringModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + for (const QString &libraryPath : libraryPaths) { + const QFileInfo libraryPathInfo(libraryPath); + const QString fullLibrarySearchPath = + libraryPathInfo.absoluteFilePath(); + if (fullLibrarySearchPath.startsWith(toolkitPath, + Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } + } + + // Add static libraries paths. + const QStringList staticLibrariesProps = + IarewUtils::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$/") + + IarewUtils::targetBinaryPath(baseDirectory, + qbsProductDep); + staticLibraries.push_back(depBinaryPath); + } + } + + QVariantList configFilePaths; + QVariantList librarySearchPaths; + QVariantList staticLibraries; + QString entryPoint; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = IarewUtils::targetBinary(qbsProduct); + } + + QString outputFile; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { NoListing, + GenerateListing }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = IarewUtils::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); + // Enumerate all linker defines. + for (const QString &flag : flags) { + if (!flag.startsWith(QLatin1String("-D"))) + continue; + const auto symbol = flag.mid(2); + // Ignore system-defined macroses. + if (symbol.startsWith(QLatin1String("_..X_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_TINY_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_NEAR_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_FAR_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_HUGE_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_SIZE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_SIZE")) + || symbol.startsWith(QLatin1String("_..X_FLASH_CODE_END")) + || symbol.startsWith(QLatin1String("_..X_FLASH_BASE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_END")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_END")) + || symbol.startsWith(QLatin1String("_..X_EXT_SRAM_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_SRAM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_EXT_ROM_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_ROM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_EXT_NV_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_NV_SIZE")) + || symbol.startsWith(QLatin1String("_..X_SRAM_BASE")) + || symbol.startsWith(QLatin1String("_..X_SRAM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_SIZE")) + ) { + continue; + } + defineSymbols.push_back(symbol); + } + } + + QVariantList defineSymbols; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = IarewUtils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + suppressAllWarnings = (warningLevel == QLatin1String("none")); + } + + int suppressAllWarnings = 0; +}; + +} // namespace AvrLinker + +// AvrLinkerSettingsGroup + +AvrLinkerSettingsGroup::AvrLinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + setName(QByteArrayLiteral("XLINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(IarewUtils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = IarewUtils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct, qbsProductDeps); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + buildDiagnosticsPage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void AvrLinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + AvrLinker::ConfigPageOptions opts(baseDirectory, qbsProduct, + qbsProductDeps); + + 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 'XclOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XclOverride"), + {}, {1}); + // Add 'XclFile' item (Linke configuration file). + addOptionsGroup(QByteArrayLiteral("XclFile"), + {}, {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("-f ") + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } + + if (opts.staticLibraries.count() > 0) + m_extraOptions << opts.staticLibraries; + + if (!opts.entryPoint.isEmpty()) { + // Add 'xcProgramEntryLabel' item (Entry symbol). + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabel"), + {}, {opts.entryPoint}); + // Add 'xcOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("xcOverrideProgramEntryLabel"), + {}, {1}); + // Add 'xcProgramEntryLabelSelect' item. + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabelSelect"), + {}, {0}); + } + + // Add 'XIncludes' item (Libraries search paths). + addOptionsGroup(QByteArrayLiteral("XIncludes"), + {}, opts.librarySearchPaths); +} + +void AvrLinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const AvrLinker::OutputPageOptions opts(qbsProduct); + // Add 'XOutOverride' item (Override default output file). + addOptionsGroup(QByteArrayLiteral("XOutOverride"), + {}, {1}); + // Add 'OutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {}, {opts.outputFile}); +} + +void AvrLinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const AvrLinker::ListPageOptions opts(qbsProduct); + // Add 'XList' item (Generate linker listing). + addOptionsGroup(QByteArrayLiteral("XList"), + {}, {opts.generateMap}); +} + +void AvrLinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const AvrLinker::DefinePageOptions opts(qbsProduct); + // Add 'XDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("XDefines"), + {}, opts.defineSymbols); +} + +void AvrLinkerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const AvrLinker::DiagnosticsPageOptions opts(qbsProduct); + // Add 'SuppressAllWarn' item (Suppress all warnings). + addOptionsGroup(QByteArrayLiteral("SuppressAllWarn"), + {}, {opts.suppressAllWarnings}); +} + +void AvrLinkerSettingsGroup::buildExtraOptionsPage(const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + if (!m_extraOptions.isEmpty()) { + // Add 'XExtraOptionsCheck' (Use command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptionsCheck"), + {}, {1}); + // Add 'XExtraOptions' item (Command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptions"), + {}, m_extraOptions); + } +} + +} // namespace v7 +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h new file mode 100644 index 000000000..97d20db58 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** 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_AVRLINKERSETTINGSGROUP_V7_H +#define QBS_AVRLINKERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace v7 { + +class AvrLinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrLinkerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + 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 v7 +} // namespace qbs + +#endif // QBS_AVRLINKERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/iarew.pro b/src/plugins/generator/iarew/iarew.pro index bf970af97..1239941bd 100644 --- a/src/plugins/generator/iarew/iarew.pro +++ b/src/plugins/generator/iarew/iarew.pro @@ -64,3 +64,21 @@ SOURCES += \ $$PWD/archs/arm/armcompilersettingsgroup_v8.cpp \ $$PWD/archs/arm/armgeneralsettingsgroup_v8.cpp \ $$PWD/archs/arm/armlinkersettingsgroup_v8.cpp \ + +# For AVR architecture. + +HEADERS += \ + $$PWD/archs/avr/avrarchiversettingsgroup_v7.h \ + $$PWD/archs/avr/avrassemblersettingsgroup_v7.h \ + $$PWD/archs/avr/avrbuildconfigurationgroup_v7.h \ + $$PWD/archs/avr/avrcompilersettingsgroup_v7.h \ + $$PWD/archs/avr/avrgeneralsettingsgroup_v7.h \ + $$PWD/archs/avr/avrlinkersettingsgroup_v7.h \ + +SOURCES += \ + $$PWD/archs/avr/avrarchiversettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrassemblersettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrbuildconfigurationgroup_v7.cpp \ + $$PWD/archs/avr/avrcompilersettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrgeneralsettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrlinkersettingsgroup_v7.cpp \ diff --git a/src/plugins/generator/iarew/iarew.qbs b/src/plugins/generator/iarew/iarew.qbs index 27949ce8a..7143f5592 100644 --- a/src/plugins/generator/iarew/iarew.qbs +++ b/src/plugins/generator/iarew/iarew.qbs @@ -62,4 +62,22 @@ QbsPlugin { "armlinkersettingsgroup_v8.h", ] } + Group { + name: "IAR EW generator for AVR" + prefix: "archs/avr/" + files: [ + "avrarchiversettingsgroup_v7.cpp", + "avrarchiversettingsgroup_v7.h", + "avrassemblersettingsgroup_v7.cpp", + "avrassemblersettingsgroup_v7.h", + "avrbuildconfigurationgroup_v7.cpp", + "avrbuildconfigurationgroup_v7.h", + "avrcompilersettingsgroup_v7.cpp", + "avrcompilersettingsgroup_v7.h", + "avrgeneralsettingsgroup_v7.cpp", + "avrgeneralsettingsgroup_v7.h", + "avrlinkersettingsgroup_v7.cpp", + "avrlinkersettingsgroup_v7.h", + ] + } } diff --git a/src/plugins/generator/iarew/iarewproject.cpp b/src/plugins/generator/iarew/iarewproject.cpp index fced06d11..fe4bb476f 100644 --- a/src/plugins/generator/iarew/iarewproject.cpp +++ b/src/plugins/generator/iarew/iarewproject.cpp @@ -36,6 +36,7 @@ #include "iiarewnodevisitor.h" #include "archs/arm/armbuildconfigurationgroup_v8.h" +#include "archs/avr/avrbuildconfigurationgroup_v7.h" #include @@ -50,6 +51,7 @@ IarewProject::IarewProject(const GeneratableProject &genProject, // Create available configuration group factories. m_factories.push_back(std::make_unique()); + m_factories.push_back(std::make_unique()); // Construct file version item. appendChild(versionInfo); diff --git a/src/plugins/generator/iarew/iarewversioninfo.cpp b/src/plugins/generator/iarew/iarewversioninfo.cpp index 522a86213..734aa1452 100644 --- a/src/plugins/generator/iarew/iarewversioninfo.cpp +++ b/src/plugins/generator/iarew/iarewversioninfo.cpp @@ -56,6 +56,7 @@ std::set IarewVersionInfo::knownVersions() { static const std::set known = { {Version(8), {IarewUtils::Architecture::ArmArchitecture}}, + {Version(7), {IarewUtils::Architecture::AvrArchitecture}}, }; return known; } -- cgit v1.2.3