forked from qt-creator/qt-creator
McuSupport: Give a reason for the toolchain being declared unsupported
Change-Id: I95eb399cbaa199b442ce0d9596477a039dce4f30 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
committed by
Rainer Keller
parent
6326ccfe30
commit
925a8a7a19
@@ -4,6 +4,7 @@
|
||||
#include "mcutargetfactory.h"
|
||||
#include "mcuhelpers.h"
|
||||
#include "mcupackage.h"
|
||||
#include "mcusupportplugin.h"
|
||||
#include "mcusupportversiondetection.h"
|
||||
#include "mcutarget.h"
|
||||
#include "mcutargetdescription.h"
|
||||
@@ -16,11 +17,6 @@
|
||||
|
||||
namespace McuSupport::Internal {
|
||||
|
||||
bool isToolchainDescriptionValid(const McuTargetDescription::Toolchain &t)
|
||||
{
|
||||
return !t.id.isEmpty() && !t.compiler.cmakeVar.isEmpty() && !t.file.cmakeVar.isEmpty();
|
||||
}
|
||||
|
||||
bool isDesktopToolchain(McuToolChainPackage::ToolChainType type)
|
||||
{
|
||||
return type == McuToolChainPackage::ToolChainType::MSVC
|
||||
@@ -80,7 +76,7 @@ QPair<Targets, Packages> McuTargetFactory::createTargets(const McuTargetDescript
|
||||
const McuTarget::Platform platform(
|
||||
{desc.platform.id, desc.platform.name, desc.platform.vendor});
|
||||
|
||||
auto *toolchain = createToolchain(desc.toolchain);
|
||||
auto *toolchain = createToolchain(desc.toolchain, desc.sourceFile);
|
||||
McuPackagePtr toolchainFile{createPackage(desc.toolchain.file)};
|
||||
//Skip target with incorrect toolchain dir or toolchain file.
|
||||
if (!toolchain || !toolchainFile)
|
||||
@@ -146,7 +142,9 @@ McuPackagePtr McuTargetFactory::createPackage(const PackageDescription &pkgDesc)
|
||||
}
|
||||
|
||||
McuToolChainPackage *McuTargetFactory::createToolchain(
|
||||
const McuTargetDescription::Toolchain &toolchain)
|
||||
const McuTargetDescription::Toolchain &toolchain,
|
||||
const Utils::FilePath &sourceFile
|
||||
)
|
||||
{
|
||||
const static QMap<QString, McuToolChainPackage::ToolChainType> toolchainTypeMapping{
|
||||
{"iar", McuToolChainPackage::ToolChainType::IAR},
|
||||
@@ -175,9 +173,36 @@ McuToolChainPackage *McuTargetFactory::createToolchain(
|
||||
compilerDescription.cmakeVar,
|
||||
{},
|
||||
createVersionDetection(compilerDescription.versionDetection)};
|
||||
} else if (!isToolchainDescriptionValid(toolchain))
|
||||
}
|
||||
|
||||
// Validate toolchain and provide a proper error message
|
||||
QString errorMessage;
|
||||
|
||||
if (toolchain.id.isEmpty()) {
|
||||
errorMessage = McuPackage::tr("the toolchain.id JSON entry is empty");
|
||||
} else if (!toolchainTypeMapping.contains(toolchain.id)) {
|
||||
errorMessage = McuPackage::tr("the given toolchain \"%1\" is not supported").arg(toolchain.id);
|
||||
} else if (toolchain.compiler.cmakeVar.isEmpty()) {
|
||||
errorMessage = McuPackage::tr("the toolchain.compiler.cmakeVar JSON entry is empty");
|
||||
} else if (toolchain.file.cmakeVar.isEmpty()) {
|
||||
errorMessage = McuPackage::tr("the toolchain.file.cmakeVar JSON entry is empty");
|
||||
}
|
||||
|
||||
if (!errorMessage.isEmpty()) {
|
||||
toolchainType = McuToolChainPackage::ToolChainType::Unsupported;
|
||||
|
||||
if (toolchain.id.isEmpty()) {
|
||||
printMessage(McuPackage::tr("Toolchain is invalid because %2 in file \"%3\".")
|
||||
.arg(errorMessage).arg(sourceFile.toUserOutput()),
|
||||
true);
|
||||
} else {
|
||||
printMessage(McuPackage::tr("Toolchain description for \"%1\" is invalid because %2 in file \"%3\".")
|
||||
.arg(toolchain.id).arg(errorMessage).arg(sourceFile.toUserOutput()),
|
||||
true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new McuToolChainPackage{settingsHandler,
|
||||
compilerDescription.label,
|
||||
compilerDescription.defaultPath,
|
||||
|
@@ -20,7 +20,7 @@ public:
|
||||
QPair<Targets, Packages> createTargets(const McuTargetDescription &,
|
||||
const McuPackagePtr &qtForMCUsPackage) override;
|
||||
Packages createPackages(const McuTargetDescription &);
|
||||
McuToolChainPackage *createToolchain(const McuTargetDescription::Toolchain &);
|
||||
McuToolChainPackage *createToolchain(const McuTargetDescription::Toolchain &, const Utils::FilePath &sourceFile = Utils::FilePath());
|
||||
McuPackagePtr createPackage(const PackageDescription &);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user