2019-10-22 14:33:31 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2020-07-02 16:04:31 +02:00
|
|
|
** Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2019-10-22 14:33:31 +02:00
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-02-15 16:20:38 +01:00
|
|
|
#include "mcusupportversiondetection.h"
|
2021-03-09 18:28:58 +01:00
|
|
|
#include "mcusupport_global.h"
|
2021-02-15 16:20:38 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
2021-03-09 18:28:58 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2020-06-17 09:14:47 +02:00
|
|
|
|
2019-10-22 14:33:31 +02:00
|
|
|
#include <QObject>
|
2019-10-23 06:44:21 +02:00
|
|
|
#include <QVector>
|
2020-03-25 15:09:02 +01:00
|
|
|
#include <QVersionNumber>
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QWidget)
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
2020-03-18 03:17:35 +01:00
|
|
|
class FilePath;
|
2019-10-22 14:33:31 +02:00
|
|
|
class PathChooser;
|
2019-12-11 21:17:53 +01:00
|
|
|
class InfoLabel;
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class Kit;
|
2020-02-26 16:41:52 +01:00
|
|
|
class ToolChain;
|
2019-10-22 14:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace McuSupport {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-12-04 16:32:34 +01:00
|
|
|
void printMessage(const QString &message, bool important);
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
class McuPackage : public QObject
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum Status {
|
2020-12-04 16:32:34 +01:00
|
|
|
EmptyPath,
|
2019-10-22 14:33:31 +02:00
|
|
|
InvalidPath,
|
|
|
|
|
ValidPathInvalidPackage,
|
2021-02-15 16:20:38 +01:00
|
|
|
ValidPackageMismatchedVersion,
|
2019-10-22 14:33:31 +02:00
|
|
|
ValidPackage
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-15 16:20:38 +01:00
|
|
|
McuPackage(const QString &label, const QString &defaultPath,
|
|
|
|
|
const QString &detectionPath, const QString &settingsKey,
|
|
|
|
|
const McuPackageVersionDetector *versionDetector = nullptr);
|
2020-02-26 16:41:52 +01:00
|
|
|
virtual ~McuPackage() = default;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2020-12-04 16:32:34 +01:00
|
|
|
QString basePath() const;
|
2019-10-22 14:33:31 +02:00
|
|
|
QString path() const;
|
|
|
|
|
QString label() const;
|
2020-07-03 09:46:44 +02:00
|
|
|
QString defaultPath() const;
|
2019-10-22 14:33:31 +02:00
|
|
|
QString detectionPath() const;
|
2020-12-04 16:32:34 +01:00
|
|
|
QString statusText() const;
|
|
|
|
|
void updateStatus();
|
|
|
|
|
|
2019-10-22 14:33:31 +02:00
|
|
|
Status status() const;
|
2021-02-15 16:20:38 +01:00
|
|
|
bool validStatus() const;
|
2019-10-22 14:33:31 +02:00
|
|
|
void setDownloadUrl(const QString &url);
|
|
|
|
|
void setEnvironmentVariableName(const QString &name);
|
|
|
|
|
void setAddToPath(bool addToPath);
|
|
|
|
|
bool addToPath() const;
|
2020-10-16 15:10:17 +02:00
|
|
|
void writeGeneralSettings() const;
|
2019-10-22 14:33:31 +02:00
|
|
|
void writeToSettings() const;
|
|
|
|
|
void setRelativePathModifier(const QString &path);
|
2021-02-15 16:20:38 +01:00
|
|
|
void setVersions(const QVector<QString> &versions);
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2020-10-16 15:10:17 +02:00
|
|
|
bool automaticKitCreationEnabled() const;
|
|
|
|
|
void setAutomaticKitCreationEnabled(const bool enabled);
|
|
|
|
|
|
2019-10-22 14:33:31 +02:00
|
|
|
QWidget *widget();
|
|
|
|
|
|
|
|
|
|
QString environmentVariableName() const;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void changed();
|
2020-12-04 16:32:34 +01:00
|
|
|
void statusChanged();
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-12-04 16:32:34 +01:00
|
|
|
void updatePath();
|
|
|
|
|
void updateStatusUi();
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
QWidget *m_widget = nullptr;
|
|
|
|
|
Utils::PathChooser *m_fileChooser = nullptr;
|
2019-12-11 21:17:53 +01:00
|
|
|
Utils::InfoLabel *m_infoLabel = nullptr;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
const QString m_label;
|
|
|
|
|
const QString m_defaultPath;
|
|
|
|
|
const QString m_detectionPath;
|
|
|
|
|
const QString m_settingsKey;
|
2021-02-15 16:20:38 +01:00
|
|
|
const McuPackageVersionDetector *m_versionDetector;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
QString m_path;
|
|
|
|
|
QString m_relativePathModifier; // relative path to m_path to be returned by path()
|
2021-02-15 16:20:38 +01:00
|
|
|
QString m_detectedVersion;
|
|
|
|
|
QVector<QString> m_versions;
|
2019-10-22 14:33:31 +02:00
|
|
|
QString m_downloadUrl;
|
|
|
|
|
QString m_environmentVariableName;
|
|
|
|
|
bool m_addToPath = false;
|
2020-10-16 15:10:17 +02:00
|
|
|
bool m_automaticKitCreation = true;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
Status m_status = InvalidPath;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-26 16:41:52 +01:00
|
|
|
class McuToolChainPackage : public McuPackage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum Type {
|
|
|
|
|
TypeArmGcc,
|
|
|
|
|
TypeIAR,
|
2020-04-07 18:19:32 +02:00
|
|
|
TypeKEIL,
|
2020-04-09 23:50:03 +02:00
|
|
|
TypeGHS,
|
2020-09-18 11:16:37 +02:00
|
|
|
TypeMSVC,
|
2020-11-13 14:00:18 +01:00
|
|
|
TypeGCC,
|
|
|
|
|
TypeUnsupported
|
2020-02-26 16:41:52 +01:00
|
|
|
};
|
|
|
|
|
|
2020-09-18 11:16:37 +02:00
|
|
|
McuToolChainPackage(const QString &label,
|
|
|
|
|
const QString &defaultPath,
|
|
|
|
|
const QString &detectionPath,
|
|
|
|
|
const QString &settingsKey,
|
2021-02-15 16:20:38 +01:00
|
|
|
Type type,
|
|
|
|
|
const McuPackageVersionDetector *versionDetector = nullptr
|
|
|
|
|
);
|
2020-02-26 16:41:52 +01:00
|
|
|
|
|
|
|
|
Type type() const;
|
2020-09-18 11:16:37 +02:00
|
|
|
bool isDesktopToolchain() const;
|
2020-06-26 13:59:38 +02:00
|
|
|
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
|
2020-11-13 14:00:18 +01:00
|
|
|
QString toolChainName() const;
|
2020-02-26 16:41:52 +01:00
|
|
|
QString cmakeToolChainFileName() const;
|
|
|
|
|
QVariant debuggerId() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const Type m_type;
|
|
|
|
|
};
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
class McuTarget : public QObject
|
2019-10-22 14:33:31 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2020-04-27 20:51:08 +02:00
|
|
|
enum class OS {
|
|
|
|
|
Desktop,
|
|
|
|
|
BareMetal,
|
|
|
|
|
FreeRTOS
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-18 11:16:37 +02:00
|
|
|
struct Platform {
|
|
|
|
|
QString name;
|
|
|
|
|
QString displayName;
|
|
|
|
|
QString vendor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
McuTarget(const QVersionNumber &qulVersion, const Platform &platform, OS os,
|
|
|
|
|
const QVector<McuPackage *> &packages,
|
2020-06-30 17:09:03 +02:00
|
|
|
const McuToolChainPackage *toolChainPackage);
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2020-06-30 17:09:03 +02:00
|
|
|
QVersionNumber qulVersion() const;
|
2019-11-20 13:32:10 +01:00
|
|
|
QVector<McuPackage *> packages() const;
|
2020-04-23 23:30:40 +02:00
|
|
|
const McuToolChainPackage *toolChainPackage() const;
|
2020-09-18 11:16:37 +02:00
|
|
|
Platform platform() const;
|
2020-04-27 20:51:08 +02:00
|
|
|
OS os() const;
|
2019-11-21 01:22:28 +01:00
|
|
|
void setColorDepth(int colorDepth);
|
|
|
|
|
int colorDepth() const;
|
2019-11-13 18:37:27 +01:00
|
|
|
bool isValid() const;
|
2020-12-04 16:32:34 +01:00
|
|
|
void printPackageProblems() const;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
private:
|
2020-06-30 17:09:03 +02:00
|
|
|
const QVersionNumber m_qulVersion;
|
2020-09-18 11:16:37 +02:00
|
|
|
const Platform m_platform;
|
2020-04-27 20:51:08 +02:00
|
|
|
const OS m_os = OS::BareMetal;
|
2019-11-15 08:38:55 +01:00
|
|
|
const QVector<McuPackage*> m_packages;
|
2020-04-23 23:30:40 +02:00
|
|
|
const McuToolChainPackage *m_toolChainPackage;
|
2019-11-21 01:22:28 +01:00
|
|
|
int m_colorDepth = -1;
|
2019-10-22 14:33:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class McuSupportOptions : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
McuSupportOptions(QObject *parent = nullptr);
|
|
|
|
|
~McuSupportOptions() override;
|
|
|
|
|
|
2019-11-15 08:38:55 +01:00
|
|
|
QVector<McuPackage*> packages;
|
|
|
|
|
QVector<McuTarget*> mcuTargets;
|
|
|
|
|
McuPackage *qtForMCUsSdkPackage = nullptr;
|
2019-10-22 14:33:31 +02:00
|
|
|
|
2020-03-18 03:17:35 +01:00
|
|
|
void setQulDir(const Utils::FilePath &dir);
|
2020-03-24 18:58:29 +01:00
|
|
|
static Utils::FilePath qulDirFromSettings();
|
2020-03-18 03:17:35 +01:00
|
|
|
|
2020-04-23 23:30:40 +02:00
|
|
|
static QString kitName(const McuTarget* mcuTarget);
|
2019-11-12 15:14:20 +01:00
|
|
|
|
2020-04-23 23:30:40 +02:00
|
|
|
static QList<ProjectExplorer::Kit *> existingKits(const McuTarget *mcuTarget);
|
2020-04-22 23:24:54 +02:00
|
|
|
static QList<ProjectExplorer::Kit *> outdatedKits();
|
|
|
|
|
static void removeOutdatedKits();
|
2020-04-23 23:30:40 +02:00
|
|
|
static ProjectExplorer::Kit *newKit(const McuTarget *mcuTarget, const McuPackage *qtForMCUsSdk);
|
2020-10-16 15:10:17 +02:00
|
|
|
static void createAutomaticKits();
|
2021-02-09 17:27:02 +01:00
|
|
|
static void fixExistingKits();
|
2020-03-18 03:17:35 +01:00
|
|
|
void populatePackagesAndTargets();
|
2020-03-24 18:58:29 +01:00
|
|
|
static void registerQchFiles();
|
2020-04-02 19:31:52 +02:00
|
|
|
static void registerExamples();
|
2020-03-18 03:17:35 +01:00
|
|
|
|
2020-06-30 17:09:03 +02:00
|
|
|
static const QVersionNumber &minimalQulVersion();
|
2020-03-25 15:09:02 +01:00
|
|
|
|
2020-03-18 03:17:35 +01:00
|
|
|
private:
|
|
|
|
|
void deletePackagesAndTargets();
|
2019-10-22 14:33:31 +02:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void changed();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2021-03-09 18:28:58 +01:00
|
|
|
|
|
|
|
|
class MCUSUPPORTSHARED_EXPORT McuDependenciesKitAspect : public ProjectExplorer::KitAspect
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
McuDependenciesKitAspect();
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Tasks validate(const ProjectExplorer::Kit *k) const override;
|
|
|
|
|
void fix(ProjectExplorer::Kit *k) override;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::KitAspectWidget *createConfigWidget(ProjectExplorer::Kit *k) const override;
|
|
|
|
|
|
|
|
|
|
ItemList toUserOutput(const ProjectExplorer::Kit *k) const override;
|
|
|
|
|
|
|
|
|
|
static Utils::Id id();
|
|
|
|
|
static Utils::NameValueItems dependencies(const ProjectExplorer::Kit *k);
|
|
|
|
|
static void setDependencies(ProjectExplorer::Kit *k, const Utils::NameValueItems &dependencies);
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-22 14:33:31 +02:00
|
|
|
} // namespace McuSupport
|