2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2022-02-01 14:30:35 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
#include "mcuabstractpackage.h"
|
2022-06-02 16:13:08 +02:00
|
|
|
#include "mcusupportversiondetection.h"
|
2022-04-22 11:41:33 +02:00
|
|
|
#include "settingshandler.h"
|
2022-02-01 14:30:35 +01:00
|
|
|
|
|
|
|
|
#include <utils/filepath.h>
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QWidget)
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class ToolChain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
class PathChooser;
|
|
|
|
|
class InfoLabel;
|
2022-02-16 16:48:28 +01:00
|
|
|
class Id;
|
2022-02-01 14:30:35 +01:00
|
|
|
} // namespace Utils
|
|
|
|
|
|
2022-08-18 16:44:49 +02:00
|
|
|
namespace McuSupport::Internal {
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
class McuPackage : public McuAbstractPackage
|
2022-02-01 14:30:35 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2022-04-22 11:41:33 +02:00
|
|
|
McuPackage(const SettingsHandler::Ptr &settingsHandler,
|
|
|
|
|
const QString &label,
|
2022-02-11 13:51:42 +01:00
|
|
|
const Utils::FilePath &defaultPath,
|
2022-02-21 15:24:46 +01:00
|
|
|
const Utils::FilePath &detectionPath,
|
2022-02-11 13:51:42 +01:00
|
|
|
const QString &settingsKey,
|
2022-02-22 13:36:55 +01:00
|
|
|
const QString &cmakeVarName,
|
|
|
|
|
const QString &envVarName,
|
2022-06-07 20:58:42 +02:00
|
|
|
const QStringList &versions = {},
|
2022-02-11 13:51:42 +01:00
|
|
|
const QString &downloadUrl = {},
|
2022-02-21 15:24:46 +01:00
|
|
|
const McuPackageVersionDetector *versionDetector = nullptr,
|
|
|
|
|
const bool addToPath = false,
|
|
|
|
|
const Utils::FilePath &relativePathModifier = Utils::FilePath());
|
|
|
|
|
|
2022-03-28 16:42:51 +02:00
|
|
|
~McuPackage() override = default;
|
|
|
|
|
|
2022-02-21 15:24:46 +01:00
|
|
|
QString label() const override;
|
2022-03-23 13:24:02 +01:00
|
|
|
QString cmakeVariableName() const override;
|
|
|
|
|
QString environmentVariableName() const override;
|
2022-02-21 15:24:46 +01:00
|
|
|
bool isAddToSystemPath() const override;
|
2022-06-07 20:58:42 +02:00
|
|
|
QStringList versions() const override;
|
2022-02-21 15:24:46 +01:00
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
Utils::FilePath basePath() const override;
|
|
|
|
|
Utils::FilePath path() const override;
|
|
|
|
|
Utils::FilePath defaultPath() const override;
|
2022-02-21 15:24:46 +01:00
|
|
|
Utils::FilePath detectionPath() const override;
|
2022-03-01 22:35:33 +01:00
|
|
|
QString settingsKey() const final;
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-02-21 15:24:46 +01:00
|
|
|
void updateStatus() override;
|
2022-02-11 13:51:42 +01:00
|
|
|
Status status() const override;
|
2022-02-21 15:24:46 +01:00
|
|
|
bool isValidStatus() const override;
|
|
|
|
|
QString statusText() const override;
|
|
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
bool writeToSettings() const override;
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
QWidget *widget() override;
|
2022-07-04 22:30:42 +02:00
|
|
|
const McuPackageVersionDetector *getVersionDetector() const override;
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-08-18 16:44:49 +02:00
|
|
|
void setPath(const Utils::FilePath &) override;
|
2022-08-09 10:56:33 +02:00
|
|
|
|
2022-02-01 14:30:35 +01:00
|
|
|
private:
|
|
|
|
|
void updatePath();
|
|
|
|
|
void updateStatusUi();
|
|
|
|
|
|
2022-04-22 11:41:33 +02:00
|
|
|
SettingsHandler::Ptr settingsHandler;
|
|
|
|
|
|
2022-02-01 14:30:35 +01:00
|
|
|
Utils::PathChooser *m_fileChooser = nullptr;
|
|
|
|
|
Utils::InfoLabel *m_infoLabel = nullptr;
|
|
|
|
|
|
|
|
|
|
const QString m_label;
|
2022-08-09 10:56:33 +02:00
|
|
|
Utils::FilePath m_defaultPath;
|
2022-02-21 15:24:46 +01:00
|
|
|
const Utils::FilePath m_detectionPath;
|
2022-02-01 14:30:35 +01:00
|
|
|
const QString m_settingsKey;
|
2022-06-02 16:13:08 +02:00
|
|
|
QScopedPointer<const McuPackageVersionDetector> m_versionDetector;
|
2022-02-01 14:30:35 +01:00
|
|
|
|
|
|
|
|
Utils::FilePath m_path;
|
2022-02-21 15:24:46 +01:00
|
|
|
Utils::FilePath m_relativePathModifier; // relative path to m_path to be returned by path()
|
2022-02-01 14:30:35 +01:00
|
|
|
QString m_detectedVersion;
|
|
|
|
|
QStringList m_versions;
|
2022-02-22 13:36:55 +01:00
|
|
|
const QString m_cmakeVariableName;
|
2022-02-01 16:07:50 +01:00
|
|
|
const QString m_environmentVariableName;
|
|
|
|
|
const QString m_downloadUrl;
|
2022-02-21 15:24:46 +01:00
|
|
|
const bool m_addToSystemPath;
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-02-11 13:51:42 +01:00
|
|
|
Status m_status = Status::InvalidPath;
|
2022-07-04 22:30:42 +02:00
|
|
|
}; // class McuPackage
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-07-04 22:30:42 +02:00
|
|
|
class McuToolChainPackage final : public McuPackage
|
2022-02-01 14:30:35 +01:00
|
|
|
{
|
2022-03-28 16:42:51 +02:00
|
|
|
Q_OBJECT
|
2022-02-01 14:30:35 +01:00
|
|
|
public:
|
2022-02-21 15:24:46 +01:00
|
|
|
enum class ToolChainType { IAR, KEIL, MSVC, GCC, ArmGcc, GHS, GHSArm, Unsupported };
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-04-22 11:41:33 +02:00
|
|
|
McuToolChainPackage(const SettingsHandler::Ptr &settingsHandler,
|
|
|
|
|
const QString &label,
|
2022-02-01 14:30:35 +01:00
|
|
|
const Utils::FilePath &defaultPath,
|
2022-02-21 15:24:46 +01:00
|
|
|
const Utils::FilePath &detectionPath,
|
2022-02-01 14:30:35 +01:00
|
|
|
const QString &settingsKey,
|
2022-02-21 15:24:46 +01:00
|
|
|
ToolChainType toolchainType,
|
2022-06-07 20:58:42 +02:00
|
|
|
const QStringList &versions,
|
|
|
|
|
const QString &cmakeVarName,
|
2022-07-04 22:30:42 +02:00
|
|
|
const QString &envVarName,
|
|
|
|
|
const McuPackageVersionDetector *versionDetector);
|
2022-02-01 14:30:35 +01:00
|
|
|
|
2022-02-21 15:24:46 +01:00
|
|
|
ToolChainType toolchainType() const;
|
2022-02-01 14:30:35 +01:00
|
|
|
bool isDesktopToolchain() const;
|
|
|
|
|
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
|
|
|
|
|
QString toolChainName() const;
|
|
|
|
|
QVariant debuggerId() const;
|
|
|
|
|
|
2022-06-20 17:51:59 +03:00
|
|
|
static ProjectExplorer::ToolChain *msvcToolChain(Utils::Id language);
|
|
|
|
|
static ProjectExplorer::ToolChain *gccToolChain(Utils::Id language);
|
|
|
|
|
|
2022-02-01 14:30:35 +01:00
|
|
|
private:
|
2022-02-21 15:24:46 +01:00
|
|
|
const ToolChainType m_type;
|
2022-02-01 14:30:35 +01:00
|
|
|
};
|
|
|
|
|
|
2022-08-18 16:44:49 +02:00
|
|
|
} // namespace McuSupport::Internal
|
2022-04-04 15:40:56 +02:00
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(McuSupport::Internal::McuToolChainPackage::ToolChainType)
|