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-16 16:48:28 +01:00
|
|
|
|
|
|
|
|
#include "mcutarget.h"
|
|
|
|
|
#include "mcukitmanager.h"
|
2022-03-28 16:42:51 +02:00
|
|
|
#include "mcupackage.h"
|
2022-02-16 16:48:28 +01:00
|
|
|
#include "mcusupportplugin.h"
|
|
|
|
|
|
2022-02-21 15:24:46 +01:00
|
|
|
#include <utils/algorithm.h>
|
2022-02-16 16:48:28 +01:00
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace McuSupport::Internal {
|
|
|
|
|
|
|
|
|
|
McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
|
|
|
|
const Platform &platform,
|
|
|
|
|
OS os,
|
2022-03-28 16:42:51 +02:00
|
|
|
const Packages &packages,
|
|
|
|
|
const McuToolChainPackagePtr &toolChainPackage,
|
2022-04-25 19:52:29 +02:00
|
|
|
const McuPackagePtr &toolChainFilePackage,
|
2022-02-16 16:48:28 +01:00
|
|
|
int colorDepth)
|
|
|
|
|
: m_qulVersion(qulVersion)
|
|
|
|
|
, m_platform(platform)
|
|
|
|
|
, m_os(os)
|
|
|
|
|
, m_packages(packages)
|
|
|
|
|
, m_toolChainPackage(toolChainPackage)
|
2022-04-25 19:52:29 +02:00
|
|
|
, m_toolChainFilePackage(toolChainFilePackage)
|
2022-02-16 16:48:28 +01:00
|
|
|
, m_colorDepth(colorDepth)
|
|
|
|
|
{}
|
|
|
|
|
|
2022-03-28 16:42:51 +02:00
|
|
|
Packages McuTarget::packages() const
|
2022-02-16 16:48:28 +01:00
|
|
|
{
|
|
|
|
|
return m_packages;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 16:42:51 +02:00
|
|
|
McuToolChainPackagePtr McuTarget::toolChainPackage() const
|
2022-02-16 16:48:28 +01:00
|
|
|
{
|
|
|
|
|
return m_toolChainPackage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 19:52:29 +02:00
|
|
|
McuPackagePtr McuTarget::toolChainFilePackage() const
|
|
|
|
|
{
|
|
|
|
|
return m_toolChainFilePackage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 16:48:28 +01:00
|
|
|
McuTarget::OS McuTarget::os() const
|
|
|
|
|
{
|
|
|
|
|
return m_os;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 16:42:51 +02:00
|
|
|
McuTarget::Platform McuTarget::platform() const
|
2022-02-16 16:48:28 +01:00
|
|
|
{
|
|
|
|
|
return m_platform;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool McuTarget::isValid() const
|
|
|
|
|
{
|
2022-03-28 16:42:51 +02:00
|
|
|
return Utils::allOf(packages(), [](const McuPackagePtr &package) {
|
2022-02-16 16:48:28 +01:00
|
|
|
package->updateStatus();
|
2022-02-21 15:24:46 +01:00
|
|
|
return package->isValidStatus();
|
2022-02-16 16:48:28 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 16:55:41 +02:00
|
|
|
QString McuTarget::desktopCompilerId() const
|
|
|
|
|
{
|
|
|
|
|
// MinGW shares CMake configuration with GCC
|
|
|
|
|
// and it is distinguished from MSVC by CMake compiler ID.
|
|
|
|
|
// This provides the compiler ID to set up a different Qul configuration
|
|
|
|
|
// for MSVC and MinGW.
|
|
|
|
|
if (m_toolChainPackage) {
|
|
|
|
|
switch (m_toolChainPackage->toolchainType()) {
|
|
|
|
|
case McuToolChainPackage::ToolChainType::MSVC:
|
|
|
|
|
return QLatin1String("msvc");
|
|
|
|
|
case McuToolChainPackage::ToolChainType::GCC:
|
|
|
|
|
case McuToolChainPackage::ToolChainType::MinGW:
|
|
|
|
|
return QLatin1String("gnu");
|
|
|
|
|
default:
|
|
|
|
|
return QLatin1String("unsupported");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QLatin1String("invalid");
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 16:48:28 +01:00
|
|
|
void McuTarget::printPackageProblems() const
|
|
|
|
|
{
|
|
|
|
|
for (auto package : packages()) {
|
|
|
|
|
package->updateStatus();
|
2022-02-21 15:24:46 +01:00
|
|
|
if (!package->isValidStatus())
|
2022-02-16 16:48:28 +01:00
|
|
|
printMessage(tr("Error creating kit for target %1, package %2: %3")
|
2022-02-22 13:36:55 +01:00
|
|
|
.arg(McuKitManager::generateKitNameFromTarget(this),
|
2022-02-16 16:48:28 +01:00
|
|
|
package->label(),
|
|
|
|
|
package->statusText()),
|
|
|
|
|
true);
|
|
|
|
|
if (package->status() == McuAbstractPackage::Status::ValidPackageMismatchedVersion)
|
|
|
|
|
printMessage(tr("Warning creating kit for target %1, package %2: %3")
|
2022-02-22 13:36:55 +01:00
|
|
|
.arg(McuKitManager::generateKitNameFromTarget(this),
|
2022-02-16 16:48:28 +01:00
|
|
|
package->label(),
|
|
|
|
|
package->statusText()),
|
|
|
|
|
false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 16:42:51 +02:00
|
|
|
QVersionNumber McuTarget::qulVersion() const
|
2022-02-16 16:48:28 +01:00
|
|
|
{
|
|
|
|
|
return m_qulVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int McuTarget::colorDepth() const
|
|
|
|
|
{
|
|
|
|
|
return m_colorDepth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace McuSupport::Internal
|