diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2019-08-02 19:30:15 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2019-08-20 11:29:48 +0000 |
commit | 276a969d857922367a65a36b16f885745ea4a5f2 (patch) | |
tree | 003e8f638a10a461f20e2968aa33493bc4996b13 /src/lib/corelib/generators/generatorutils.cpp | |
parent | 17f7e6a79e17fe19e0bf5c6f9189ca513406740d (diff) |
baremetal: Long live the KEIL UV project generator for ARM
Right now it is possible to generate a native projects for the
KEIL UVision IDE, e.g. using the following command:
qbs generate -g keiluv5 -d <path/to/build/directory> -f <path/to/qbs/project> profile:<your/qbs/profile>
We need in a valid KEIL QBS profile, from which the generator take
a desired target architecture and other stuff.
The KEIL UV 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 KEIL UVsion project.
Currently it is supported only one 'keiluv5' generator which allow to
generate a projects for the KEIL UVision v5 for ARM architecture.
Tested with the KEIL UVision v5.23 for ARM, using as the QBS
bare-metal examples, and as other projects.
Change-Id: I3af9d01f25a9570a99a62d4ce2c30fec3566b9a1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/generators/generatorutils.cpp')
-rw-r--r-- | src/lib/corelib/generators/generatorutils.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/corelib/generators/generatorutils.cpp b/src/lib/corelib/generators/generatorutils.cpp index 872adbba2..5c93c0502 100644 --- a/src/lib/corelib/generators/generatorutils.cpp +++ b/src/lib/corelib/generators/generatorutils.cpp @@ -208,6 +208,53 @@ QVariantList cppVariantModuleProperties(const PropertyMap &qbsProps, return properties; } +static QString parseFlagValue(const QString &flagKey, + QStringList::const_iterator &flagIt, + const QStringList::const_iterator &flagEnd) +{ + if (flagIt->contains(QLatin1Char('='))) { + // In this case an option is in form of 'flagKey=<flagValue>'. + const auto parts = flagIt->split(QLatin1Char('=')); + if (parts.count() == 2) + return parts.at(1).trimmed(); + } else if (flagKey < *flagIt) { + // In this case an option is in form of 'flagKey<flagValue>'. + return flagIt->mid(flagKey.count()).trimmed(); + } else { + // In this case an option is in form of 'flagKey <flagValue>'. + ++flagIt; + if (flagIt < flagEnd && !flagIt->startsWith(QLatin1Char('-'))) + return (*flagIt).trimmed(); + } + return {}; +} + +QString firstFlagValue(const QStringList &flags, const QString &flagKey) +{ + const auto flagBegin = flags.cbegin(); + const auto flagEnd = flags.cend(); + auto flagIt = std::find_if(flagBegin, flagEnd, [flagKey](const QString &flag) { + return flag == flagKey || flag.startsWith(flagKey); + }); + if (flagIt == flagEnd) + return {}; + return parseFlagValue(flagKey, flagIt, flagEnd); +} + +QStringList allFlagValues(const QStringList &flags, const QString &flagKey) +{ + QStringList values; + const auto flagEnd = flags.cend(); + for (auto flagIt = flags.cbegin(); flagIt < flagEnd; ++flagIt) { + if (*flagIt == flagKey || flagIt->startsWith(flagKey)) { + const QString value = parseFlagValue(flagKey, flagIt, flagEnd); + if (!value.isEmpty()) + values.push_back(value); + } + } + return values; +} + } // namespace utils } // namespace gen } // namespace qbs |