forked from qt-creator/qt-creator
McuSupport: Add toolchain information for desktop kits
To be able to check the validity of a desktop toolchain used in an mcusupport kit with qt platform. Task-number: QTCREATORBUG-26750 Change-Id: Ifc518257844c8994150f3d86eb5512701c38c2b7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Piotr Mućko <piotr.mucko@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <debugger/debuggerkitinformation.h>
|
#include <debugger/debuggerkitinformation.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/toolchain.h>
|
||||||
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <qtsupport/qtversionmanager.h>
|
#include <qtsupport/qtversionmanager.h>
|
||||||
@@ -250,14 +251,27 @@ public:
|
|||||||
auto configMap = cMakeConfigToMap(CMakeConfigurationKitAspect::configuration(k));
|
auto configMap = cMakeConfigToMap(CMakeConfigurationKitAspect::configuration(k));
|
||||||
|
|
||||||
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
|
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
|
||||||
if (mcuTarget->toolChainPackage()->toolchainType() != McuToolChainPackage::ToolChainType::GHS
|
const QList autonomousCompilerDetectionToolchains{
|
||||||
&& mcuTarget->toolChainPackage()->toolchainType()
|
McuToolChainPackage::ToolChainType::GHS,
|
||||||
!= McuToolChainPackage::ToolChainType::GHSArm) {
|
McuToolChainPackage::ToolChainType::GHSArm,
|
||||||
|
};
|
||||||
|
if (!autonomousCompilerDetectionToolchains.contains(
|
||||||
|
mcuTarget->toolChainPackage()->toolchainType())) {
|
||||||
configMap.insert("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}");
|
configMap.insert("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}");
|
||||||
configMap.insert("CMAKE_C_COMPILER", "%{Compiler:Executable:C}");
|
configMap.insert("CMAKE_C_COMPILER", "%{Compiler:Executable:C}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mcuTarget->toolChainPackage()->isDesktopToolchain()) {
|
auto toolchainPackage = mcuTarget->toolChainPackage();
|
||||||
|
if (toolchainPackage->isDesktopToolchain()) {
|
||||||
|
auto cToolchain = toolchainPackage->toolChain(ProjectExplorer::Constants::C_LANGUAGE_ID);
|
||||||
|
auto cxxToolchain = toolchainPackage->toolChain(
|
||||||
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
|
|
||||||
|
configMap.insert("CMAKE_CXX_COMPILER",
|
||||||
|
cxxToolchain->compilerCommand().toString().toLatin1());
|
||||||
|
configMap.insert("CMAKE_C_COMPILER",
|
||||||
|
cToolchain->compilerCommand().toString().toLatin1());
|
||||||
|
} else {
|
||||||
const FilePath cMakeToolchainFile = mcuTarget->toolChainFilePackage()->path();
|
const FilePath cMakeToolchainFile = mcuTarget->toolChainFilePackage()->path();
|
||||||
|
|
||||||
configMap.insert(Legacy::Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE,
|
configMap.insert(Legacy::Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE,
|
||||||
@@ -348,8 +362,7 @@ Kit *newKit(const McuTarget *mcuTarget, const McuPackagePtr &qtForMCUsSdk)
|
|||||||
QString generateKitNameFromTarget(const McuTarget *mcuTarget)
|
QString generateKitNameFromTarget(const McuTarget *mcuTarget)
|
||||||
{
|
{
|
||||||
McuToolChainPackagePtr tcPkg = mcuTarget->toolChainPackage();
|
McuToolChainPackagePtr tcPkg = mcuTarget->toolChainPackage();
|
||||||
const QString compilerName = tcPkg && !tcPkg->isDesktopToolchain()
|
const QString compilerName = tcPkg ? QString::fromLatin1(" (%1)").arg(
|
||||||
? QString::fromLatin1(" (%1)").arg(
|
|
||||||
tcPkg->toolChainName().toUpper())
|
tcPkg->toolChainName().toUpper())
|
||||||
: "";
|
: "";
|
||||||
const QString colorDepth = mcuTarget->colorDepth() != McuTarget::UnspecifiedColorDepth
|
const QString colorDepth = mcuTarget->colorDepth() != McuTarget::UnspecifiedColorDepth
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ bool McuToolChainPackage::isDesktopToolchain() const
|
|||||||
return m_type == ToolChainType::MSVC || m_type == ToolChainType::GCC;
|
return m_type == ToolChainType::MSVC || m_type == ToolChainType::GCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ToolChain *msvcToolChain(Id language)
|
ToolChain *McuToolChainPackage::msvcToolChain(Id language)
|
||||||
{
|
{
|
||||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||||
const Abi abi = t->targetAbi();
|
const Abi abi = t->targetAbi();
|
||||||
@@ -330,7 +330,7 @@ static ToolChain *msvcToolChain(Id language)
|
|||||||
return toolChain;
|
return toolChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ToolChain *gccToolChain(Id language)
|
ToolChain *McuToolChainPackage::gccToolChain(Id language)
|
||||||
{
|
{
|
||||||
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
|
||||||
const Abi abi = t->targetAbi();
|
const Abi abi = t->targetAbi();
|
||||||
@@ -430,6 +430,10 @@ ToolChain *McuToolChainPackage::toolChain(Id language) const
|
|||||||
QString McuToolChainPackage::toolChainName() const
|
QString McuToolChainPackage::toolChainName() const
|
||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
|
case ToolChainType::MSVC:
|
||||||
|
return QLatin1String("msvc");
|
||||||
|
case ToolChainType::GCC:
|
||||||
|
return QLatin1String("gcc");
|
||||||
case ToolChainType::ArmGcc:
|
case ToolChainType::ArmGcc:
|
||||||
return QLatin1String("armgcc");
|
return QLatin1String("armgcc");
|
||||||
case ToolChainType::IAR:
|
case ToolChainType::IAR:
|
||||||
|
|||||||
@@ -140,6 +140,9 @@ public:
|
|||||||
QString toolChainName() const;
|
QString toolChainName() const;
|
||||||
QVariant debuggerId() const;
|
QVariant debuggerId() const;
|
||||||
|
|
||||||
|
static ProjectExplorer::ToolChain *msvcToolChain(Utils::Id language);
|
||||||
|
static ProjectExplorer::ToolChain *gccToolChain(Utils::Id language);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ToolChainType m_type;
|
const ToolChainType m_type;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <baremetal/baremetalconstants.h>
|
#include <baremetal/baremetalconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/toolchainmanager.h>
|
#include <projectexplorer/toolchainmanager.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace McuSupport::Internal {
|
namespace McuSupport::Internal {
|
||||||
@@ -204,31 +206,54 @@ McuToolChainPackagePtr createUnsupportedToolChainPackage(const SettingsHandler::
|
|||||||
McuToolChainPackagePtr createMsvcToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
McuToolChainPackagePtr createMsvcToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
const QStringList &versions)
|
const QStringList &versions)
|
||||||
{
|
{
|
||||||
|
ToolChain *toolChain = McuToolChainPackage::msvcToolChain(
|
||||||
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
|
|
||||||
|
const FilePath detectionPath = FilePath("cl").withExecutableSuffix();
|
||||||
|
const FilePath defaultPath = toolChain ? toolChain->compilerCommand().parentDir() : FilePath();
|
||||||
|
|
||||||
|
const auto versionDetector
|
||||||
|
= new McuPackageExecutableVersionDetector(detectionPath,
|
||||||
|
{"--version"},
|
||||||
|
"\\b(\\d+\\.\\d+)\\.\\d+\\b");
|
||||||
|
|
||||||
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
||||||
{},
|
McuPackage::tr("MSVC Binary directory"),
|
||||||
{},
|
defaultPath,
|
||||||
{},
|
detectionPath,
|
||||||
{},
|
"MsvcToolchain",
|
||||||
McuToolChainPackage::ToolChainType::MSVC,
|
McuToolChainPackage::ToolChainType::MSVC,
|
||||||
versions,
|
versions,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
nullptr)};
|
versionDetector)};
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackagePtr createGccToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
McuToolChainPackagePtr createGccToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
const QStringList &versions)
|
const QStringList &versions)
|
||||||
{
|
{
|
||||||
|
ToolChain *toolChain = McuToolChainPackage::gccToolChain(
|
||||||
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
|
|
||||||
|
const FilePath detectionPath = FilePath("bin/g++").withExecutableSuffix();
|
||||||
|
const FilePath defaultPath = toolChain ? toolChain->compilerCommand().parentDir().parentDir()
|
||||||
|
: FilePath();
|
||||||
|
|
||||||
|
const auto versionDetector
|
||||||
|
= new McuPackageExecutableVersionDetector(detectionPath,
|
||||||
|
{"--version"},
|
||||||
|
"\\b(\\d+\\.\\d+\\.\\d+)\\b");
|
||||||
|
|
||||||
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
return McuToolChainPackagePtr{new McuToolChainPackage(settingsHandler,
|
||||||
{},
|
McuPackage::tr("GCC Toolchain"),
|
||||||
{},
|
defaultPath,
|
||||||
{},
|
detectionPath,
|
||||||
{},
|
"GnuToolchain",
|
||||||
McuToolChainPackage::ToolChainType::GCC,
|
McuToolChainPackage::ToolChainType::GCC,
|
||||||
versions,
|
versions,
|
||||||
|
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE,
|
||||||
{},
|
{},
|
||||||
{},
|
versionDetector)};
|
||||||
nullptr)};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
McuToolChainPackagePtr createArmGccToolchainPackage(const SettingsHandler::Ptr &settingsHandler,
|
McuToolChainPackagePtr createArmGccToolchainPackage(const SettingsHandler::Ptr &settingsHandler,
|
||||||
@@ -250,7 +275,7 @@ McuToolChainPackagePtr createArmGccToolchainPackage(const SettingsHandler::Ptr &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::FilePath detectionPath = FilePath("bin/arm-none-eabi-g++").withExecutableSuffix();
|
const FilePath detectionPath = FilePath("bin/arm-none-eabi-g++").withExecutableSuffix();
|
||||||
const auto versionDetector = new McuPackageExecutableVersionDetector(detectionPath,
|
const auto versionDetector = new McuPackageExecutableVersionDetector(detectionPath,
|
||||||
{"--version"},
|
{"--version"},
|
||||||
R"(\b(\d+\.\d+\.\d+)\b)");
|
R"(\b(\d+\.\d+\.\d+)\b)");
|
||||||
@@ -511,8 +536,8 @@ static McuAbstractTargetFactory::Ptr createFactory(bool isLegacy,
|
|||||||
|
|
||||||
const FilePath toolchainFilePrefix = qtMcuSdkPath
|
const FilePath toolchainFilePrefix = qtMcuSdkPath
|
||||||
/ Legacy::Constants::QUL_TOOLCHAIN_CMAKE_DIR;
|
/ Legacy::Constants::QUL_TOOLCHAIN_CMAKE_DIR;
|
||||||
static const QHash<QString, McuPackagePtr> toolchainFiles = {
|
static const QHash<QString, McuPackagePtr> toolchainFiles
|
||||||
{{"armgcc"},
|
= {{{"armgcc"},
|
||||||
McuPackagePtr{new McuPackage{settingsHandler,
|
McuPackagePtr{new McuPackage{settingsHandler,
|
||||||
{},
|
{},
|
||||||
toolchainFilePrefix / "armgcc.cmake",
|
toolchainFilePrefix / "armgcc.cmake",
|
||||||
@@ -544,7 +569,8 @@ static McuAbstractTargetFactory::Ptr createFactory(bool isLegacy,
|
|||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
Legacy::Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE,
|
Legacy::Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE,
|
||||||
{}}}},
|
{}}}}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: the vendor name (the key of the hash) is case-sensitive. It has to match the "platformVendor" key in the
|
// Note: the vendor name (the key of the hash) is case-sensitive. It has to match the "platformVendor" key in the
|
||||||
@@ -595,12 +621,12 @@ McuSdkRepository targetsFromDescriptions(const QList<McuTargetDescription> &desc
|
|||||||
return McuSdkRepository{mcuTargets, mcuPackages};
|
return McuSdkRepository{mcuTargets, mcuPackages};
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath kitsPath(const Utils::FilePath &qtMcuSdkPath)
|
FilePath kitsPath(const FilePath &qtMcuSdkPath)
|
||||||
{
|
{
|
||||||
return qtMcuSdkPath / "kits/";
|
return qtMcuSdkPath / "kits/";
|
||||||
}
|
}
|
||||||
|
|
||||||
static QFileInfoList targetDescriptionFiles(const Utils::FilePath &dir)
|
static QFileInfoList targetDescriptionFiles(const FilePath &dir)
|
||||||
{
|
{
|
||||||
const QDir kitsDir(kitsPath(dir).toString(), "*.json");
|
const QDir kitsDir(kitsPath(dir).toString(), "*.json");
|
||||||
return kitsDir.entryInfoList();
|
return kitsDir.entryInfoList();
|
||||||
@@ -721,7 +747,7 @@ static const QString legacySupportVersionFor(const QString &sdkVersion)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
bool checkDeprecatedSdkError(const FilePath &qulDir, QString &message)
|
||||||
{
|
{
|
||||||
const McuPackagePathVersionDetector versionDetector(R"((?<=\bQtMCUs.)(\d+\.\d+))");
|
const McuPackagePathVersionDetector versionDetector(R"((?<=\bQtMCUs.)(\d+\.\d+))");
|
||||||
const QString sdkDetectedVersion = versionDetector.parseVersion(qulDir);
|
const QString sdkDetectedVersion = versionDetector.parseVersion(qulDir);
|
||||||
@@ -740,7 +766,7 @@ bool checkDeprecatedSdkError(const Utils::FilePath &qulDir, QString &message)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuSdkRepository targetsAndPackages(const Utils::FilePath &qtForMCUSdkPath,
|
McuSdkRepository targetsAndPackages(const FilePath &qtForMCUSdkPath,
|
||||||
const SettingsHandler::Ptr &settingsHandler)
|
const SettingsHandler::Ptr &settingsHandler)
|
||||||
{
|
{
|
||||||
QList<McuTargetDescription> descriptions;
|
QList<McuTargetDescription> descriptions;
|
||||||
@@ -752,7 +778,7 @@ McuSdkRepository targetsAndPackages(const Utils::FilePath &qtForMCUSdkPath,
|
|||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
continue;
|
continue;
|
||||||
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
const McuTargetDescription desc = parseDescriptionJson(file.readAll());
|
||||||
const auto pth = Utils::FilePath::fromString(fileInfo.filePath());
|
const auto pth = FilePath::fromString(fileInfo.filePath());
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const int compatVersion = desc.compatVersion.toInt(&ok);
|
const int compatVersion = desc.compatVersion.toInt(&ok);
|
||||||
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {
|
if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ QPair<Targets, Packages> McuTargetFactory::createTargets(const McuTargetDescript
|
|||||||
for (int colorDepth : desc.platform.colorDepths) {
|
for (int colorDepth : desc.platform.colorDepths) {
|
||||||
Packages required3rdPartyPkgs;
|
Packages required3rdPartyPkgs;
|
||||||
// Desktop toolchains don't need any additional settings
|
// Desktop toolchains don't need any additional settings
|
||||||
if (toolchainPackage && !toolchainPackage->isDesktopToolchain()
|
if (toolchainPackage
|
||||||
&& toolchainPackage->toolchainType()
|
&& toolchainPackage->toolchainType()
|
||||||
!= McuToolChainPackage::ToolChainType::Unsupported) {
|
!= McuToolChainPackage::ToolChainType::Unsupported) {
|
||||||
required3rdPartyPkgs.insert(toolchainPackage);
|
required3rdPartyPkgs.insert(toolchainPackage);
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ FilePath SettingsHandler::getPath(const QString &settingsKey,
|
|||||||
QSettings::Scope scope,
|
QSettings::Scope scope,
|
||||||
const Utils::FilePath &defaultPath) const
|
const Utils::FilePath &defaultPath) const
|
||||||
{
|
{
|
||||||
|
//Use the default value for empty keys
|
||||||
|
if (settingsKey.isEmpty())
|
||||||
|
return defaultPath;
|
||||||
|
|
||||||
return packagePathFromSettings(settingsKey, *Core::ICore::settings(scope), defaultPath);
|
return packagePathFromSettings(settingsKey, *Core::ICore::settings(scope), defaultPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user