Merge remote-tracking branch 'origin/4.12'

Change-Id: Ie35e9959693b6f6f78509eea5b259d6493ef87f2
This commit is contained in:
Eike Ziller
2020-04-17 08:09:55 +02:00
55 changed files with 7620 additions and 5291 deletions

View File

@@ -27,18 +27,21 @@
#include "mcusupportoptions.h"
#include "mcusupportsdk.h"
#include <cmakeprojectmanager/cmaketoolmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <cmakeprojectmanager/cmakekitinformation.h>
#include <debugger/debuggeritem.h>
#include <debugger/debuggeritemmanager.h>
#include <debugger/debuggerkitinformation.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
@@ -182,7 +185,7 @@ void McuPackage::updateStatus()
const Utils::FilePath detectionPath = Utils::FilePath::fromString(
m_fileChooser->filePath().toString() + "/" + m_detectionPath);
const QString displayDetectionPath = Utils::FilePath::fromString(m_detectionPath).toUserOutput();
const bool validPackage = detectionPath.exists();
const bool validPackage = m_detectionPath.isEmpty() || detectionPath.exists();
m_status = validPath ? (validPackage ? ValidPackage : ValidPathInvalidPackage) : InvalidPath;
@@ -192,7 +195,9 @@ void McuPackage::updateStatus()
QString statusText;
switch (m_status) {
case ValidPackage:
statusText = tr("Path is valid, \"%1\" was found.").arg(displayDetectionPath);
statusText = m_detectionPath.isEmpty()
? "Path exists." // TODO tr()
: tr("Path is valid, \"%1\" was found.").arg(displayDetectionPath);
break;
case ValidPathInvalidPackage:
statusText = tr("Path exists, but does not contain \"%1\".").arg(displayDetectionPath);
@@ -217,6 +222,22 @@ McuToolChainPackage::Type McuToolChainPackage::type() const
return m_type;
}
static ProjectExplorer::ToolChain *desktopToolChain(Core::Id language)
{
using namespace ProjectExplorer;
ToolChain *toolChain = ToolChainManager::toolChain([language](const ToolChain *t) {
const Abi abi = t->targetAbi();
return (abi.os() != Abi::WindowsOS
|| (abi.osFlavor() == Abi::WindowsMsvc2017Flavor
|| abi.osFlavor() == Abi::WindowsMsvc2019Flavor))
&& abi.architecture() == Abi::X86Architecture
&& abi.wordWidth() == 64
&& t->language() == language;
});
return toolChain;
}
static ProjectExplorer::ToolChain* armGccToolChain(const Utils::FilePath &path, Core::Id language)
{
using namespace ProjectExplorer;
@@ -245,24 +266,30 @@ static ProjectExplorer::ToolChain* armGccToolChain(const Utils::FilePath &path,
ProjectExplorer::ToolChain *McuToolChainPackage::toolChain(Core::Id language) const
{
const QLatin1String compilerName(
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(
Utils::HostOsInfo::withExecutableSuffix(
path() + (
m_type == TypeArmGcc
? "/bin/arm-none-eabi-%1" : m_type == TypeIAR
? "/foo/bar-iar-%1" : "/bar/foo-keil-%1")).arg(compilerName));
ProjectExplorer::ToolChain *tc = nullptr;
if (m_type == TypeDesktop) {
tc = desktopToolChain(language);
} else {
const QLatin1String compilerName(
language == ProjectExplorer::Constants::C_LANGUAGE_ID ? "gcc" : "g++");
const Utils::FilePath compiler = Utils::FilePath::fromUserInput(
Utils::HostOsInfo::withExecutableSuffix(
path() + (
m_type == TypeArmGcc
? "/bin/arm-none-eabi-%1" : m_type == TypeIAR
? "/foo/bar-iar-%1" : "/bar/foo-keil-%1")).arg(compilerName));
ProjectExplorer::ToolChain *tc = armGccToolChain(compiler, language);
tc = armGccToolChain(compiler, language);
}
return tc;
}
QString McuToolChainPackage::cmakeToolChainFileName() const
{
return QLatin1String(m_type == TypeArmGcc
? "armgcc.cmake" : m_type == McuToolChainPackage::TypeIAR
? "iar.cmake" : "keil.cmake");
? "armgcc" : m_type == McuToolChainPackage::TypeIAR
? "iar" : m_type == McuToolChainPackage::TypeKEIL
? "keil" : "ghs") + QLatin1String(".cmake");
}
QVariant McuToolChainPackage::debuggerId() const
@@ -429,11 +456,6 @@ Utils::FilePath McuSupportOptions::qulDirFromSettings()
packagePathFromSettings(Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK));
}
static bool mcuTargetIsDesktop(const McuTarget* mcuTarget)
{
return mcuTarget->qulPlatform() == "Qt";
}
static Utils::FilePath jomExecutablePath()
{
return Utils::HostOsInfo::isWindowsHost() ?
@@ -453,21 +475,23 @@ static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k,
McuSupportOptions::supportedQulVersion().toString());
k->setAutoDetected(true);
k->makeSticky();
if (mcuTargetIsDesktop(mcuTarget)) {
if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
k->setDeviceTypeForIcon(Constants::DEVICE_TYPE);
} else {
QSet<Core::Id> irrelevant = {
SysRootKitAspect::id(),
"QtSupport.QtInformation" // QtKitAspect::id()
};
if (jomExecutablePath().exists()) // TODO: add id() getter to CMakeGeneratorKitAspect
irrelevant.insert("CMake.GeneratorKitInformation");
k->setIrrelevantAspects(irrelevant);
}
QSet<Core::Id> irrelevant = {
SysRootKitAspect::id(),
QtSupport::QtKitAspect::id()
};
if (jomExecutablePath().exists()) // TODO: add id() getter to CMakeGeneratorKitAspect
irrelevant.insert("CMake.GeneratorKitInformation");
k->setIrrelevantAspects(irrelevant);
}
static void setKitToolchains(ProjectExplorer::Kit *k, const McuToolChainPackage *tcPackage)
{
// No Green Hills toolchain, because support for it is missing.
if (tcPackage->type() == McuToolChainPackage::TypeGHS)
return;
ProjectExplorer::ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
ProjectExplorer::Constants::C_LANGUAGE_ID));
ProjectExplorer::ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
@@ -476,11 +500,22 @@ static void setKitToolchains(ProjectExplorer::Kit *k, const McuToolChainPackage
static void setKitDebugger(ProjectExplorer::Kit *k, const McuToolChainPackage *tcPackage)
{
// 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->type() == McuToolChainPackage::TypeDesktop
// No Green Hills debugger, because support for it is missing.
|| tcPackage->type() == McuToolChainPackage::TypeGHS)
return;
Debugger::DebuggerKitAspect::setDebugger(k, tcPackage->debuggerId());
}
static void setKitDevice(ProjectExplorer::Kit *k)
static void setKitDevice(ProjectExplorer::Kit *k, const McuTarget* mcuTarget)
{
// "Device Type" Desktop is the default. We use that for the Qt for MCUs Desktop Kit
if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop)
return;
ProjectExplorer::DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
}
@@ -492,6 +527,13 @@ static void setKitEnvironment(ProjectExplorer::Kit *k, const McuTarget* mcuTarge
Utils::EnvironmentItems changes;
QStringList pathAdditions;
// The Desktop version depends on the Qt shared libs in Qul_DIR/bin.
// If CMake's fileApi is avaialble, we can rely on the "Add library search path to PATH"
// feature of the run configuration. Otherwise, we just prepend the path, here.
if (mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop
&& !CMakeProjectManager::CMakeToolManager::defaultCMakeTool()->hasFileApi())
pathAdditions.append(QDir::toNativeSeparators(qtForMCUsSdkPackage->path() + "/bin"));
QVector<McuPackage *> packagesIncludingSdk;
packagesIncludingSdk.reserve(mcuTarget->packages().size() + 1);
packagesIncludingSdk.append(mcuTarget->packages());
@@ -517,9 +559,12 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
using namespace CMakeProjectManager;
CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
if (mcuTarget->toolChainPackage())
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeGHS) {
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
}
if (mcuTarget->toolChainPackage()->type() != McuToolChainPackage::TypeDesktop)
config.append(CMakeConfigItem(
"CMAKE_TOOLCHAIN_FILE",
(qulDir + "/lib/cmake/Qul/toolchain/"
@@ -528,8 +573,6 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
(qulDir + "/lib/cmake/Qul/QulGenerators.cmake").toUtf8()));
config.append(CMakeConfigItem("QUL_PLATFORM",
mcuTarget->qulPlatform().toUtf8()));
if (mcuTargetIsDesktop(mcuTarget))
config.append(CMakeConfigItem("CMAKE_PREFIX_PATH", "%{Qt:QT_INSTALL_PREFIX}"));
if (mcuTarget->colorDepth() >= 0)
config.append(CMakeConfigItem("QUL_COLOR_DEPTH",
QString::number(mcuTarget->colorDepth()).toLatin1()));
@@ -541,14 +584,24 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarg
CMakeConfigurationKitAspect::setConfiguration(k, config);
}
static void setKitQtVersionOptions(ProjectExplorer::Kit *k)
{
QtSupport::QtKitAspect::setQtVersion(k, nullptr);
}
QString McuSupportOptions::kitName(const McuTarget *mcuTarget) const
{
// TODO: get version from qulSdkPackage and insert into name
const QString colorDepth = mcuTarget->colorDepth() > 0
? QString::fromLatin1(" %1bpp").arg(mcuTarget->colorDepth())
: "";
// Hack: Use the platform name in the kit name. Exception for the "Qt" platform: use "Desktop"
const QString targetName =
mcuTarget->toolChainPackage()->type() == McuToolChainPackage::TypeDesktop
? "Desktop"
: mcuTarget->qulPlatform();
return QString::fromLatin1("Qt for MCUs %1 - %2%3")
.arg(supportedQulVersion().toString(), mcuTarget->qulPlatform(), colorDepth);
.arg(supportedQulVersion().toString(), targetName, colorDepth);
}
QList<ProjectExplorer::Kit *> McuSupportOptions::existingKits(const McuTarget *mcuTargt)
@@ -568,13 +621,12 @@ ProjectExplorer::Kit *McuSupportOptions::newKit(const McuTarget *mcuTarget)
KitGuard kitGuard(k);
setKitProperties(kitName(mcuTarget), k, mcuTarget);
if (!mcuTargetIsDesktop(mcuTarget)) {
setKitToolchains(k, mcuTarget->toolChainPackage());
setKitDebugger(k, mcuTarget->toolChainPackage());
setKitDevice(k);
}
setKitDevice(k, mcuTarget);
setKitToolchains(k, mcuTarget->toolChainPackage());
setKitDebugger(k, mcuTarget->toolChainPackage());
setKitEnvironment(k, mcuTarget, qtForMCUsSdkPackage);
setKitCMakeOptions(k, mcuTarget, qtForMCUsSdkPackage->path());
setKitQtVersionOptions(k);
k->setup();
k->fix();