diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2021-02-01 21:38:46 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2021-02-02 15:50:54 +0000 |
commit | d00af6b0dcc1a567c29ebb46bc30368886663555 (patch) | |
tree | a6ff524c380e5a3b7ecb88b2fefaf8f2dce67780 /src | |
parent | 0d0acf7d4dfaedce6d849d2db4613ca8a4e9952b (diff) |
baremetal: Add support for HCS08 architectures to SDCC toolchain
This patch adds the HCS08 architectures, provided
by Freescale Semiconductor:
* https://en.wikipedia.org/wiki/Motorola_S08
Change-Id: I0a08c6433041eb8a00cb3705c5e65857188f4830
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/app/qbs-setup-toolchains/sdccprobe.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/app/qbs-setup-toolchains/sdccprobe.cpp b/src/app/qbs-setup-toolchains/sdccprobe.cpp index 9c68d0c0f..a8a27fb96 100644 --- a/src/app/qbs-setup-toolchains/sdccprobe.cpp +++ b/src/app/qbs-setup-toolchains/sdccprobe.cpp @@ -89,13 +89,12 @@ static QByteArray dumpSdccMacros(const QFileInfo &compiler, return p.readAllStandardOutput(); } -static QString dumpSdccArchitecture(const QFileInfo &compiler, - const QString &arch) +static bool supportsSdccArchitecture(const QFileInfo &compiler, QStringView flag) { - const auto targetFlag = QStringLiteral("-m%1").arg(arch); - const auto token = QStringLiteral("__SDCC_%1").arg(arch); + const auto targetFlag = QStringLiteral("-m%1").arg(flag); const auto macros = dumpSdccMacros(compiler, targetFlag); - return macros.contains(token.toLatin1()) ? arch : QString(); + const auto token = QStringLiteral("__SDCC_%1").arg(flag); + return macros.contains(token.toLatin1()); } static std::vector<Profile> createSdccProfileHelper( @@ -107,13 +106,15 @@ static std::vector<Profile> createSdccProfileHelper( std::vector<Profile> profiles; - const char *knownArchs[] = {"mcs51", "stm8"}; + static constexpr struct KnownArch { + QStringView architecture; + QStringView flag; + } knownArchs[] = {{u"mcs51", u"mcs51"}, {u"stm8", u"stm8"}, {u"hcs8", u"hc08"}}; + for (const auto &knownArch : knownArchs) { - const auto actualArch = dumpSdccArchitecture( - compiler, QString::fromLatin1(knownArch)); // Don't create a profile in case the compiler does // not support the proposed architecture. - if (actualArch != QString::fromLatin1(knownArch)) + if (!supportsSdccArchitecture(compiler, knownArch.flag)) continue; QString fullProfileName; @@ -122,18 +123,18 @@ static std::vector<Profile> createSdccProfileHelper( // in auto-detecting mode. if (!info.compilerVersion.isValid()) { fullProfileName = QStringLiteral("sdcc-unknown-%1") - .arg(actualArch); + .arg(knownArch.architecture); } else { const QString version = info.compilerVersion.toString( QLatin1Char('_'), QLatin1Char('_')); fullProfileName = QStringLiteral("sdcc-%1-%2").arg( - version, actualArch); + version, knownArch.architecture); } } else { // Append the detected actual architecture name // to the proposed profile name. fullProfileName = QStringLiteral("%1-%2").arg( - profileName, actualArch); + profileName, knownArch.architecture); } Profile profile(fullProfileName, settings); @@ -141,8 +142,8 @@ static std::vector<Profile> createSdccProfileHelper( compiler.absolutePath()); profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("sdcc")); - if (!actualArch.isEmpty()) - profile.setValue(QStringLiteral("qbs.architecture"), actualArch); + profile.setValue(QStringLiteral("qbs.architecture"), + knownArch.architecture.toString()); qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg( profile.name(), compiler.absoluteFilePath()); |