2019-10-22 14:33:31 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
|
|
|
|
** Contact: BlackBerry (qt@blackberry.com)
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "mcusupportconstants.h"
|
|
|
|
|
#include "mcusupportoptions.h"
|
2020-03-12 14:25:49 +01:00
|
|
|
#include "mcusupportsdk.h"
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <cmakeprojectmanager/cmakekitinformation.h>
|
|
|
|
|
#include <debugger/debuggeritem.h>
|
|
|
|
|
#include <debugger/debuggeritemmanager.h>
|
|
|
|
|
#include <debugger/debuggerkitinformation.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 <utils/algorithm.h>
|
|
|
|
|
#include <utils/fileutils.h>
|
2019-12-11 21:17:53 +01:00
|
|
|
#include <utils/infolabel.h>
|
2019-10-22 14:33:31 +02:00
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
|
|
|
|
#include <QDesktopServices>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
|
|
namespace McuSupport {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
McuPackage::McuPackage(const QString &label, const QString &defaultPath,
|
|
|
|
|
const QString &detectionPath, const QString &settingsKey)
|
2019-10-22 14:33:31 +02:00
|
|
|
: m_label(label)
|
|
|
|
|
, m_defaultPath(defaultPath)
|
|
|
|
|
, m_detectionPath(detectionPath)
|
|
|
|
|
, m_settingsKey(settingsKey)
|
|
|
|
|
{
|
|
|
|
|
QSettings *s = Core::ICore::settings();
|
|
|
|
|
s->beginGroup(Constants::SETTINGS_GROUP);
|
|
|
|
|
m_path = s->value(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey,
|
|
|
|
|
m_defaultPath).toString();
|
|
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QString McuPackage::path() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return QFileInfo(m_fileChooser->path() + m_relativePathModifier).absoluteFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QString McuPackage::label() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return m_label;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QString McuPackage::detectionPath() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return m_detectionPath;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QWidget *McuPackage::widget()
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
if (m_widget)
|
|
|
|
|
return m_widget;
|
|
|
|
|
|
|
|
|
|
m_widget = new QWidget;
|
|
|
|
|
m_fileChooser = new Utils::PathChooser;
|
|
|
|
|
|
|
|
|
|
auto layout = new QGridLayout(m_widget);
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
2019-12-11 21:17:53 +01:00
|
|
|
m_infoLabel = new Utils::InfoLabel();
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
if (!m_downloadUrl.isEmpty()) {
|
|
|
|
|
auto downLoadButton = new QToolButton;
|
|
|
|
|
downLoadButton->setIcon(Utils::Icons::DOWNLOAD.icon());
|
|
|
|
|
downLoadButton->setToolTip(tr("Download from \"%1\"").arg(m_downloadUrl));
|
|
|
|
|
QObject::connect(downLoadButton, &QToolButton::pressed, [this]{
|
|
|
|
|
QDesktopServices::openUrl(m_downloadUrl);
|
|
|
|
|
});
|
|
|
|
|
layout->addWidget(downLoadButton, 0, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout->addWidget(m_fileChooser, 0, 0, 1, 2);
|
2019-12-11 21:17:53 +01:00
|
|
|
layout->addWidget(m_infoLabel, 1, 0, 1, -1);
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2019-11-13 18:37:27 +01:00
|
|
|
m_fileChooser->setPath(m_path);
|
|
|
|
|
|
|
|
|
|
QObject::connect(m_fileChooser, &Utils::PathChooser::pathChanged,
|
|
|
|
|
[this](){
|
|
|
|
|
updateStatus();
|
|
|
|
|
emit changed();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
updateStatus();
|
2019-10-22 14:33:31 +02:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
McuPackage::Status McuPackage::status() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return m_status;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::setDownloadUrl(const QString &url)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
m_downloadUrl = url;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::setEnvironmentVariableName(const QString &name)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
m_environmentVariableName = name;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QString McuPackage::environmentVariableName() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return m_environmentVariableName;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::setAddToPath(bool addToPath)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
m_addToPath = addToPath;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
bool McuPackage::addToPath() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
return m_addToPath;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::writeToSettings() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
if (m_path.compare(m_defaultPath) == 0)
|
|
|
|
|
return;
|
|
|
|
|
QSettings *s = Core::ICore::settings();
|
|
|
|
|
s->beginGroup(Constants::SETTINGS_GROUP);
|
|
|
|
|
s->setValue(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey, m_path);
|
|
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::setRelativePathModifier(const QString &path)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
m_relativePathModifier = path;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
void McuPackage::updateStatus()
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
m_path = m_fileChooser->rawPath();
|
|
|
|
|
const bool validPath = m_fileChooser->isValid();
|
|
|
|
|
const Utils::FilePath detectionPath = Utils::FilePath::fromString(
|
|
|
|
|
m_fileChooser->path() + "/" + m_detectionPath);
|
|
|
|
|
const QString displayDetectionPath = Utils::FilePath::fromString(m_detectionPath).toUserOutput();
|
|
|
|
|
const bool validPackage = detectionPath.exists();
|
|
|
|
|
|
|
|
|
|
m_status = validPath ? (validPackage ? ValidPackage : ValidPathInvalidPackage) : InvalidPath;
|
|
|
|
|
|
2019-12-11 21:17:53 +01:00
|
|
|
m_infoLabel->setType(m_status == ValidPackage ? Utils::InfoLabel::Ok
|
|
|
|
|
: Utils::InfoLabel::NotOk);
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
QString statusText;
|
|
|
|
|
switch (m_status) {
|
|
|
|
|
case ValidPackage:
|
|
|
|
|
statusText = tr("Path is valid, \"%1\" was found.").arg(displayDetectionPath);
|
|
|
|
|
break;
|
|
|
|
|
case ValidPathInvalidPackage:
|
|
|
|
|
statusText = tr("Path exists, but does not contain \"%1\".").arg(displayDetectionPath);
|
|
|
|
|
break;
|
|
|
|
|
case InvalidPath:
|
|
|
|
|
statusText = tr("Path does not exist.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-12-11 21:17:53 +01:00
|
|
|
m_infoLabel->setText(statusText);
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-26 16:41:52 +01:00
|
|
|
McuToolChainPackage::McuToolChainPackage(const QString &label, const QString &defaultPath,
|
|
|
|
|
const QString &detectionPath, const QString &settingsKey,
|
|
|
|
|
McuToolChainPackage::Type type)
|
|
|
|
|
: McuPackage(label, defaultPath, detectionPath, settingsKey)
|
|
|
|
|
, m_type(type)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
McuToolChainPackage::Type McuToolChainPackage::type() const
|
|
|
|
|
{
|
|
|
|
|
return m_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ProjectExplorer::ToolChain* armGccToolChain(const Utils::FilePath &path, Core::Id language)
|
|
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t){
|
|
|
|
|
return t->compilerCommand() == path && t->language() == language;
|
|
|
|
|
});
|
|
|
|
|
if (!toolChain) {
|
|
|
|
|
ToolChainFactory *gccFactory =
|
|
|
|
|
Utils::findOrDefault(ToolChainFactory::allToolChainFactories(), [](ToolChainFactory *f){
|
|
|
|
|
return f->supportedToolChainType() == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID;
|
|
|
|
|
});
|
|
|
|
|
if (gccFactory) {
|
|
|
|
|
const QList<ToolChain*> detected = gccFactory->detectForImport({path, language});
|
|
|
|
|
if (!detected.isEmpty()) {
|
|
|
|
|
toolChain = detected.first();
|
|
|
|
|
toolChain->setDetection(ToolChain::ManualDetection);
|
|
|
|
|
toolChain->setDisplayName("Arm GCC");
|
|
|
|
|
ToolChainManager::registerToolChain(toolChain);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return toolChain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = armGccToolChain(compiler, language);
|
|
|
|
|
return tc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString McuToolChainPackage::cmakeToolChainFileName() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(m_type == TypeArmGcc
|
|
|
|
|
? "armgcc.cmake" : m_type == McuToolChainPackage::TypeIAR
|
|
|
|
|
? "iar.cmake" : "keil.cmake");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant McuToolChainPackage::debuggerId() const
|
|
|
|
|
{
|
|
|
|
|
using namespace Debugger;
|
|
|
|
|
|
|
|
|
|
const Utils::FilePath command = Utils::FilePath::fromUserInput(
|
|
|
|
|
Utils::HostOsInfo::withExecutableSuffix(path() + (
|
|
|
|
|
m_type == TypeArmGcc
|
|
|
|
|
? "/bin/arm-none-eabi-gdb-py" : m_type == TypeIAR
|
|
|
|
|
? "/foo/bar-iar-gdb" : "/bar/foo-keil-gdb")));
|
|
|
|
|
const DebuggerItem *debugger = DebuggerItemManager::findByCommand(command);
|
|
|
|
|
QVariant debuggerId;
|
|
|
|
|
if (!debugger) {
|
|
|
|
|
DebuggerItem newDebugger;
|
|
|
|
|
newDebugger.setCommand(command);
|
2020-03-12 13:46:25 +01:00
|
|
|
const QString displayName = m_type == TypeArmGcc
|
|
|
|
|
? McuPackage::tr("Arm GDB at %1")
|
|
|
|
|
: m_type == TypeIAR ? QLatin1String("/foo/bar-iar-gdb")
|
|
|
|
|
: QLatin1String("/bar/foo-keil-gdb");
|
2020-02-26 16:41:52 +01:00
|
|
|
newDebugger.setUnexpandedDisplayName(displayName.arg(command.toUserOutput()));
|
|
|
|
|
debuggerId = DebuggerItemManager::registerDebugger(newDebugger);
|
|
|
|
|
} else {
|
|
|
|
|
debuggerId = debugger->id();
|
|
|
|
|
}
|
|
|
|
|
return debuggerId;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 00:17:04 +01:00
|
|
|
McuTarget::McuTarget(const QString &vendor, const QString &platform,
|
2020-02-26 16:41:52 +01:00
|
|
|
const QVector<McuPackage *> &packages, McuToolChainPackage *toolChainPackage)
|
2019-11-04 18:01:54 +01:00
|
|
|
: m_vendor(vendor)
|
2020-02-06 00:17:04 +01:00
|
|
|
, m_qulPlatform(platform)
|
2019-10-22 14:33:31 +02:00
|
|
|
, m_packages(packages)
|
2020-02-26 16:41:52 +01:00
|
|
|
, m_toolChainPackage(toolChainPackage)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
2020-02-26 16:41:52 +01:00
|
|
|
QTC_CHECK(m_toolChainPackage == nullptr || m_packages.contains(m_toolChainPackage));
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-20 13:32:10 +01:00
|
|
|
QString McuTarget::vendor() const
|
|
|
|
|
{
|
|
|
|
|
return m_vendor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<McuPackage *> McuTarget::packages() const
|
|
|
|
|
{
|
|
|
|
|
return m_packages;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-26 16:41:52 +01:00
|
|
|
McuToolChainPackage *McuTarget::toolChainPackage() const
|
2019-11-20 13:32:10 +01:00
|
|
|
{
|
2020-02-26 16:41:52 +01:00
|
|
|
return m_toolChainPackage;
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-20 13:32:10 +01:00
|
|
|
QString McuTarget::qulPlatform() const
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
2019-11-20 13:32:10 +01:00
|
|
|
return m_qulPlatform;
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
bool McuTarget::isValid() const
|
2019-11-13 18:37:27 +01:00
|
|
|
{
|
2019-11-15 08:38:55 +01:00
|
|
|
return !Utils::anyOf(packages(), [](McuPackage *package) {
|
|
|
|
|
return package->status() != McuPackage::ValidPackage;
|
2019-11-13 18:37:27 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 01:22:28 +01:00
|
|
|
int McuTarget::colorDepth() const
|
|
|
|
|
{
|
|
|
|
|
return m_colorDepth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void McuTarget::setColorDepth(int colorDepth)
|
|
|
|
|
{
|
|
|
|
|
m_colorDepth = colorDepth;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-22 14:33:31 +02:00
|
|
|
McuSupportOptions::McuSupportOptions(QObject *parent)
|
|
|
|
|
: QObject(parent)
|
2020-03-12 14:25:49 +01:00
|
|
|
, qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage())
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
2020-03-12 14:25:49 +01:00
|
|
|
Sdk::hardcodedTargetsAndPackages(qtForMCUsSdkPackage, &packages, &mcuTargets);
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2020-03-12 14:25:49 +01:00
|
|
|
packages.append(qtForMCUsSdkPackage);
|
2019-10-22 14:33:31 +02:00
|
|
|
for (auto package : packages)
|
2019-11-15 08:38:55 +01:00
|
|
|
connect(package, &McuPackage::changed, [this](){
|
2019-10-22 14:33:31 +02:00
|
|
|
emit changed();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
McuSupportOptions::~McuSupportOptions()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(packages);
|
|
|
|
|
packages.clear();
|
2019-11-15 08:38:55 +01:00
|
|
|
qDeleteAll(mcuTargets);
|
|
|
|
|
mcuTargets.clear();
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
static bool mcuTargetIsDesktop(const McuTarget* mcuTarget)
|
2019-11-02 06:19:51 +01:00
|
|
|
{
|
2019-11-15 08:38:55 +01:00
|
|
|
return mcuTarget->qulPlatform() == "Qt";
|
2019-11-02 06:19:51 +01:00
|
|
|
}
|
|
|
|
|
|
2019-12-06 17:58:38 +01:00
|
|
|
static Utils::FilePath jomExecutablePath()
|
|
|
|
|
{
|
|
|
|
|
return Utils::HostOsInfo::isWindowsHost() ?
|
|
|
|
|
Utils::FilePath::fromUserInput(Core::ICore::libexecPath() + "/jom.exe")
|
|
|
|
|
: Utils::FilePath();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-12 10:39:18 +01:00
|
|
|
static void setKitProperties(const QString &kitName, ProjectExplorer::Kit *k,
|
2019-11-15 08:38:55 +01:00
|
|
|
const McuTarget* mcuTarget)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2019-11-12 10:39:18 +01:00
|
|
|
k->setUnexpandedDisplayName(kitName);
|
2019-11-15 08:38:55 +01:00
|
|
|
k->setValue(Constants::KIT_MCUTARGET_VENDOR_KEY, mcuTarget->vendor());
|
2020-02-06 00:17:04 +01:00
|
|
|
k->setValue(Constants::KIT_MCUTARGET_MODEL_KEY, mcuTarget->qulPlatform());
|
2019-11-13 18:37:27 +01:00
|
|
|
k->setAutoDetected(true);
|
|
|
|
|
k->makeSticky();
|
2019-11-15 08:38:55 +01:00
|
|
|
if (mcuTargetIsDesktop(mcuTarget)) {
|
2019-11-13 23:39:08 +01:00
|
|
|
k->setDeviceTypeForIcon(Constants::DEVICE_TYPE);
|
|
|
|
|
} else {
|
2019-12-06 17:58:38 +01:00
|
|
|
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);
|
2019-11-02 06:19:51 +01:00
|
|
|
}
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-26 16:41:52 +01:00
|
|
|
static void setKitToolchains(ProjectExplorer::Kit *k, const McuToolChainPackage *tcPackage)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
2020-02-26 16:41:52 +01:00
|
|
|
ProjectExplorer::ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
|
|
|
|
|
ProjectExplorer::Constants::C_LANGUAGE_ID));
|
|
|
|
|
ProjectExplorer::ToolChainKitAspect::setToolChain(k, tcPackage->toolChain(
|
|
|
|
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-26 16:41:52 +01:00
|
|
|
static void setKitDebugger(ProjectExplorer::Kit *k, const McuToolChainPackage *tcPackage)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
2020-02-26 16:41:52 +01:00
|
|
|
Debugger::DebuggerKitAspect::setDebugger(k, tcPackage->debuggerId());
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void setKitDevice(ProjectExplorer::Kit *k)
|
|
|
|
|
{
|
2020-02-26 16:41:52 +01:00
|
|
|
ProjectExplorer::DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE);
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-04 19:59:50 +01:00
|
|
|
static void setKitEnvironment(ProjectExplorer::Kit *k, const McuTarget* mcuTarget,
|
|
|
|
|
McuPackage *qtForMCUsSdkPackage)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
Utils::EnvironmentItems changes;
|
|
|
|
|
QStringList pathAdditions;
|
2020-03-04 19:59:50 +01:00
|
|
|
|
|
|
|
|
QVector<McuPackage *> packagesIncludingSdk;
|
|
|
|
|
packagesIncludingSdk.reserve(mcuTarget->packages().size() + 1);
|
|
|
|
|
packagesIncludingSdk.append(mcuTarget->packages());
|
|
|
|
|
packagesIncludingSdk.append(qtForMCUsSdkPackage);
|
|
|
|
|
|
|
|
|
|
for (auto package : packagesIncludingSdk) {
|
2019-10-22 14:33:31 +02:00
|
|
|
if (package->addToPath())
|
|
|
|
|
pathAdditions.append(QDir::toNativeSeparators(package->path()));
|
|
|
|
|
if (!package->environmentVariableName().isEmpty())
|
|
|
|
|
changes.append({package->environmentVariableName(),
|
|
|
|
|
QDir::toNativeSeparators(package->path())});
|
|
|
|
|
}
|
2019-10-31 16:01:35 +01:00
|
|
|
pathAdditions.append("${Path}");
|
2019-10-31 16:04:59 +01:00
|
|
|
pathAdditions.append(QDir::toNativeSeparators(Core::ICore::libexecPath() + "/clang/bin"));
|
2019-11-28 21:13:40 +01:00
|
|
|
const QString path = QLatin1String(Utils::HostOsInfo().isWindowsHost() ? "Path" : "PATH");
|
2019-11-28 18:17:37 +01:00
|
|
|
changes.append({path, pathAdditions.join(Utils::HostOsInfo::pathListSeparator())});
|
2019-10-22 14:33:31 +02:00
|
|
|
EnvironmentKitAspect::setEnvironmentChanges(k, changes);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
static void setKitCMakeOptions(ProjectExplorer::Kit *k, const McuTarget* mcuTarget,
|
2019-11-12 10:39:18 +01:00
|
|
|
const QString &qulDir)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
|
|
|
|
|
CMakeConfig config = CMakeConfigurationKitAspect::configuration(k);
|
2019-11-13 23:32:51 +01:00
|
|
|
config.append(CMakeConfigItem("CMAKE_CXX_COMPILER", "%{Compiler:Executable:Cxx}"));
|
|
|
|
|
config.append(CMakeConfigItem("CMAKE_C_COMPILER", "%{Compiler:Executable:C}"));
|
2020-02-26 16:41:52 +01:00
|
|
|
if (mcuTarget->toolChainPackage())
|
|
|
|
|
config.append(CMakeConfigItem(
|
|
|
|
|
"CMAKE_TOOLCHAIN_FILE",
|
|
|
|
|
(qulDir + "/lib/cmake/Qul/toolchain/"
|
|
|
|
|
+ mcuTarget->toolChainPackage()->cmakeToolChainFileName()).toUtf8()));
|
2020-02-06 00:17:04 +01:00
|
|
|
config.append(CMakeConfigItem("QUL_GENERATORS",
|
2020-02-26 16:41:52 +01:00
|
|
|
(qulDir + "/lib/cmake/Qul/QulGenerators.cmake").toUtf8()));
|
2020-02-06 00:17:04 +01:00
|
|
|
config.append(CMakeConfigItem("QUL_PLATFORM",
|
|
|
|
|
mcuTarget->qulPlatform().toUtf8()));
|
2019-11-21 01:22:28 +01:00
|
|
|
if (mcuTargetIsDesktop(mcuTarget))
|
2019-11-07 13:27:18 +01:00
|
|
|
config.append(CMakeConfigItem("CMAKE_PREFIX_PATH", "%{Qt:QT_INSTALL_PREFIX}"));
|
2019-11-21 01:22:28 +01:00
|
|
|
if (mcuTarget->colorDepth() >= 0)
|
|
|
|
|
config.append(CMakeConfigItem("QUL_COLOR_DEPTH",
|
|
|
|
|
QString::number(mcuTarget->colorDepth()).toLatin1()));
|
2019-12-06 17:58:38 +01:00
|
|
|
const Utils::FilePath jom = jomExecutablePath();
|
|
|
|
|
if (jom.exists()) {
|
|
|
|
|
config.append(CMakeConfigItem("CMAKE_MAKE_PROGRAM", jom.toString().toLatin1()));
|
2019-10-31 16:01:35 +01:00
|
|
|
CMakeGeneratorKitAspect::setGenerator(k, "NMake Makefiles JOM");
|
2019-12-06 17:58:38 +01:00
|
|
|
}
|
|
|
|
|
CMakeConfigurationKitAspect::setConfiguration(k, config);
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QString McuSupportOptions::kitName(const McuTarget *mcuTarget) const
|
2019-11-12 15:14:20 +01:00
|
|
|
{
|
|
|
|
|
// TODO: get version from qulSdkPackage and insert into name
|
2019-11-21 01:22:28 +01:00
|
|
|
const QString colorDepth = mcuTarget->colorDepth() > 0
|
|
|
|
|
? QString::fromLatin1(" %1bpp").arg(mcuTarget->colorDepth())
|
|
|
|
|
: "";
|
2020-02-06 00:17:04 +01:00
|
|
|
return QString::fromLatin1("Qt for MCUs - %1%2")
|
|
|
|
|
.arg(mcuTarget->qulPlatform(), colorDepth);
|
2019-11-12 15:14:20 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QList<ProjectExplorer::Kit *> McuSupportOptions::existingKits(const McuTarget *mcuTargt)
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
2019-11-15 08:38:55 +01:00
|
|
|
const QString mcuTargetKitName = kitName(mcuTargt);
|
|
|
|
|
return Utils::filtered(KitManager::kits(), [&mcuTargetKitName](Kit *kit) {
|
|
|
|
|
return kit->isAutoDetected() && kit->unexpandedDisplayName() == mcuTargetKitName;
|
2019-10-22 14:33:31 +02:00
|
|
|
});
|
2019-11-13 18:37:27 +01:00
|
|
|
}
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
ProjectExplorer::Kit *McuSupportOptions::newKit(const McuTarget *mcuTarget)
|
2019-11-13 18:37:27 +01:00
|
|
|
{
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
const auto init = [this, mcuTarget](Kit *k) {
|
2019-11-13 18:37:27 +01:00
|
|
|
KitGuard kitGuard(k);
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
setKitProperties(kitName(mcuTarget), k, mcuTarget);
|
|
|
|
|
if (!mcuTargetIsDesktop(mcuTarget)) {
|
2020-02-26 16:41:52 +01:00
|
|
|
setKitToolchains(k, mcuTarget->toolChainPackage());
|
|
|
|
|
setKitDebugger(k, mcuTarget->toolChainPackage());
|
2019-11-13 18:37:27 +01:00
|
|
|
setKitDevice(k);
|
|
|
|
|
}
|
2020-03-04 19:59:50 +01:00
|
|
|
setKitEnvironment(k, mcuTarget, qtForMCUsSdkPackage);
|
2019-11-15 08:38:55 +01:00
|
|
|
setKitCMakeOptions(k, mcuTarget, qtForMCUsSdkPackage->path());
|
2019-11-13 18:37:27 +01:00
|
|
|
|
|
|
|
|
k->setup();
|
|
|
|
|
k->fix();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return KitManager::registerKit(init);
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // McuSupport
|