diff options
Diffstat (limited to 'src/plugins/generator/keiluv/archs/mcs51')
24 files changed, 2038 insertions, 0 deletions
diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp new file mode 100644 index 000000000..e9af55743 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51buildtargetgroup_v5.h" +#include "mcs51commonpropertygroup_v5.h" +#include "mcs51debugoptiongroup_v5.h" +#include "mcs51dlloptiongroup_v5.h" +#include "mcs51targetcommonoptionsgroup_v5.h" +#include "mcs51targetgroup_v5.h" +#include "mcs51utilitiesgroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvfilesgroupspropertygroup.h" +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51BuildTargetGroup::Mcs51BuildTargetGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector<ProductData> &qbsProductDeps) + : KeiluvPropertyGroup("Target") +{ + // Append target name item (it is a build configuration name). + const QString targetName = qbs::KeiluvUtils::buildConfigurationName( + qbsProject); + appendProperty(QByteArrayLiteral("TargetName"), targetName); + // Append toolset number group item. + appendChild<KeiluvProperty>(QByteArrayLiteral("ToolsetNumber"), + QByteArrayLiteral("0x0")); + // Append toolset name group item. + appendChild<KeiluvProperty>(QByteArrayLiteral("ToolsetName"), + QByteArrayLiteral("MCS-51")); + + // Append target option group item. + const auto targetOptionGroup = appendChild<KeiluvPropertyGroup>( + QByteArrayLiteral("TargetOption")); + + targetOptionGroup->appendChild<Mcs51TargetCommonOptionsGroup>( + qbsProject, qbsProduct); + targetOptionGroup->appendChild<Mcs51CommonPropertyGroup>( + qbsProject, qbsProduct); + targetOptionGroup->appendChild<Mcs51DllOptionGroup>( + qbsProject, qbsProduct); + targetOptionGroup->appendChild<Mcs51DebugOptionGroup>( + qbsProject, qbsProduct); + targetOptionGroup->appendChild<Mcs51UtilitiesGroup>( + qbsProject, qbsProduct); + targetOptionGroup->appendChild<Mcs51TargetGroup>( + qbsProject, qbsProduct); + + // Append files group. + appendChild<KeiluvFilesGroupsPropertyGroup>(qbsProject, qbsProduct, + qbsProductDeps); +} + +bool Mcs51BuildTargetGroupFactory::canCreate( + qbs::KeiluvUtils::Architecture architecture, + const Version &version) const +{ + return architecture == qbs::KeiluvUtils::Architecture::Mcs51Architecture + && version.majorVersion() == KeiluvConstants::kUVisionVersion; +} + +std::unique_ptr<KeiluvPropertyGroup> Mcs51BuildTargetGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector<ProductData> &qbsProductDeps) const +{ + const auto group = new Mcs51BuildTargetGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr<Mcs51BuildTargetGroup>(group); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h new file mode 100644 index 000000000..3f11c489e --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H +#define QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51BuildTargetGroup final : public KeiluvPropertyGroup +{ +private: + explicit Mcs51BuildTargetGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector<ProductData> &qbsProductDeps); + + friend class Mcs51BuildTargetGroupFactory; +}; + +class Mcs51BuildTargetGroupFactory final : public KeiluvPropertyGroupFactory +{ +public: + bool canCreate(KeiluvUtils::Architecture architecture, + const Version &version) const final; + + std::unique_ptr<KeiluvPropertyGroup> create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector<ProductData> &qbsProductDeps) const final; +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp new file mode 100644 index 000000000..32760df23 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51commonpropertygroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51CommonPropertyGroup::Mcs51CommonPropertyGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("CommonProperty") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h new file mode 100644 index 000000000..185d498d0 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51COMMONPROPERTYGROUP_V5_H +#define QBS_KEILUVMCS51COMMONPROPERTYGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51CommonPropertyGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51CommonPropertyGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_MCS51COMMONPROPERTYGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp new file mode 100644 index 000000000..5f2494f8f --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51debugoptiongroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51DebugOptionGroup::Mcs51DebugOptionGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("DebugOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h new file mode 100644 index 000000000..e19f1edf8 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H +#define QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51DebugOptionGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51DebugOptionGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp new file mode 100644 index 000000000..26639b9bf --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51dlloptiongroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51DllOptionGroup::Mcs51DllOptionGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("DllOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h new file mode 100644 index 000000000..5144dfd72 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H +#define QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51DllOptionGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51DllOptionGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp new file mode 100644 index 000000000..00120a56d --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetassemblergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct AssemblerPageOptions final +{ + explicit AssemblerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleAssemblerFlags(qbsProps); + + // Don't use standard macro. + if (flags.contains(QLatin1String("NOMACRO"), Qt::CaseInsensitive)) + useStandardMacroProcessor = false; + + // Use MPL. + if (flags.contains(QLatin1String("MPL"), Qt::CaseInsensitive)) + useMacroProcessingLanguage = true; + + // Define 8051 SFR names. + if (flags.contains(QLatin1String("NOMOD51"), Qt::CaseInsensitive)) + suppressSfrNames = true; + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other assembler flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.compare(QLatin1String("NOMACRO"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MACRO"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOMPL"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MPL"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOMOD51"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MOD51"), + Qt::CaseInsensitive) == 0 + ) { + continue; + } + miscControls.push_back(flag); + } + } + + int useStandardMacroProcessor = true; + int useMacroProcessingLanguage = false; + int suppressSfrNames = false; + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetAssemblerGroup::Mcs51TargetAssemblerGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("Ax51") +{ + const AssemblerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Macro processor (Standard)' + appendProperty(QByteArrayLiteral("UseStandard"), + opts.useStandardMacroProcessor); + // Add 'Macro processor (MPL)' + appendProperty(QByteArrayLiteral("UseMpl"), + opts.useMacroProcessingLanguage); + // Add 'Define 8051 SFR names' + appendProperty(QByteArrayLiteral("UseMod51"), + opts.suppressSfrNames); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild<KeiluvPropertyGroup>( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), + opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h new file mode 100644 index 000000000..8a183c30b --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 +#define QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetAssemblerGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetAssemblerGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp new file mode 100644 index 000000000..00d15d34b --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetcommonoptionsgroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct CommonPageOptions final +{ + explicit CommonPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Browse information. + if (flags.contains(QLatin1String("BROWSE"), Qt::CaseInsensitive)) + browseInfo = true; + + // Debug information. + debugInfo = KeiluvUtils::debugInformation(qbsProduct); + + // Output parameters. + executableName = KeiluvUtils::targetBinary(qbsProduct); + // Fix output binary name if it is a library. Because + // the IDE appends an additional suffix (.LIB) to end + // of an output library name. + if (executableName.endsWith(QLatin1String(".lib"))) + executableName = qbsProduct.targetName(); + + + const QString baseDirectory = KeiluvUtils::buildRootPath(qbsProject); + objectDirectory = KeiluvUtils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = KeiluvUtils::listingOutputDirectory( + baseDirectory, qbsProduct); + + // Target type. + targetType = KeiluvUtils::outputBinaryType(qbsProduct); + } + + int browseInfo = false; + int debugInfo = false; + QString executableName; + QString objectDirectory; + QString listingDirectory; + KeiluvUtils::OutputBinaryType targetType = + KeiluvUtils::ApplicationOutputType; +}; + +} // namespace + +Mcs51TargetCommonOptionsGroup::Mcs51TargetCommonOptionsGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("TargetCommonOption") +{ + const CommonPageOptions opts(qbsProject, qbsProduct); + + // Add 'Generic 8051 device' items, + // because we can't detect a target device + // form the present command lines. + appendProperty(QByteArrayLiteral("Device"), + QByteArrayLiteral("8051 (all Variants)")); + appendProperty(QByteArrayLiteral("Vendor"), + QByteArrayLiteral("Generic")); + appendProperty(QByteArrayLiteral("DeviceId"), + QByteArrayLiteral("2994")); + + // Add 'Debug Information' item. + appendProperty(QByteArrayLiteral("DebugInformation"), + opts.debugInfo); + // Add 'Browse Information' item. + appendProperty(QByteArrayLiteral("BrowseInformation"), + opts.browseInfo); + + // Add 'Name of Executable'. + appendProperty(QByteArrayLiteral("OutputName"), + opts.executableName); + // Add 'Output objects directory'. + appendProperty(QByteArrayLiteral("OutputDirectory"), + opts.objectDirectory); + // Add 'Output listing directory'. + appendProperty(QByteArrayLiteral("ListingPath"), + opts.listingDirectory); + + // Add 'Create Executable/Library' item. + const int isExecutable = (opts.targetType + == KeiluvUtils::ApplicationOutputType); + const int isLibrary = (opts.targetType + == KeiluvUtils::LibraryOutputType); + appendProperty(QByteArrayLiteral("CreateExecutable"), + isExecutable); + appendProperty(QByteArrayLiteral("CreateLib"), + isLibrary); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h new file mode 100644 index 000000000..7535b3373 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H +#define QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetCommonOptionsGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetCommonOptionsGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp new file mode 100644 index 000000000..76a246508 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetcompilergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct CompilerPageOptions final +{ + enum WarningLevel { + WarningLevelNone = 0, + WarningLevelOne, + WarningLevelTwo + }; + + enum OptimizationLevel { + ConstantFoldingOptimizationLevel = 0, + DeadCodeEliminationOptimizationLevel, + DataOverlayingOptimizationLevel, + PeepholeOptimizationLevel, + RegisterVariablesOptimizationLevel, + CommonSubexpressionEliminationOptimizationLevel, + LoopRotationOptimizationLevel, + ExtendedIndexAccessOptimizationLevel, + ReuseCommonEntryCodeOptimizationLevel, + CommonBlockSubroutinesOptimizationLevel, + RearrangeCodeOptimizationLevel, + ReuseCommonExitCodeOptimizationLevel + }; + + enum OptimizationEmphasis { + FavorSizeOptimizationEmphasis = 0, + FavorSpeedOptimizationEmphasis + }; + + enum FloatFuzzyBits { + NoFloatFuzzyBits = 0, + OneFloatFuzzyBit, + TwoFloatFuzzyBits, + ThreeFloatFuzzyBits, + FourFloatFuzzyBits, + FiveFloatFuzzyBits, + SixFloatFuzzyBits, + SevenFloatFuzzyBits + }; + + explicit CompilerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Warnings. + const QString level = qbs::KeiluvUtils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (level == QLatin1String("none")) { + warningLevel = WarningLevelNone; + } else if (level == QLatin1String("all")) { + warningLevel = WarningLevelTwo; + } else { + // In this case take it directly from the compiler command line, + // e.g. parse the line in a form: 'WARNINGLEVEL (2)' + const auto warnValue = KeiluvUtils::flagValue( + flags, QStringLiteral("WARNINGLEVEL")); + bool ok = false; + const auto level = warnValue.toInt(&ok); + if (ok && qbs::KeiluvUtils::inBounds( + level, int(WarningLevelNone),int(WarningLevelTwo))) { + warningLevel = static_cast<WarningLevel>(level); + } + } + + // Optimizations. + const QString optimization = qbs::KeiluvUtils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("fast")) { + optimizationEmphasis = FavorSpeedOptimizationEmphasis; + } else if (level == QLatin1String("small")) { + optimizationEmphasis = FavorSizeOptimizationEmphasis; + } else if (level == QLatin1String("small")) { + // Don't supported by C51 compiler. + } else { + // In this case take it directly from the compiler command line, + // e.g. parse the line in a form: 'OPTIMIZE (8, SPEED)' + const auto optValue = KeiluvUtils::flagValue( + flags, QStringLiteral("OPTIMIZE")); + const auto parts = KeiluvUtils::flagValueParts(optValue); + for (const auto &part : parts) { + bool ok = false; + const auto level = part.toInt(&ok); + if (ok && (level >= ConstantFoldingOptimizationLevel) + && (level <= ReuseCommonExitCodeOptimizationLevel)) { + optimizationLevel = static_cast<OptimizationLevel>(level); + } else if (part.compare(QLatin1String("SIZE"), + Qt::CaseInsensitive) == 0) { + optimizationEmphasis = FavorSizeOptimizationEmphasis; + } else if (part.compare(QLatin1String("SPEED"), + Qt::CaseInsensitive) == 0) { + optimizationEmphasis = FavorSpeedOptimizationEmphasis; + } + } + } + + // Don't use absolute register accesses. + if (flags.contains(QLatin1String("NOAREGS"), Qt::CaseInsensitive)) + dontuseAbsoluteRegsAccess = true; + + // Enable ANSI integer promotion rules. + if (flags.contains(QLatin1String("NOINTPROMOTE"), Qt::CaseInsensitive)) + enableIntegerPromotionRules = false; + + // Keep variables in order. + if (flags.contains(QLatin1String("ORDER"), Qt::CaseInsensitive)) + keepVariablesInOrder = true; + + // Don't use interrupt vector. + if (flags.contains(QLatin1String("NOINTVECTOR"), Qt::CaseInsensitive)) + useInterruptVector = false; + + // Interrupt vector address. + interruptVectorAddress = KeiluvUtils::flagValue( + flags, QStringLiteral("INTVECTOR")); + + // Float fuzzy bits count. + const auto bitsValue = KeiluvUtils::flagValue( + flags, QStringLiteral("FLOATFUZZY")); + bool ok = false; + const auto bits = bitsValue.toInt(&ok); + if (ok && qbs::KeiluvUtils::inBounds( + bits, int(NoFloatFuzzyBits), int(SevenFloatFuzzyBits))) { + floatFuzzyBits = static_cast<FloatFuzzyBits>(bits); + } + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other compiler flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.startsWith(QLatin1String("WARNINGLEVEL"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("OPTIMIZE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("FLOATFUZZY"), + Qt::CaseInsensitive) + || flag.compare(QLatin1String("NOAREGS"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("AREGS"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOINTPROMOTE"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("INTPROMOTE"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOINTVECTOR"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("INTVECTOR"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("ORDER"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("BROSWE"), + Qt::CaseInsensitive) == 0 + ) { + continue; + } + miscControls.push_back(flag); + } + } + + WarningLevel warningLevel = WarningLevelTwo; + OptimizationLevel optimizationLevel = ReuseCommonEntryCodeOptimizationLevel; + OptimizationEmphasis optimizationEmphasis = FavorSpeedOptimizationEmphasis; + FloatFuzzyBits floatFuzzyBits = ThreeFloatFuzzyBits; + int dontuseAbsoluteRegsAccess = false; + int enableIntegerPromotionRules = true; + int keepVariablesInOrder = false; + int useInterruptVector = true; + QString interruptVectorAddress; + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetCompilerGroup::Mcs51TargetCompilerGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("C51") +{ + const CompilerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Code Optimization' options. + appendProperty(QByteArrayLiteral("Optimize"), + opts.optimizationLevel); + appendProperty(QByteArrayLiteral("SizeSpeed"), + opts.optimizationEmphasis); + // Add 'Warnings' options. + appendProperty(QByteArrayLiteral("WarningLevel"), + opts.warningLevel); + // Add 'Don't use absolute register access' item. + appendProperty(QByteArrayLiteral("uAregs"), + opts.dontuseAbsoluteRegsAccess); + // Add 'Enable integer promotion rules' item. + appendProperty(QByteArrayLiteral("IntegerPromotion"), + opts.enableIntegerPromotionRules); + // Add 'Keep variables in order' item. + appendProperty(QByteArrayLiteral("VariablesInOrder"), + opts.keepVariablesInOrder); + // Add 'Use interrupt vector' item. + appendProperty(QByteArrayLiteral("UseInterruptVector"), + opts.useInterruptVector); + appendProperty(QByteArrayLiteral("InterruptVectorAddress"), + opts.interruptVectorAddress); + // Add 'Float fuzzy bits' item. + appendProperty(QByteArrayLiteral("Fuzzy"), + opts.floatFuzzyBits); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild<KeiluvPropertyGroup>( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), + opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h new file mode 100644 index 000000000..801f79ee6 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H +#define QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetCompilerGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetCompilerGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp new file mode 100644 index 000000000..ec583aa29 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetassemblergroup_v5.h" +#include "mcs51targetcompilergroup_v5.h" +#include "mcs51targetgroup_v5.h" +#include "mcs51targetlinkergroup_v5.h" +#include "mcs51targetmiscgroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51TargetGroup::Mcs51TargetGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("Target51") +{ + appendChild<Mcs51TargetMiscGroup>(qbsProject, qbsProduct); + appendChild<Mcs51TargetCompilerGroup>(qbsProject, qbsProduct); + appendChild<Mcs51TargetAssemblerGroup>(qbsProject, qbsProduct); + appendChild<Mcs51TargetLinkerGroup>(qbsProject, qbsProduct); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h new file mode 100644 index 000000000..989e50991 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETGROUP_V5_H +#define QBS_KEILUVMCS51TARGETGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp new file mode 100644 index 000000000..6e5f807a5 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetlinkergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct LinkerPageOptions final +{ + explicit LinkerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleLinkerFlags(qbsProps); + + // Handle all 'BIT' memory flags. + parseMemory(flags, QStringLiteral("BIT"), + bitAddresses, bitSegments); + // Handle all 'CODE' memory flags. + parseMemory(flags, QStringLiteral("CODE"), + codeAddresses, codeSegments); + // Handle all 'DATA' memory flags. + parseMemory(flags, QStringLiteral("DATA"), + dataAddresses, dataSegments); + // Handle all 'IDATA' memory flags. + parseMemory(flags, QStringLiteral("IDATA"), + idataAddresses, idataSegments); + // Handle all 'PDATA' memory flags. + parseMemory(flags, QStringLiteral("PDATA"), + pdataAddresses, pdataSegments); + // Handle all 'XDATA' memory flags. + parseMemory(flags, QStringLiteral("XDATA"), + xdataAddresses, xdataSegments); + + // Enumerate all flags in a form like: + // 'PRECEDE(foo, bar) PRECEDE(baz)'. + const auto precedeValues = KeiluvUtils::flagValues( + flags, QStringLiteral("PRECEDE")); + for (const auto &precedeValue : precedeValues) { + const auto parts = KeiluvUtils::flagValueParts(precedeValue); + precedeSegments.reserve(precedeSegments.size() + parts.count()); + std::copy(parts.cbegin(), parts.cend(), + std::back_inserter(precedeSegments)); + } + + // Enumerate all flags in a form like: + // 'STACK(foo, bar) STACK(baz)'. + const auto stackValues = KeiluvUtils::flagValues( + flags, QStringLiteral("STACK")); + for (const auto &stackValue : stackValues) { + const auto parts = KeiluvUtils::flagValueParts(stackValue); + stackSegments.reserve(stackSegments.size() + parts.count()); + std::copy(parts.cbegin(), parts.cend(), + std::back_inserter(stackSegments)); + } + + // Interpret other linker flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.startsWith(QLatin1String("BIT"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("CODE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("DATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("IDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("PDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("XDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("PRECEDE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("STACK"), + Qt::CaseInsensitive) + ) { + continue; + } + miscControls.push_back(flag); + } + } + + static void parseMemory(const QStringList &flags, + const QString &flagKey, + QStringList &destAddresses, + QStringList &destSegments) + { + // Handle all flags in a form like: + // 'FLAGKEY(0x00-0x20, 30, foo, bar(0x40)) FLAGKEY(baz)'. + const auto values = KeiluvUtils::flagValues(flags, flagKey); + for (const auto &value : values) { + const auto parts = KeiluvUtils::flagValueParts(value); + for (const auto &part : parts) { + if (part.contains(QLatin1Char('-'))) { + // Seems, it is an address range. + destAddresses.push_back(part); + } else { + // Check on address (specified in decimal + // or hexadecimal form). + bool ok = false; + part.toInt(&ok, 16); + if (!ok) + part.toInt(&ok, 10); + if (ok) { + // Seems, it is just a single address. + destAddresses.push_back(part); + } else { + // Seems it is a segment name. + destSegments.push_back(part); + } + } + } + } + } + + QStringList bitAddresses; + QStringList bitSegments; + QStringList codeAddresses; + QStringList codeSegments; + QStringList dataAddresses; + QStringList dataSegments; + QStringList idataAddresses; + QStringList idataSegments; + QStringList pdataAddresses; + QStringList pdataSegments; + QStringList xdataAddresses; + QStringList xdataSegments; + + QStringList precedeSegments; + QStringList stackSegments; + + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetLinkerGroup::Mcs51TargetLinkerGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("Lx51") +{ + const LinkerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Misc Controls' item. + appendMultiLineProperty(QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + + // Add 'Use Memory Layout from Target Dialog' item. + // Note: we always disable it, as we expect that + // the layout will be specified from the linker's + // command line. + appendProperty(QByteArrayLiteral("UseMemoryFromTarget"), + 0); + + // Add 'Bit Range' item. + appendMultiLineProperty(QByteArrayLiteral("BitBaseAddress"), + opts.bitAddresses); + // Add 'Code Range' item. + appendMultiLineProperty(QByteArrayLiteral("CodeBaseAddress"), + opts.codeAddresses); + // Add 'Data Range' item. + appendMultiLineProperty(QByteArrayLiteral("DataBaseAddress"), + opts.dataAddresses); + // Add 'IData Range' item. + appendMultiLineProperty(QByteArrayLiteral("IDataBaseAddress"), + opts.idataAddresses); + // Add 'PData Range' item. + appendMultiLineProperty(QByteArrayLiteral("PDataBaseAddress"), + opts.pdataAddresses); + // Add 'XData Range' item. + appendMultiLineProperty(QByteArrayLiteral("XDataBaseAddress"), + opts.xdataAddresses); + + // Add 'Bit Segment' item. + appendMultiLineProperty(QByteArrayLiteral("BitSegmentName"), + opts.bitSegments); + // Add 'Code Segment' item. + appendMultiLineProperty(QByteArrayLiteral("CodeSegmentName"), + opts.codeSegments); + // Add 'Data Segment' item. + appendMultiLineProperty(QByteArrayLiteral("DataSegmentName"), + opts.dataSegments); + // Add 'IData Segment' item. + appendMultiLineProperty(QByteArrayLiteral("IDataSegmentName"), + opts.idataSegments); + + // Note: PData has not segments! + + // Add 'XData Segment' item. + appendMultiLineProperty(QByteArrayLiteral("XDataSegmentName"), + opts.xdataSegments); + // Add 'Precede' item. + appendMultiLineProperty(QByteArrayLiteral("Precede"), + opts.precedeSegments); + // Add 'Stack' item. + appendMultiLineProperty(QByteArrayLiteral("Stack"), + opts.stackSegments); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h new file mode 100644 index 000000000..d9bbcea4b --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H +#define QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetLinkerGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetLinkerGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp new file mode 100644 index 000000000..193330864 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetmiscgroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct MiscPageOptions final +{ + enum MemoryModel { + SmallMemoryModel = 0, + CompactMemoryModel, + LargeMemoryModel + }; + + enum CodeRomSize { + SmallCodeRomSize = 0, + CompactCodeRomSize, + LargeCodeRomSize + }; + + explicit MiscPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Memory model. + if (flags.contains(QLatin1String("COMPACT"), Qt::CaseInsensitive)) + memoryModel = CompactMemoryModel; + else if (flags.contains(QLatin1String("LARGE"), Qt::CaseInsensitive)) + memoryModel = LargeMemoryModel; + + // Code ROM size. + const auto sizeValue = KeiluvUtils::flagValue( + flags, QStringLiteral("ROM")); + if (sizeValue == QLatin1String("SMALL")) + coderomSize = SmallCodeRomSize; + else if (sizeValue == QLatin1String("COMPACT")) + coderomSize = CompactCodeRomSize; + } + + MemoryModel memoryModel = SmallMemoryModel; + CodeRomSize coderomSize = LargeCodeRomSize; +}; + +} // namespace + +Mcs51TargetMiscGroup::Mcs51TargetMiscGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("Target51Misc") +{ + const MiscPageOptions opts(qbsProject, qbsProduct); + + // Add 'Memory Model' options item. + appendProperty(QByteArrayLiteral("MemoryModel"), + opts.memoryModel); + // Add 'ROM Size' options item. + appendProperty(QByteArrayLiteral("RomSize"), + opts.coderomSize); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h new file mode 100644 index 000000000..e1dfd4a56 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETMISCGROUP_V5_H +#define QBS_KEILUVMCS51TARGETMISCGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetMiscGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51TargetMiscGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETMISCGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp new file mode 100644 index 000000000..380876e51 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51utilitiesgroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51UtilitiesGroup::Mcs51UtilitiesGroup( + const Project &qbsProject, + const ProductData &qbsProduct) + : KeiluvPropertyGroup("Utilities") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h new file mode 100644 index 000000000..4345bd981 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51UTILITIESGROUP_V5_H +#define QBS_KEILUVMCS51UTILITIESGROUP_V5_H + +#include "../../keiluvpropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51UtilitiesGroup final : public KeiluvPropertyGroup +{ +public: + explicit Mcs51UtilitiesGroup( + const Project &qbsProject, + const ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51UTILITIESGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp new file mode 100644 index 000000000..698f0df78 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51utils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { + +namespace KeiluvUtils { + +static QString extractValue(const QString &flag) +{ + const auto openBracketIndex = flag.indexOf(QLatin1Char('(')); + const auto closeBracketIndex = flag.indexOf(QLatin1Char(')')); + const auto n = closeBracketIndex - openBracketIndex - 1; + return flag.mid(openBracketIndex + 1, n); +} + +QStringList flagValues(const QStringList &flags, const QString &flagKey) +{ + QStringList values; + for (const auto &flag : flags) { + if (!flag.startsWith(flagKey, Qt::CaseInsensitive)) + continue; + const auto value = extractValue(flag); + values.push_back(value); + } + return values; +} + +QString flagValue(const QStringList &flags, const QString &flagKey) +{ + const auto flagEnd = flags.cend(); + const auto flagIt = std::find_if(flags.cbegin(), flagEnd, + [flagKey](const auto &flag) { + return flag.startsWith(flagKey, Qt::CaseInsensitive); + }); + if (flagIt == flagEnd) + return {}; // Flag key not found. + return extractValue(*flagIt); +} + +QStringList flagValueParts(const QString &flagValue, const QLatin1Char &sep) +{ + auto parts = flagValue.split(sep); + std::transform(parts.begin(), parts.end(), parts.begin(), + [](const auto &part) { return part.trimmed(); }); + return parts; +} + +} // namespace KeiluvUtils + +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h new file mode 100644 index 000000000..f6ed7e4eb --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com> +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51UTILS_H +#define QBS_KEILUVMCS51UTILS_H + +#include <QtCore/qstringlist.h> + +namespace qbs { + +namespace keiluv { +namespace mcs51 { + +namespace KeiluvUtils { + +QStringList flagValues(const QStringList &flags, const QString &flagKey); + +QString flagValue(const QStringList &flags, const QString &flagKey); + +QStringList flagValueParts(const QString &flagValue, + const QLatin1Char &sep = QLatin1Char(',')); + +} // namespace KeiluvUtils + +namespace v5 { + +namespace KeiluvConstants { + +constexpr int kUVisionVersion = 5; + +} // namespace KeiluvConstants + +} // namespace v5 + +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51UTILS_H + |