forked from qt-creator/qt-creator
BareMetal: Add STM8 architecture for SDCC toolchain
Previous implementation of SDCC toolchain based on an assumption, that the default target architecture always is MCS51. But, the SDCC compiler support multiple architectures: * http://sdcc.sourceforge.net/ Since we have the new STM8 architecture in the Abi::Architecture enumeration, it is makes sense to add support for this architecture and to the SDCC compiler. Right now, the SDCC compiler will be auto-detected as two instances: * with mcs51 architecture * with stm8 architecture by analogy as it does for the MSVC compiler for multiple x86, x86_64 and so forth architectures. In case the SDCC compiler is manually added, the user can choose a desired architecture (mcs51 or stm8) from the combo-box. Change-Id: I9b7d34f9064ea34c94dab7f1a7e3b64b190f7cb0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -72,6 +72,8 @@ static QString compilerTargetFlag(const Abi &abi)
|
|||||||
switch (abi.architecture()) {
|
switch (abi.architecture()) {
|
||||||
case Abi::Architecture::Mcs51Architecture:
|
case Abi::Architecture::Mcs51Architecture:
|
||||||
return QString("-mmcs51");
|
return QString("-mmcs51");
|
||||||
|
case Abi::Architecture::Stm8Architecture:
|
||||||
|
return QString("-mstm8");
|
||||||
default:
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -169,6 +171,8 @@ static Abi::Architecture guessArchitecture(const Macros ¯os)
|
|||||||
for (const Macro ¯o : macros) {
|
for (const Macro ¯o : macros) {
|
||||||
if (macro.key == "__SDCC_mcs51")
|
if (macro.key == "__SDCC_mcs51")
|
||||||
return Abi::Architecture::Mcs51Architecture;
|
return Abi::Architecture::Mcs51Architecture;
|
||||||
|
if (macro.key == "__SDCC_stm8")
|
||||||
|
return Abi::Architecture::Stm8Architecture;
|
||||||
}
|
}
|
||||||
return Abi::Architecture::UnknownArchitecture;
|
return Abi::Architecture::UnknownArchitecture;
|
||||||
}
|
}
|
||||||
@@ -443,21 +447,41 @@ QList<ToolChain *> SdccToolChainFactory::autoDetectToolchain(
|
|||||||
const Candidate &candidate, Core::Id language) const
|
const Candidate &candidate, Core::Id language) const
|
||||||
{
|
{
|
||||||
const auto env = Environment::systemEnvironment();
|
const auto env = Environment::systemEnvironment();
|
||||||
const Macros macros = dumpPredefinedMacros(candidate.compilerPath, env.toStringList(), {});
|
|
||||||
if (macros.isEmpty())
|
|
||||||
return {};
|
|
||||||
const Abi abi = guessAbi(macros);
|
|
||||||
|
|
||||||
const auto tc = new SdccToolChain;
|
// Table of supported ABI's by SDCC compiler.
|
||||||
tc->setDetection(ToolChain::AutoDetection);
|
const Abi knownAbis[] = {
|
||||||
tc->setLanguage(language);
|
{Abi::Mcs51Architecture},
|
||||||
tc->setCompilerCommand(candidate.compilerPath);
|
{Abi::Stm8Architecture}
|
||||||
tc->setTargetAbi(abi);
|
};
|
||||||
tc->setDisplayName(buildDisplayName(abi.architecture(), language, candidate.compilerVersion));
|
|
||||||
|
|
||||||
const auto languageVersion = ToolChain::languageVersion(language, macros);
|
QList<ToolChain *> tcs;
|
||||||
tc->predefinedMacrosCache()->insert({}, {macros, languageVersion});
|
|
||||||
return {tc};
|
// Probe each ABI from the table, because the SDCC compiler
|
||||||
|
// can be compiled with or without the specified architecture.
|
||||||
|
for (const auto &knownAbi : knownAbis) {
|
||||||
|
const Macros macros = dumpPredefinedMacros(candidate.compilerPath,
|
||||||
|
env.toStringList(), knownAbi);
|
||||||
|
if (macros.isEmpty())
|
||||||
|
continue;
|
||||||
|
const Abi abi = guessAbi(macros);
|
||||||
|
if (knownAbi.architecture() != abi.architecture())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const auto tc = new SdccToolChain;
|
||||||
|
tc->setDetection(ToolChain::AutoDetection);
|
||||||
|
tc->setLanguage(language);
|
||||||
|
tc->setCompilerCommand(candidate.compilerPath);
|
||||||
|
tc->setTargetAbi(abi);
|
||||||
|
tc->setDisplayName(buildDisplayName(abi.architecture(), language,
|
||||||
|
candidate.compilerVersion));
|
||||||
|
|
||||||
|
const auto languageVersion = ToolChain::languageVersion(language, macros);
|
||||||
|
tc->predefinedMacrosCache()->insert({}, {macros, languageVersion});
|
||||||
|
|
||||||
|
tcs.push_back(tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SdccToolChainConfigWidget
|
// SdccToolChainConfigWidget
|
||||||
|
Reference in New Issue
Block a user