forked from qt-creator/qt-creator
Make McuToolChainPackage::Type an enum class
And make more use of switch statements without a default case, so each type is handled explicitly. (Ok, there is a default, but that is Q_UNREACHABLE). Change-Id: I30ccc447e55a5aeebebe1a9879ea3136545f5e68 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <piotr.mucko@qt.io>
This commit is contained in:
committed by
piotr.mucko
parent
32f8ed7b66
commit
34345f8b7e
@@ -302,7 +302,7 @@ McuToolChainPackage::Type McuToolChainPackage::type() const
|
|||||||
|
|
||||||
bool McuToolChainPackage::isDesktopToolchain() const
|
bool McuToolChainPackage::isDesktopToolchain() const
|
||||||
{
|
{
|
||||||
return m_type == TypeMSVC || m_type == TypeGCC;
|
return m_type == Type::MSVC || m_type == Type::GCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -122,15 +122,15 @@ private:
|
|||||||
class McuToolChainPackage : public McuPackage
|
class McuToolChainPackage : public McuPackage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum class Type {
|
||||||
TypeArmGcc,
|
IAR,
|
||||||
TypeIAR,
|
KEIL,
|
||||||
TypeKEIL,
|
MSVC,
|
||||||
TypeGHS,
|
GCC,
|
||||||
TypeMSVC,
|
ArmGcc,
|
||||||
TypeGCC,
|
GHS,
|
||||||
TypeGHSArm,
|
GHSArm,
|
||||||
TypeUnsupported
|
Unsupported
|
||||||
};
|
};
|
||||||
|
|
||||||
McuToolChainPackage(const QString &label,
|
McuToolChainPackage(const QString &label,
|
||||||
|
@@ -178,35 +178,42 @@ static ToolChain *iarToolChain(const FilePath &path, Id language)
|
|||||||
|
|
||||||
ToolChain *McuToolChainPackage::toolChain(Id language) const
|
ToolChain *McuToolChainPackage::toolChain(Id language) const
|
||||||
{
|
{
|
||||||
ToolChain *tc = nullptr;
|
switch (m_type) {
|
||||||
if (m_type == TypeMSVC)
|
case Type::MSVC:
|
||||||
tc = msvcToolChain(language);
|
return msvcToolChain(language);
|
||||||
else if (m_type == TypeGCC)
|
case Type::GCC:
|
||||||
tc = gccToolChain(language);
|
return gccToolChain(language);
|
||||||
else if (m_type == TypeIAR) {
|
case Type::IAR: {
|
||||||
const FilePath compiler = path().pathAppended("/bin/iccarm").withExecutableSuffix();
|
const FilePath compiler = path().pathAppended("/bin/iccarm").withExecutableSuffix();
|
||||||
tc = iarToolChain(compiler, language);
|
return iarToolChain(compiler, language);
|
||||||
}
|
}
|
||||||
else {
|
case Type::ArmGcc:
|
||||||
|
case Type::KEIL:
|
||||||
|
case Type::GHS:
|
||||||
|
case Type::GHSArm:
|
||||||
|
case Type::Unsupported: {
|
||||||
const QLatin1String compilerName(
|
const QLatin1String compilerName(
|
||||||
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
|
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
|
||||||
const QString comp = QLatin1String(m_type == TypeArmGcc ? "/bin/arm-none-eabi-%1" : "/bar/foo-keil-%1")
|
const QString comp = QLatin1String(m_type == Type::ArmGcc ? "/bin/arm-none-eabi-%1"
|
||||||
|
: "/bar/foo-keil-%1")
|
||||||
.arg(compilerName);
|
.arg(compilerName);
|
||||||
const FilePath compiler = path().pathAppended(comp).withExecutableSuffix();
|
const FilePath compiler = path().pathAppended(comp).withExecutableSuffix();
|
||||||
|
|
||||||
tc = armGccToolChain(compiler, language);
|
return armGccToolChain(compiler, language);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
}
|
}
|
||||||
return tc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString McuToolChainPackage::toolChainName() const
|
QString McuToolChainPackage::toolChainName() const
|
||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case TypeArmGcc: return QLatin1String("armgcc");
|
case Type::ArmGcc: return QLatin1String("armgcc");
|
||||||
case TypeIAR: return QLatin1String("iar");
|
case Type::IAR: return QLatin1String("iar");
|
||||||
case TypeKEIL: return QLatin1String("keil");
|
case Type::KEIL: return QLatin1String("keil");
|
||||||
case TypeGHS: return QLatin1String("ghs");
|
case Type::GHS: return QLatin1String("ghs");
|
||||||
case TypeGHSArm: return QLatin1String("ghs-arm");
|
case Type::GHSArm: return QLatin1String("ghs-arm");
|
||||||
default: return QLatin1String("unsupported");
|
default: return QLatin1String("unsupported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,37 +231,38 @@ QVariant McuToolChainPackage::debuggerId() const
|
|||||||
DebuggerEngineType engineType;
|
DebuggerEngineType engineType;
|
||||||
|
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case TypeArmGcc: {
|
case Type::ArmGcc: {
|
||||||
sub = QString::fromLatin1("bin/arm-none-eabi-gdb-py");
|
sub = QString::fromLatin1("bin/arm-none-eabi-gdb-py");
|
||||||
displayName = McuPackage::tr("Arm GDB at %1");
|
displayName = McuPackage::tr("Arm GDB at %1");
|
||||||
engineType = Debugger::GdbEngineType;
|
engineType = Debugger::GdbEngineType;
|
||||||
break; }
|
break;
|
||||||
case TypeIAR: {
|
}
|
||||||
|
case Type::IAR: {
|
||||||
sub = QString::fromLatin1("../common/bin/CSpyBat");
|
sub = QString::fromLatin1("../common/bin/CSpyBat");
|
||||||
displayName = QLatin1String("CSpy");
|
displayName = QLatin1String("CSpy");
|
||||||
engineType = Debugger::NoEngineType; // support for IAR missing
|
engineType = Debugger::NoEngineType; // support for IAR missing
|
||||||
break; }
|
break;
|
||||||
case TypeKEIL: {
|
}
|
||||||
|
case Type::KEIL: {
|
||||||
sub = QString::fromLatin1("UV4/UV4");
|
sub = QString::fromLatin1("UV4/UV4");
|
||||||
displayName = QLatin1String("KEIL uVision Debugger");
|
displayName = QLatin1String("KEIL uVision Debugger");
|
||||||
engineType = Debugger::UvscEngineType;
|
engineType = Debugger::UvscEngineType;
|
||||||
break; }
|
break;
|
||||||
default: return QVariant();
|
}
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilePath command = path().pathAppended(sub).withExecutableSuffix();
|
const FilePath command = path().pathAppended(sub).withExecutableSuffix();
|
||||||
const DebuggerItem *debugger = DebuggerItemManager::findByCommand(command);
|
if (const DebuggerItem *debugger = DebuggerItemManager::findByCommand(command)) {
|
||||||
QVariant debuggerId;
|
return debugger->id();
|
||||||
if (!debugger) {
|
}
|
||||||
|
|
||||||
DebuggerItem newDebugger;
|
DebuggerItem newDebugger;
|
||||||
newDebugger.setCommand(command);
|
newDebugger.setCommand(command);
|
||||||
newDebugger.setUnexpandedDisplayName(displayName.arg(command.toUserOutput()));
|
newDebugger.setUnexpandedDisplayName(displayName.arg(command.toUserOutput()));
|
||||||
newDebugger.setEngineType(engineType);
|
newDebugger.setEngineType(engineType);
|
||||||
debuggerId = DebuggerItemManager::registerDebugger(newDebugger);
|
return DebuggerItemManager::registerDebugger(newDebugger);
|
||||||
} else {
|
|
||||||
debuggerId = debugger->id();
|
|
||||||
}
|
|
||||||
return debuggerId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
||||||
@@ -458,34 +466,61 @@ static void setKitProperties(const QString &kitName, Kit *k, const McuTarget *mc
|
|||||||
|
|
||||||
static void setKitToolchains(Kit *k, const McuToolChainPackage *tcPackage)
|
static void setKitToolchains(Kit *k, const McuToolChainPackage *tcPackage)
|
||||||
{
|
{
|
||||||
// No Green Hills toolchain, because support for it is missing.
|
switch (tcPackage->type()) {
|
||||||
if (tcPackage->type() == McuToolChainPackage::TypeUnsupported
|
case McuToolChainPackage::Type::Unsupported:
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeGHS
|
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeGHSArm)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
|
case McuToolChainPackage::Type::GHS:
|
||||||
|
case McuToolChainPackage::Type::GHSArm:
|
||||||
|
return; // No Green Hills toolchain, because support for it is missing.
|
||||||
|
|
||||||
|
case McuToolChainPackage::Type::IAR:
|
||||||
|
case McuToolChainPackage::Type::KEIL:
|
||||||
|
case McuToolChainPackage::Type::MSVC:
|
||||||
|
case McuToolChainPackage::Type::GCC:
|
||||||
|
case McuToolChainPackage::Type::ArmGcc:
|
||||||
|
ToolChainKitAspect::setToolChain(k,
|
||||||
|
tcPackage->toolChain(
|
||||||
ProjectExplorer::Constants::C_LANGUAGE_ID));
|
ProjectExplorer::Constants::C_LANGUAGE_ID));
|
||||||
ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
|
ToolChainKitAspect::setToolChain(k,
|
||||||
|
tcPackage->toolChain(
|
||||||
ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setKitDebugger(Kit *k, const McuToolChainPackage *tcPackage)
|
static void setKitDebugger(Kit *k, const McuToolChainPackage *tcPackage)
|
||||||
{
|
{
|
||||||
|
if (tcPackage->isDesktopToolchain()) {
|
||||||
// Qt Creator seems to be smart enough to deduce the right Kit debugger from the ToolChain
|
// Qt Creator seems to be smart enough to deduce the right Kit debugger from the ToolChain
|
||||||
// We rely on that at least in the Desktop case.
|
|
||||||
if (tcPackage->isDesktopToolchain()
|
|
||||||
// No Green Hills and IAR debugger, because support for it is missing.
|
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeUnsupported
|
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeGHS
|
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeGHSArm
|
|
||||||
|| tcPackage->type() == McuToolChainPackage::TypeIAR)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (tcPackage->type()) {
|
||||||
|
case McuToolChainPackage::Type::Unsupported:
|
||||||
|
case McuToolChainPackage::Type::GHS:
|
||||||
|
case McuToolChainPackage::Type::GHSArm:
|
||||||
|
case McuToolChainPackage::Type::IAR:
|
||||||
|
return; // No Green Hills and IAR debugger, because support for it is missing.
|
||||||
|
|
||||||
|
case McuToolChainPackage::Type::KEIL:
|
||||||
|
case McuToolChainPackage::Type::MSVC:
|
||||||
|
case McuToolChainPackage::Type::GCC:
|
||||||
|
case McuToolChainPackage::Type::ArmGcc: {
|
||||||
const QVariant debuggerId = tcPackage->debuggerId();
|
const QVariant debuggerId = tcPackage->debuggerId();
|
||||||
if (debuggerId.isValid())
|
if (debuggerId.isValid()) {
|
||||||
Debugger::DebuggerKitAspect::setDebugger(k, debuggerId);
|
Debugger::DebuggerKitAspect::setDebugger(k, debuggerId);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void setKitDevice(Kit *k, const McuTarget* mcuTarget)
|
static void setKitDevice(Kit *k, const McuTarget* mcuTarget)
|
||||||
{
|
{
|
||||||
@@ -596,8 +631,8 @@ static void setKitCMakeOptions(Kit *k, const McuTarget* mcuTarget, const FilePat
|
|||||||
|
|
||||||
CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
|
CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
|
||||||
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
|
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
|
||||||
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeGHS &&
|
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHS &&
|
||||||
mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeGHSArm) {
|
mcuTarget->toolChainPackage()->type() != McuToolChainPackage::Type::GHSArm) {
|
||||||
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
|
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
|
||||||
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
||||||
}
|
}
|
||||||
@@ -638,7 +673,7 @@ static void setKitCMakeOptions(Kit *k, const McuTarget* mcuTarget, const FilePat
|
|||||||
|
|
||||||
if (HostOsInfo::isWindowsHost()) {
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
auto type = mcuTarget->toolChainPackage()->type();
|
auto type = mcuTarget->toolChainPackage()->type();
|
||||||
if (type == McuToolChainPackage::TypeGHS || type == McuToolChainPackage::TypeGHSArm) {
|
if (type == McuToolChainPackage::Type::GHS || type == McuToolChainPackage::Type::GHSArm) {
|
||||||
// See https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565802&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565802
|
// See https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565802&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565802
|
||||||
// and https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565803&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565803
|
// and https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565803&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565803
|
||||||
CMakeGeneratorKitAspect::setGenerator(k, "NMake Makefiles JOM");
|
CMakeGeneratorKitAspect::setGenerator(k, "NMake Makefiles JOM");
|
||||||
|
@@ -74,17 +74,17 @@ McuPackage *createQtForMCUsPackage()
|
|||||||
|
|
||||||
static McuToolChainPackage *createMsvcToolChainPackage()
|
static McuToolChainPackage *createMsvcToolChainPackage()
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeMSVC);
|
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::Type::MSVC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createGccToolChainPackage()
|
static McuToolChainPackage *createGccToolChainPackage()
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeGCC);
|
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::Type::GCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createUnsupportedToolChainPackage()
|
static McuToolChainPackage *createUnsupportedToolChainPackage()
|
||||||
{
|
{
|
||||||
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::TypeUnsupported);
|
return new McuToolChainPackage({}, {}, {}, {}, McuToolChainPackage::Type::Unsupported);
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createArmGccPackage()
|
static McuToolChainPackage *createArmGccPackage()
|
||||||
@@ -116,7 +116,7 @@ static McuToolChainPackage *createArmGccPackage()
|
|||||||
defaultPath,
|
defaultPath,
|
||||||
detectionPath,
|
detectionPath,
|
||||||
"GNUArmEmbeddedToolchain", // settingsKey
|
"GNUArmEmbeddedToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeArmGcc,
|
McuToolChainPackage::Type::ArmGcc,
|
||||||
envVar,
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ static McuToolChainPackage *createGhsToolchainPackage()
|
|||||||
Utils::HostOsInfo::withExecutableSuffix(
|
Utils::HostOsInfo::withExecutableSuffix(
|
||||||
"ccv850"), // detectionPath
|
"ccv850"), // detectionPath
|
||||||
"GHSToolchain", // settingsKey
|
"GHSToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeGHS,
|
McuToolChainPackage::Type::GHS,
|
||||||
envVar,
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ static McuToolChainPackage *createGhsArmToolchainPackage()
|
|||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("cxarm"), // detectionPath
|
Utils::HostOsInfo::withExecutableSuffix("cxarm"), // detectionPath
|
||||||
"GHSArmToolchain", // settingsKey
|
"GHSArmToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeGHSArm,
|
McuToolChainPackage::Type::GHSArm,
|
||||||
envVar,
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ static McuToolChainPackage *createIarToolChainPackage()
|
|||||||
defaultPath,
|
defaultPath,
|
||||||
detectionPath,
|
detectionPath,
|
||||||
"IARToolchain", // settings key
|
"IARToolchain", // settings key
|
||||||
McuToolChainPackage::TypeIAR,
|
McuToolChainPackage::Type::IAR,
|
||||||
envVar,
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
}
|
}
|
||||||
@@ -555,7 +555,7 @@ protected:
|
|||||||
// Desktop toolchains don't need any additional settings
|
// Desktop toolchains don't need any additional settings
|
||||||
if (tcPkg
|
if (tcPkg
|
||||||
&& !tcPkg->isDesktopToolchain()
|
&& !tcPkg->isDesktopToolchain()
|
||||||
&& tcPkg->type() != McuToolChainPackage::TypeUnsupported)
|
&& tcPkg->type() != McuToolChainPackage::Type::Unsupported)
|
||||||
required3rdPartyPkgs.append(tcPkg);
|
required3rdPartyPkgs.append(tcPkg);
|
||||||
|
|
||||||
// Add setting specific to platform IDE
|
// Add setting specific to platform IDE
|
||||||
|
Reference in New Issue
Block a user