From 358348530d69528ce36e6d767d51a47cd42ae1e5 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 19 Aug 2019 18:12:40 +0300 Subject: baremetal: Long live the IAR EW project generator for MSP430 Right now it is possible to generate a native projects for the IAR Embedded Workbench IDE, e.g. using the following command: qbs generate -g 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 MSP430 for all versions of 7 series. Tested with the IAR EW for MSP430 v7.12.4, using as the QBS bare-metal examples, and as other projects. Change-Id: Ic0bbc82e6ebb3b04bced639797976e432809171f Reviewed-by: Christian Kandeler --- src/lib/corelib/generators/generatorutils.cpp | 2 + src/lib/corelib/generators/generatorutils.h | 1 + .../msp430/msp430archiversettingsgroup_v7.cpp | 94 ++++ .../archs/msp430/msp430archiversettingsgroup_v7.h | 59 +++ .../msp430/msp430assemblersettingsgroup_v7.cpp | 229 ++++++++++ .../archs/msp430/msp430assemblersettingsgroup_v7.h | 62 +++ .../msp430/msp430buildconfigurationgroup_v7.cpp | 98 +++++ .../msp430/msp430buildconfigurationgroup_v7.h | 72 +++ .../msp430/msp430compilersettingsgroup_v7.cpp | 486 +++++++++++++++++++++ .../archs/msp430/msp430compilersettingsgroup_v7.h | 65 +++ .../archs/msp430/msp430generalsettingsgroup_v7.cpp | 483 ++++++++++++++++++++ .../archs/msp430/msp430generalsettingsgroup_v7.h | 64 +++ .../archs/msp430/msp430linkersettingsgroup_v7.cpp | 290 ++++++++++++ .../archs/msp430/msp430linkersettingsgroup_v7.h | 65 +++ src/plugins/generator/iarew/iarew.pro | 18 + src/plugins/generator/iarew/iarew.qbs | 18 + .../generator/iarew/iarewfileversionproperty.cpp | 3 + src/plugins/generator/iarew/iarewproject.cpp | 3 + src/plugins/generator/iarew/iarewversioninfo.cpp | 3 +- 19 files changed, 2114 insertions(+), 1 deletion(-) create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h (limited to 'src') diff --git a/src/lib/corelib/generators/generatorutils.cpp b/src/lib/corelib/generators/generatorutils.cpp index 5c93c0502..9c00eef05 100644 --- a/src/lib/corelib/generators/generatorutils.cpp +++ b/src/lib/corelib/generators/generatorutils.cpp @@ -62,6 +62,8 @@ Architecture architecture(const Project &qbsProject) return Architecture::Mcs51; if (qbsArch == QLatin1String("stm8")) return Architecture::Stm8; + if (qbsArch == QLatin1String("msp430")) + return Architecture::Msp430; return Architecture::Unknown; } diff --git a/src/lib/corelib/generators/generatorutils.h b/src/lib/corelib/generators/generatorutils.h index 031636a7d..9348ab18c 100644 --- a/src/lib/corelib/generators/generatorutils.h +++ b/src/lib/corelib/generators/generatorutils.h @@ -45,6 +45,7 @@ enum class Architecture { Avr, Mcs51, Stm8, + Msp430, Unknown }; diff --git a/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp new file mode 100644 index 000000000..ac5174000 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 "msp430archiversettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kArchiverArchiveVersion = 4; +constexpr int kArchiverDataVersion = 0; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +//Msp430ArchiverSettingsGroup + +Msp430ArchiverSettingsGroup::Msp430ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XAR")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void Msp430ArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const 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 msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h new file mode 100644 index 000000000..9da8d3445 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_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_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430ArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp new file mode 100644 index 000000000..d87368076 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** 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 "msp430assemblersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kAssemblerArchiveVersion = 5; +constexpr int kAssemblerDataVersion = 14; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = flags.contains( + QLatin1String("-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; + } + + int enableSymbolsCaseSensitive = 1; + int enableMultibyteSupport = 0; + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const auto &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::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 + +//Msp430AssemblerSettingsGroup + +Msp430AssemblerSettingsGroup::Msp430AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("A430")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Msp430AssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {}, {opts.enableSymbolsCaseSensitive}); + // Add 'AMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("AMultibyteSupport"), + {}, {opts.enableMultibyteSupport}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {0}, {opts.macroQuoteCharacter}); +} + +void Msp430AssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'ADebug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("ADebug"), + {}, {opts.debugInfo}); +} + +void Msp430AssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + {}, opts.defineSymbols); + // Add 'AUserIncludes' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("AUserIncludes"), + {}, opts.includePaths); +} + +void Msp430AssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const 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 msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h new file mode 100644 index 000000000..97a59f4cd --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_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_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430AssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430AssemblerSettingsGroup( + 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 msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp new file mode 100644 index 000000000..bd80cdd7f --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 "msp430archiversettingsgroup_v7.h" +#include "msp430assemblersettingsgroup_v7.h" +#include "msp430buildconfigurationgroup_v7.h" +#include "msp430compilersettingsgroup_v7.h" +#include "msp430generalsettingsgroup_v7.h" +#include "msp430linkersettingsgroup_v7.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +Msp430BuildConfigurationGroup::Msp430BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("MSP430"); + + // Append debug info item. + const int debugBuild = gen::utils::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 Msp430BuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Msp430 + && version.majorVersion() == 7; +} + +std::unique_ptr +Msp430BuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new Msp430BuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h new file mode 100644 index 000000000..ba0404c0b --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H +#define QBS_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H + +#include +#include + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430BuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit Msp430BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class Msp430BuildConfigurationGroupFactory; +}; + +class Msp430BuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp new file mode 100644 index 000000000..214b51437 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp @@ -0,0 +1,486 @@ +/**************************************************************************** +** +** 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 "msp430compilersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kCompilerArchiveVersion = 4; +constexpr int kCompilerDataVersion = 38; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Language one page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C99LanguageDialect + }; + + enum CxxLanguageDialect { + EmbeddedCPlusPlus, + ExtendedEmbeddedCPlusPlus + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // C language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + if (cLanguageVersion.contains(QLatin1String("c89"))) + cLanguageDialect = LanguageOnePageOptions::C89LanguageDialect; + else if (cLanguageVersion.contains(QLatin1String("c99"))) + cLanguageDialect = LanguageOnePageOptions::C99LanguageDialect; + // C++ language dialect. + if (flags.contains(QLatin1String("--ec++"))) + cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus; + else if (flags.contains(QLatin1String("--eec++"))) + cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus; + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + + allowVla = flags.contains(QLatin1String("--vla")); + useCppInlineSemantics = flags.contains( + QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains( + QLatin1String("--require_prototypes")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C99LanguageDialect; + CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus; + LanguageConformance languageConformance = AllowIarExtension; + int allowVla = 0; + int useCppInlineSemantics = 0; + int requirePrototypes = 0; + int destroyStaticObjects = 0; +}; + +// Language two page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains(QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + guardCalls = flags.contains( + QLatin1String("--guard_calls")); + } + + PlainCharacter plainCharacter = UnsignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; + int enableMultibyteSupport = 0; + int guardCalls = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + enum Utilization { + UtilizationNormalUse, + UtilizationRegVarVariables, + UtilizationNotUsed + }; + + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // Detect R4 utilization. + if (flags.contains(QLatin1String("--lock_r4"))) + r4utilization = UtilizationNotUsed; + else if (flags.contains(QLatin1String("--regvar_r4"))) + r4utilization = UtilizationRegVarVariables; + // Detect R5 utilization. + if (flags.contains(QLatin1String("--lock_r5"))) + r5utilization = UtilizationNotUsed; + else if (flags.contains(QLatin1String("--regvar_r54"))) + r5utilization = UtilizationRegVarVariables; + // Detect reduce stack usage. + reduceStackUsage = flags.contains( + QLatin1String("--reduce_stack_usage")); + // Detect 20-bit context save on interrupt. + save20BitContextOnInterrupt = flags.contains( + QLatin1String("--save_reg20")); + } + + Utilization r4utilization = UtilizationNormalUse; + Utilization r5utilization = UtilizationNormalUse; + int reduceStackUsage = 0; + int save20BitContextOnInterrupt = 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 = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + disableSizeConstraints = flags.contains( + QLatin1String("--no_size_constraints")); + + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableLoopUnroll = !flags.contains(QLatin1String("--no_unroll")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Separate "no size constraints" checkbox. + int disableSizeConstraints = 0; + + // Five bit-field flags on "enabled transformations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableLoopUnroll = 0; // Loop unrolling. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +} // namespace + +//Msp430CompilerSettingsGroup + +Msp430CompilerSettingsGroup::Msp430CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICC430")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Msp430CompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {}, {opts.debugInfo}); +} + +void Msp430CompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {}, {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {}, {opts.cLanguageDialect}); + // Add 'IccCppDialect' item (C++ dialect: embedded/extended). + addOptionsGroup(QByteArrayLiteral("IccCppDialect"), + {}, {opts.cxxLanguageDialect}); + // Add '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 'IccRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {}, {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {}, {opts.destroyStaticObjects}); +} + +void Msp430CompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'IccCharIs' 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 'IccMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("CCMultibyteSupport"), + {}, {opts.enableMultibyteSupport}); + // Add 'CCGuardCalls' and 'OCGuardCallsSlave' item (Guard calls). + addOptionsGroup(QByteArrayLiteral("CCGuardCalls"), + {}, {opts.guardCalls}); +} + +void Msp430CompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const CodePageOptions opts(qbsProduct); + // Add 'OCCR4Utilize' item + // (R4 utilization: normal/regvar/disabled). + addOptionsGroup(QByteArrayLiteral("OCCR4Utilize"), + {}, {opts.r4utilization}); + // Add 'OCCR5Utilize' item + // (R5 utilization: normal/regvar/disabled). + addOptionsGroup(QByteArrayLiteral("OCCR5Utilize"), + {}, {opts.r5utilization}); + // Add 'ReduceStack' item + // (Reduce stack usage). + addOptionsGroup(QByteArrayLiteral("ReduceStack"), + {}, {opts.reduceStackUsage}); + // Add 'Save20bit' item + // (20-bit context save on interrupt). + addOptionsGroup(QByteArrayLiteral("Save20bit"), + {}, {opts.save20BitContextOnInterrupt}); +} + +void Msp430CompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const 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 'CCOptimizationNoSizeConstraints' item (no size constraints). + addOptionsGroup(QByteArrayLiteral("CCOptimizationNoSizeConstraints"), + {}, {opts.disableSizeConstraints}); + + // Add 'CCAllowList' item + // (Enabled transformations: 5 check boxes). + const QString bitflags = QStringLiteral("%1%2%3%4%5%6") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableLoopUnroll) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableTypeBasedAliasAnalysis); + addOptionsGroup(QByteArrayLiteral("CCAllowList"), + {}, {bitflags}); +} + +void Msp430CompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const 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 Msp430CompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"), + {}, {opts.warningsAsErrors}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h new file mode 100644 index 000000000..498100881 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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_IAREWMSP430COMPILERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430COMPILERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430CompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430CompilerSettingsGroup( + 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 buildCodePage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430COMPILERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp new file mode 100644 index 000000000..935fc6f7a --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp @@ -0,0 +1,483 @@ +/**************************************************************************** +** +** 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 "msp430generalsettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kGeneralArchiveVersion = 21; +constexpr int kGeneralDataVersion = 34; + +namespace { + +// Target page options. + +struct TargetPageOptions final +{ + enum CodeModel { + SmallCodeModel, + LargeCodeModel + }; + + enum DataModel { + SmallDataModel, + MediumDataModel, + LargeDataModel + }; + + enum FloatingPointDoubleSize { + DoubleSize32Bits, + DoubleSize64Bits + }; + + enum HardwareMultiplierType { + AllowDirectAccessMultiplier, + UseOnlyLibraryCallsMultiplier + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target code model. + const QString codeModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--code_model")); + if (codeModelValue == QLatin1String("small")) + codeModel = TargetPageOptions::SmallCodeModel; + else if (codeModelValue == QLatin1String("large")) + codeModel = TargetPageOptions::LargeCodeModel; + // Detect target data model. + const QString dataModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--data_model")); + if (dataModelValue == QLatin1String("small")) + dataModel = TargetPageOptions::SmallDataModel; + else if (dataModelValue == QLatin1String("medium")) + dataModel = TargetPageOptions::MediumDataModel; + else if (dataModelValue == QLatin1String("large")) + dataModel = TargetPageOptions::LargeDataModel; + // Detect floating point double size. + const int doubleSize = IarewUtils::flagValue( + flags, QStringLiteral("--double")).toInt(); + if (doubleSize == 32) + floatingPointDoubleSize = DoubleSize32Bits; + else if (doubleSize == 64) + floatingPointDoubleSize = DoubleSize64Bits; + // Detect hardware multiplier. + const QString multiplier = IarewUtils::flagValue( + flags, QStringLiteral("--multiplier")); + enableHardwareMultiplier = (multiplier.compare(QLatin1String("16")) == 0 + || multiplier.compare(QLatin1String("16s")) == 0 + || multiplier.compare(QLatin1String("32")) == 0); + // Detect code and read-only data position-independence. + enableRopi = flags.contains(QLatin1String("--ropi")); + // No dynamic read-write initialization. + disableDynamicReadWriteInitialization = flags.contains( + QLatin1String("--no_rw_dynamic_init")); + + // Detect target device name. + detectDeviceMenu(qbsProduct); + } + + void detectDeviceMenu(const ProductData &qbsProduct) + { + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + const auto qbsGroups = qbsProduct.groups(); + for (const auto &qbsGroup : qbsGroups) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (!fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) + continue; + + const QFileInfo configInfo(fullConfigPath); + const QString configBase = configInfo.baseName(); + if (!configBase.startsWith(QLatin1String("lnk"))) + continue; + + // Remove 'lnk' prefix. + const QString deviceName = QStringLiteral("MSP%1") + .arg(configBase.mid(3).toUpper()); + + deviceMenu = QStringLiteral("%1\t%1").arg(deviceName); + return; + } + } + + // Falling back to generic menu. + if (deviceMenu.isEmpty()) { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + const QString cpuCore = IarewUtils::flagValue(flags, QStringLiteral("--core")); + if (cpuCore.isEmpty()) + return; + deviceMenu = QStringLiteral("MSP%1\tGeneric MSP%1 device").arg(cpuCore); + return; + } + } + + CodeModel codeModel = LargeCodeModel; + DataModel dataModel = SmallDataModel; + FloatingPointDoubleSize floatingPointDoubleSize = DoubleSize32Bits; + HardwareMultiplierType hardwareMultiplierType = AllowDirectAccessMultiplier; + int enableHardwareMultiplier = 0; + int enableRopi = 0; + int disableDynamicReadWriteInitialization = 0; + QString deviceMenu; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalDLibrary, + FullDLibrary, + CustomDLibrary, + CLibrary, // deprecated + CustomCLibrary, // deprecated + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QFileInfo configInfo(IarewUtils::flagValue( + flags, + QStringLiteral("--dlib_config"))); + const QString configFilePath = configInfo.absoluteFilePath(); + + if (!configFilePath.isEmpty()) { + const QString libToolkitPath = + IarewUtils::libToolkitRootPath(qbsProduct); + + if (configFilePath.startsWith(libToolkitPath, + Qt::CaseInsensitive)) { + if (configFilePath.endsWith(QLatin1String("n.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalDLibrary; + } else if (configFilePath.endsWith(QLatin1String("f.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::FullDLibrary; + } else { + libraryType = LibraryConfigPageOptions::CustomDLibrary; + } + + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, configFilePath); + } else { + libraryType = LibraryConfigPageOptions::CustomDLibrary; + + configPath = configFilePath; + } + } + } + + RuntimeLibrary libraryType = NormalDLibrary; + QString libraryPath; + QString configPath; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter = 0, + PrintfFullFormatter = 1, + PrintfFullNoMultibytesFormatter = 2, + PrintfLargeFormatter = 3, + PrintfLargeNoMultibytesFormatter = 4, + PrintfSmallFormatter = 5, + PrintfSmallNoMultibytesFormatter = 6, + PrintfTinyFormatter = 7 + }; + + enum ScanfFormatter { + ScanfAutoFormatter = 0, + ScanfFullFormatter = 1, + ScanfFullNoMultibytesFormatter = 2, + ScanfLargeFormatter = 3, + ScanfLargeNoMultibytesFormatter = 4, + ScanfSmallFormatter = 5, + ScanfSmallNoMultibytesFormatter = 6 + }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (flagIt->endsWith(QLatin1String("=_printf"), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("_printffull")) + printfFormatter = PrintfFullFormatter; + else if (prop == QLatin1String("_printffullnomb")) + printfFormatter = PrintfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_printflarge")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printflargenomb")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printfsmall")) + printfFormatter = PrintfSmallFormatter; + else if (prop == QLatin1String("_printfsmallnomb")) + printfFormatter = PrintfSmallNoMultibytesFormatter; + else if (prop == QLatin1String("_printftiny")) + printfFormatter = PrintfTinyFormatter; + } else if (flagIt->endsWith(QLatin1String("=_scanf"), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("_scanffull")) + scanfFormatter = ScanfFullFormatter; + else if (prop == QLatin1String("_scanffullnomb")) + scanfFormatter = ScanfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_scanflarge")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanflargenomb")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanfsmall")) + scanfFormatter = ScanfSmallFormatter; + else if (prop == QLatin1String("_scanfsmallnomb")) + scanfFormatter = ScanfSmallNoMultibytesFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Stack/heap page options. + +struct StackHeapPageOptions final +{ + explicit StackHeapPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + + // Detect stack size. + stackSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_STACK_SIZE")); + if (stackSize.isEmpty()) + stackSize = QLatin1String("A0"); + // Detect data heap16 size. + data16HeapSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_DATA16_HEAP_SIZE")); + if (data16HeapSize.isEmpty()) + stackSize = QLatin1String("A0"); + // Detect data heap20 size. + data20HeapSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_DATA20_HEAP_SIZE")); + if (data20HeapSize.isEmpty()) + stackSize = QLatin1String("50"); + } + + QString stackSize; + QString data16HeapSize; + QString data20HeapSize; +}; + +} // namespace + +//Msp430GeneralSettingsGroup + +Msp430GeneralSettingsGroup::Msp430GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildStackHeapPage(qbsProduct); +} + +void Msp430GeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'OGChipSelectMenu' item + // (Device: xxx). + addOptionsGroup(QByteArrayLiteral("OGChipSelectMenu"), + {}, {opts.deviceMenu}); + + // Add 'RadioCodeModelType' item + // (Code model: small/large). + addOptionsGroup(QByteArrayLiteral("RadioCodeModelType"), + {}, {opts.codeModel}); + // Add 'RadioDataModelType' item + // (Data model: small/medium/large). + addOptionsGroup(QByteArrayLiteral("RadioDataModelType"), + {}, {opts.dataModel}); + // Add 'OGDouble' item + // (Floating point double size: 32/64 bits). + addOptionsGroup(QByteArrayLiteral("OGDouble"), + {}, {opts.floatingPointDoubleSize}); + // Add 'Hardware Multiplier' item + // (Hardware multiplier). + addOptionsGroup(QByteArrayLiteral("Hardware Multiplier"), + {}, {opts.enableHardwareMultiplier}); + if (opts.enableHardwareMultiplier) { + // Add 'RadioHardwareMultiplierType' item. + addOptionsGroup(QByteArrayLiteral("Hardware RadioHardwareMultiplierType"), + {}, {opts.hardwareMultiplierType}); + } + // Add 'Ropi' item. + // (Position independence: Code and read-only data). + addOptionsGroup(QByteArrayLiteral("Ropi"), + {}, {opts.enableRopi}); + // Add 'NoRwDynamicInit' item. + // (Position independence: No dynamic read/write initialization). + addOptionsGroup(QByteArrayLiteral("NoRwDynamicInit"), + {}, {opts.disableDynamicReadWriteInitialization}); +} + +void Msp430GeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {}, {opts.binaryType}); + // Add 'ExePath' item (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {}, {opts.binaryDirectory}); + // Add 'ObjPath' item (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {}, {opts.objectDirectory}); + // Add 'ListPath' item (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {}, {opts.listingDirectory}); +} + +void Msp430GeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GRuntimeLibSelect' and 'GRuntimeLibSelectSlave' items + // (Link with runtime: none/normal/full/custom). + 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 Msp430GeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const LibraryOptionsPageOptions opts(qbsProduct); + // Add 'Output variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Output variant"), + {}, {opts.printfFormatter}); + // Add 'Input variant' item (Scanf formatter). + addOptionsGroup(QByteArrayLiteral("Input variant"), + {}, {opts.scanfFormatter}); +} + +void Msp430GeneralSettingsGroup::buildStackHeapPage( + const ProductData &qbsProduct) +{ + const StackHeapPageOptions opts(qbsProduct); + // Add 'GStackHeapOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("GStackHeapOverride"), + {}, {1}); + // Add 'GStackSize2' item (Stack size). + addOptionsGroup(QByteArrayLiteral("GStackSize2"), + {}, {opts.stackSize}); + // Add 'GHeapSize2' item (Heap16 size). + addOptionsGroup(QByteArrayLiteral("GHeapSize2"), + {}, {opts.data16HeapSize}); + // Add 'GHeap20Size' item (Heap16 size). + addOptionsGroup(QByteArrayLiteral("GHeap20Size"), + {}, {opts.data20HeapSize}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h new file mode 100644 index 000000000..35e9e7b32 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_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_IAREWMSP430GENERALSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430GENERALSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430GeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildStackHeapPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430GENERALSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp new file mode 100644 index 000000000..3e876f9fd --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** 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 "msp430linkersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kLinkerArchiveVersion = 4; +constexpr int kLinkerDataVersion = 30; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + const auto qbsGroups = qbsProduct.groups(); + for (const auto &qbsGroup : qbsGroups) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '-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); + } + } + + // Library search paths. + librarySearchPaths = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + + // Entry point. + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + } + + QVariantList configFilePaths; + QVariantList librarySearchPaths; + QString entryPoint; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = gen::utils::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 = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = NoListing; +}; + +// Define page options. + +struct DefinePageOptions final +{ + explicit DefinePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + // Enumerate all linker defines. + for (const QString &flag : flags) { + if (!flag.startsWith(QLatin1String("-D"))) + continue; + const QString symbol = flag.mid(2); + // Ignore system-defined macroses, because its already + // handled in "General Options" page. + if (symbol.startsWith(QLatin1Char('?')) + || symbol.startsWith(QLatin1Char('_')) + ) { + continue; + } + defineSymbols.push_back(symbol); + } + } + + QVariantList defineSymbols; +}; + +} // namespace + +//Msp430LinkerSettingsGroup + +Msp430LinkerSettingsGroup::Msp430LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + setName(QByteArrayLiteral("XLINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void Msp430LinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add '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; + } + } + + // Add 'xcOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("xcOverrideProgramEntryLabel"), + {}, {1}); + // Add 'xcProgramEntryLabel' item (Entry point name). + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabel"), + {}, {opts.entryPoint}); + + // Add 'XIncludes' item (Entry point name). + addOptionsGroup(QByteArrayLiteral("XIncludes"), + {}, {opts.librarySearchPaths}); +} + +void Msp430LinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + + // Add 'XOutOverride' item (Output file name). + addOptionsGroup(QByteArrayLiteral("XOutOverride"), + {}, {1}); + // Add 'OutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {}, {opts.outputFile}); +} + +void Msp430LinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'XList' item (Generate linker map file). + addOptionsGroup(QByteArrayLiteral("XList"), + {}, {opts.generateMap}); +} + +void Msp430LinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const DefinePageOptions opts(qbsProduct); + // Add 'XDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("XDefines"), + {}, opts.defineSymbols); +} + +void Msp430LinkerSettingsGroup::buildExtraOptionsPage( + const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + if (m_extraOptions.isEmpty()) + return; + + // Add 'XExtraOptionsCheck' (Use command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptionsCheck"), + {}, {1}); + // Add 'XExtraOptions' item (Command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptions"), + {}, m_extraOptions); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h new file mode 100644 index 000000000..2b6f11514 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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_IAREWMSP430LINKERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430LINKERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430LinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildDefinePage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430LINKERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/iarew.pro b/src/plugins/generator/iarew/iarew.pro index d931f365f..7de474a45 100644 --- a/src/plugins/generator/iarew/iarew.pro +++ b/src/plugins/generator/iarew/iarew.pro @@ -113,3 +113,21 @@ SOURCES += \ $$PWD/archs/stm8/stm8compilersettingsgroup_v3.cpp \ $$PWD/archs/stm8/stm8generalsettingsgroup_v3.cpp \ $$PWD/archs/stm8/stm8linkersettingsgroup_v3.cpp + +# For MSP430 architecture. + +HEADERS += \ + $$PWD/archs/msp430/msp430archiversettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430assemblersettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430buildconfigurationgroup_v7.h \ + $$PWD/archs/msp430/msp430compilersettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430generalsettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430linkersettingsgroup_v7.h + +SOURCES += \ + $$PWD/archs/msp430/msp430archiversettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430assemblersettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430buildconfigurationgroup_v7.cpp \ + $$PWD/archs/msp430/msp430compilersettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430generalsettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430linkersettingsgroup_v7.cpp diff --git a/src/plugins/generator/iarew/iarew.qbs b/src/plugins/generator/iarew/iarew.qbs index bfa2093fa..7b2270426 100644 --- a/src/plugins/generator/iarew/iarew.qbs +++ b/src/plugins/generator/iarew/iarew.qbs @@ -111,4 +111,22 @@ QbsPlugin { "stm8linkersettingsgroup_v3.h", ] } + Group { + name: "IAR EW generator for MSP430" + prefix: "archs/msp430/" + files: [ + "msp430archiversettingsgroup_v7.cpp", + "msp430archiversettingsgroup_v7.h", + "msp430assemblersettingsgroup_v7.cpp", + "msp430assemblersettingsgroup_v7.h", + "msp430buildconfigurationgroup_v7.cpp", + "msp430buildconfigurationgroup_v7.h", + "msp430compilersettingsgroup_v7.cpp", + "msp430compilersettingsgroup_v7.h", + "msp430generalsettingsgroup_v7.cpp", + "msp430generalsettingsgroup_v7.h", + "msp430linkersettingsgroup_v7.cpp", + "msp430linkersettingsgroup_v7.h", + ] + } } diff --git a/src/plugins/generator/iarew/iarewfileversionproperty.cpp b/src/plugins/generator/iarew/iarewfileversionproperty.cpp index 86790cdf1..446b385b8 100644 --- a/src/plugins/generator/iarew/iarewfileversionproperty.cpp +++ b/src/plugins/generator/iarew/iarewfileversionproperty.cpp @@ -36,7 +36,10 @@ namespace qbs { static QByteArray buildFileVersion(const IarewVersionInfo &versionInfo) { switch (versionInfo.marketingVersion()) { + case 3: + case 7: case 8: + case 10: return QByteArrayLiteral('3'); default: return {}; diff --git a/src/plugins/generator/iarew/iarewproject.cpp b/src/plugins/generator/iarew/iarewproject.cpp index 17e69fa31..3e6a03ac2 100644 --- a/src/plugins/generator/iarew/iarewproject.cpp +++ b/src/plugins/generator/iarew/iarewproject.cpp @@ -38,6 +38,7 @@ #include "archs/avr/avrbuildconfigurationgroup_v7.h" #include "archs/mcs51/mcs51buildconfigurationgroup_v10.h" #include "archs/stm8/stm8buildconfigurationgroup_v3.h" +#include "archs/msp430/msp430buildconfigurationgroup_v7.h" #include @@ -59,6 +60,8 @@ IarewProject::IarewProject(const GeneratableProject &genProject, iarew::mcs51::v10::Mcs51BuildConfigurationGroupFactory>()); m_factories.push_back(std::make_unique< iarew::stm8::v3::Stm8BuildConfigurationGroupFactory>()); + m_factories.push_back(std::make_unique< + iarew::msp430::v7::Msp430BuildConfigurationGroupFactory>()); // Construct file version item. appendChild(versionInfo); diff --git a/src/plugins/generator/iarew/iarewversioninfo.cpp b/src/plugins/generator/iarew/iarewversioninfo.cpp index 2fc14d515..41a788e98 100644 --- a/src/plugins/generator/iarew/iarewversioninfo.cpp +++ b/src/plugins/generator/iarew/iarewversioninfo.cpp @@ -54,7 +54,8 @@ std::set IarewVersionInfo::knownVersions() { static const std::set known = { {Version(8), {gen::utils::Architecture::Arm}}, - {Version(7), {gen::utils::Architecture::Avr}}, + {Version(7), {gen::utils::Architecture::Avr, + gen::utils::Architecture::Msp430}}, {Version(10), {gen::utils::Architecture::Mcs51}}, {Version(3), {gen::utils::Architecture::Stm8}}, }; -- cgit v1.2.3