forked from qt-creator/qt-creator
McuSupport: Fix tests and non legacy code for desktop kits
Post merge updates for the "Add toolchain information for desktop kits" task. Task-number: QTCREATORBUG-26750 Change-Id: Idd230589650f88d921f5f97c2bbecabac4784584 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Piotr Mućko <piotr.mucko@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Piotr Mućko
parent
fee3a1dc78
commit
a8e1ab9c56
@@ -251,7 +251,7 @@ McuToolChainPackagePtr createGccToolChainPackage(const SettingsHandler::Ptr &set
|
||||
"GnuToolchain",
|
||||
McuToolChainPackage::ToolChainType::GCC,
|
||||
versions,
|
||||
Constants::TOOLCHAIN_DIR_CMAKE_VARIABLE,
|
||||
{},
|
||||
{},
|
||||
versionDetector)};
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ bool isDesktopToolchain(McuToolChainPackage::ToolChainType type)
|
||||
|| type == McuToolChainPackage::ToolChainType::GCC;
|
||||
}
|
||||
|
||||
|
||||
const static QMap<QString, McuToolChainPackage::ToolChainType> toolchainTypeMapping{
|
||||
{"iar", McuToolChainPackage::ToolChainType::IAR},
|
||||
{"keil", McuToolChainPackage::ToolChainType::KEIL},
|
||||
@@ -154,18 +155,18 @@ McuToolChainPackage *McuTargetFactory::createToolchain(
|
||||
McuToolChainPackage::ToolChainType toolchainType
|
||||
= toolchainTypeMapping.value(toolchain.id, McuToolChainPackage::ToolChainType::Unsupported);
|
||||
|
||||
if (isDesktopToolchain(toolchainType))
|
||||
if (isDesktopToolchain(toolchainType)) {
|
||||
return new McuToolChainPackage{settingsHandler,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
compilerDescription.label,
|
||||
compilerDescription.defaultPath,
|
||||
compilerDescription.validationPath,
|
||||
{},
|
||||
toolchainType,
|
||||
toolchain.versions,
|
||||
compilerDescription.cmakeVar,
|
||||
{},
|
||||
nullptr};
|
||||
else if (!isToolchainDescriptionValid(toolchain))
|
||||
createVersionDetection(compilerDescription.versionDetection)};
|
||||
} else if (!isToolchainDescriptionValid(toolchain))
|
||||
toolchainType = McuToolChainPackage::ToolChainType::Unsupported;
|
||||
|
||||
return new McuToolChainPackage{settingsHandler,
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#pragma once
|
||||
|
||||
constexpr auto gcc_desktop_json = R"({
|
||||
"qulVersion": "@CMAKE_PROJECT_VERSION@",
|
||||
"compatVersion": "@COMPATIBILITY_VERSION@",
|
||||
"qulVersion": "2.3.0",
|
||||
"compatVersion": "1",
|
||||
"platform": {
|
||||
"id": "Qt",
|
||||
"platformName": "Desktop",
|
||||
@@ -50,6 +50,18 @@ constexpr auto gcc_desktop_json = R"({
|
||||
]
|
||||
},
|
||||
"toolchain": {
|
||||
"id": "gcc"
|
||||
"id": "gcc",
|
||||
"versions": [
|
||||
"9.4.0",
|
||||
"10.3.1"
|
||||
],
|
||||
"compiler": {
|
||||
"defaultValue": "/usr",
|
||||
"versionDetection": {
|
||||
"filePattern": "bin/g++",
|
||||
"executableArgs": "--version",
|
||||
"regex": "\\b(\\d+\\.\\d+\\.\\d+)\\b"
|
||||
}
|
||||
}
|
||||
}
|
||||
})";
|
||||
|
||||
67
src/plugins/mcusupport/test/msvc_desktop_json.h
Normal file
67
src/plugins/mcusupport/test/msvc_desktop_json.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2022 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** 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
|
||||
|
||||
constexpr auto msvc_desktop_json = R"({
|
||||
"qulVersion": "@CMAKE_PROJECT_VERSION@",
|
||||
"compatVersion": "@COMPATIBILITY_VERSION@",
|
||||
"platform": {
|
||||
"id": "Qt",
|
||||
"platformName": "Desktop",
|
||||
"vendor": "Qt",
|
||||
"colorDepths": [
|
||||
32
|
||||
],
|
||||
"pathEntries": [
|
||||
],
|
||||
"environmentEntries": [
|
||||
],
|
||||
"cmakeEntries": [
|
||||
{
|
||||
"id": "Qul_DIR",
|
||||
"label": "Qt for MCUs SDK",
|
||||
"type": "path",
|
||||
"cmakeVar": "Qul_ROOT",
|
||||
"optional": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"toolchain": {
|
||||
"id": "msvc",
|
||||
"versions": [
|
||||
"19.20","19.21","19.22","19.23","19.24",
|
||||
"19.25","19.26","19.27","19.28","19.29"
|
||||
],
|
||||
"compiler": {
|
||||
"defaultValue": "$MSVC_COMPILER_DIR",
|
||||
"versionDetection" : {
|
||||
"filePattern": "cl.exe",
|
||||
"executableArgs": "--version",
|
||||
"regex": "\\b(\\d+\\.\\d+)\\.\\d+\\b"
|
||||
}
|
||||
}
|
||||
}
|
||||
})";
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "armgcc_stm32f769i_freertos_json.h"
|
||||
#include "armgcc_stm32h750b_metal_json.h"
|
||||
#include "gcc_desktop_json.h"
|
||||
#include "msvc_desktop_json.h"
|
||||
#include "ghs_rh850_d1m1a_baremetal_json.h"
|
||||
#include "iar_nxp_1064_json.h"
|
||||
#include "iar_stm32f469i_metal_json.h"
|
||||
@@ -81,6 +82,7 @@ const char armGccSuffix[]{"bin/arm-none-eabi-g++"};
|
||||
const char armGccToolchainFilePath[]{"/opt/qtformcu/2.2/lib/cmake/Qul/toolchain/armgcc.cmake"};
|
||||
const char armGccVersion[]{"9.3.1"};
|
||||
const char armGccNewVersion[]{"10.3.1"};
|
||||
const char msvcVersion[] {"14.29"};
|
||||
const QStringList boardSdkVersions{{"2.11.0"}};
|
||||
const char cmakeToolchainLabel[]{"CMake Toolchain File"};
|
||||
const char fallbackDir[]{"/abc/def/fallback"};
|
||||
@@ -203,9 +205,20 @@ void verifyGccToolchain(const McuToolChainPackagePtr &gccPackage, const QStringL
|
||||
QCOMPARE(gccPackage->cmakeVariableName(), "");
|
||||
QCOMPARE(gccPackage->environmentVariableName(), "");
|
||||
QCOMPARE(gccPackage->isDesktopToolchain(), true);
|
||||
QCOMPARE(gccPackage->toolChainName(), unsupported);
|
||||
QCOMPARE(gccPackage->toolChainName(), "gcc");
|
||||
QCOMPARE(gccPackage->toolchainType(), McuToolChainPackage::ToolChainType::GCC);
|
||||
QCOMPARE(gccPackage->versions(), versions);
|
||||
QVERIFY(allOf(versions, [&](const QString &v){ return gccPackage->versions().contains(v);}));
|
||||
}
|
||||
|
||||
void verifyMsvcToolchain(const McuToolChainPackagePtr &msvcPackage, const QStringList &versions)
|
||||
{
|
||||
QVERIFY(msvcPackage != nullptr);
|
||||
QCOMPARE(msvcPackage->cmakeVariableName(), "");
|
||||
QCOMPARE(msvcPackage->environmentVariableName(), "");
|
||||
QCOMPARE(msvcPackage->toolchainType(), McuToolChainPackage::ToolChainType::MSVC);
|
||||
QCOMPARE(msvcPackage->isDesktopToolchain(), true);
|
||||
QCOMPARE(msvcPackage->toolChainName(), "msvc");
|
||||
QVERIFY(allOf(versions, [&](const QString &v){ return msvcPackage->versions().contains(v);}));
|
||||
}
|
||||
|
||||
void verifyTargetToolchains(const Targets &targets,
|
||||
@@ -441,6 +454,20 @@ void McuSupportTest::test_createDesktopGccToolchain()
|
||||
verifyGccToolchain(gccPackage, {});
|
||||
}
|
||||
|
||||
void McuSupportTest::test_legacy_createDesktopMsvcToolchain()
|
||||
{
|
||||
McuToolChainPackagePtr msvcPackage = Legacy::createMsvcToolChainPackage(settingsMockPtr,
|
||||
{msvcVersion});
|
||||
verifyMsvcToolchain(msvcPackage, {msvcVersion});
|
||||
}
|
||||
|
||||
void McuSupportTest::test_createDesktopMsvcToolchain()
|
||||
{
|
||||
const auto description = parseDescriptionJson(msvc_desktop_json);
|
||||
McuToolChainPackagePtr msvcPackage{targetFactory.createToolchain(description.toolchain)};
|
||||
verifyMsvcToolchain(msvcPackage, {});
|
||||
}
|
||||
|
||||
void McuSupportTest::test_verifyManuallyCreatedArmGccToolchain()
|
||||
{
|
||||
verifyArmGccToolchain(armGccToolchainPackagePtr, {armGccVersion});
|
||||
|
||||
@@ -73,6 +73,8 @@ private slots:
|
||||
void test_createIarToolchain();
|
||||
void test_legacy_createDesktopGccToolchain();
|
||||
void test_createDesktopGccToolchain();
|
||||
void test_legacy_createDesktopMsvcToolchain();
|
||||
void test_createDesktopMsvcToolchain();
|
||||
void test_verifyManuallyCreatedArmGccToolchain();
|
||||
void test_legacy_createArmGccToolchain();
|
||||
void test_createArmGccToolchain_data();
|
||||
|
||||
Reference in New Issue
Block a user