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.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2022-02-15 11:18:56 +01:00
# include "mcusupportoptions.h"
2022-02-01 14:30:35 +01:00
# include "mcupackage.h"
2022-02-16 16:48:28 +01:00
# include "mcutarget.h"
# include "mcukitmanager.h"
# include "mcukitinformation.h"
2022-02-15 11:18:56 +01:00
# include "mcusupportcmakemapper.h"
2019-10-22 14:33:31 +02:00
# include "mcusupportconstants.h"
2022-02-15 11:18:56 +01:00
# include "mcusupportsdk.h"
2022-02-16 16:48:28 +01:00
# include "mcusupportplugin.h"
2019-10-22 14:33:31 +02:00
2021-02-26 14:22:42 +01:00
# include <cmakeprojectmanager/cmakekitinformation.h>
2022-02-15 11:18:56 +01:00
# include <cmakeprojectmanager/cmaketoolmanager.h>
2020-03-24 18:58:29 +01:00
# include <coreplugin/helpmanager.h>
2022-02-15 11:18:56 +01:00
# include <coreplugin/icore.h>
2019-10-22 14:33:31 +02:00
# include <debugger/debuggerkitinformation.h>
# include <utils/algorithm.h>
2022-02-15 11:18:56 +01:00
# include <qtsupport/qtkitinformation.h>
# include <qtsupport/qtversionmanager.h>
2019-10-22 14:33:31 +02:00
2021-03-10 16:38:45 +01:00
# include <QMessageBox>
# include <QPushButton>
2019-10-22 14:33:31 +02:00
2022-02-11 13:51:42 +01:00
using CMakeProjectManager : : CMakeConfigItem ;
using CMakeProjectManager : : CMakeConfigurationKitAspect ;
2020-09-17 11:05:28 +02:00
using namespace ProjectExplorer ;
using namespace Utils ;
2019-10-22 14:33:31 +02:00
namespace McuSupport {
namespace Internal {
2021-09-29 17:23:11 +02:00
void McuSdkRepository : : deletePackagesAndTargets ( )
{
qDeleteAll ( packages ) ;
packages . clear ( ) ;
qDeleteAll ( mcuTargets ) ;
mcuTargets . clear ( ) ;
}
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
{
2022-02-15 11:18:56 +01:00
connect ( qtForMCUsSdkPackage ,
& McuAbstractPackage : : changed ,
this ,
& McuSupportOptions : : populatePackagesAndTargets ) ;
2019-10-22 14:33:31 +02:00
}
McuSupportOptions : : ~ McuSupportOptions ( )
2020-03-18 03:17:35 +01:00
{
deletePackagesAndTargets ( ) ;
delete qtForMCUsSdkPackage ;
}
void McuSupportOptions : : populatePackagesAndTargets ( )
{
2021-09-30 18:30:02 +02:00
setQulDir ( qtForMCUsSdkPackage - > path ( ) ) ;
2020-03-18 03:17:35 +01:00
}
2020-09-17 11:05:28 +02:00
static FilePath qulDocsDir ( )
2020-04-02 19:31:52 +02:00
{
2020-09-17 11:05:28 +02:00
const FilePath qulDir = McuSupportOptions : : qulDirFromSettings ( ) ;
2020-04-02 19:31:52 +02:00
if ( qulDir . isEmpty ( ) | | ! qulDir . exists ( ) )
return { } ;
2020-09-17 11:05:28 +02:00
const FilePath docsDir = qulDir . pathAppended ( " docs " ) ;
return docsDir . exists ( ) ? docsDir : FilePath ( ) ;
2020-04-02 19:31:52 +02:00
}
2020-03-24 18:58:29 +01:00
void McuSupportOptions : : registerQchFiles ( )
{
2020-04-02 19:31:52 +02:00
const QString docsDir = qulDocsDir ( ) . toString ( ) ;
if ( docsDir . isEmpty ( ) )
2020-03-24 18:58:29 +01:00
return ;
2020-12-04 08:47:55 +01:00
const QFileInfoList qchFiles = QDir ( docsDir , " *.qch " ) . entryInfoList ( ) ;
2020-09-17 13:47:30 +02:00
Core : : HelpManager : : registerDocumentation (
2022-02-15 11:18:56 +01:00
Utils : : transform < QStringList > ( qchFiles ,
[ ] ( const QFileInfo & fi ) { return fi . absoluteFilePath ( ) ; } ) ) ;
2020-03-24 18:58:29 +01:00
}
2020-04-02 19:31:52 +02:00
void McuSupportOptions : : registerExamples ( )
{
2020-09-17 11:05:28 +02:00
const FilePath docsDir = qulDocsDir ( ) ;
2020-04-02 19:31:52 +02:00
if ( docsDir . isEmpty ( ) )
return ;
2022-02-15 11:18:56 +01:00
auto examples = { std : : make_pair ( QStringLiteral ( " demos " ) , tr ( " Qt for MCUs Demos " ) ) ,
std : : make_pair ( QStringLiteral ( " examples " ) , tr ( " Qt for MCUs Examples " ) ) } ;
2021-02-09 17:06:24 +01:00
for ( const auto & dir : examples ) {
2022-02-15 11:18:56 +01:00
const FilePath examplesDir = McuSupportOptions : : qulDirFromSettings ( ) . pathAppended ( dir . first ) ;
2021-02-09 17:06:24 +01:00
if ( ! examplesDir . exists ( ) )
continue ;
2022-02-15 11:18:56 +01:00
QtSupport : : QtVersionManager : : registerExampleSet ( dir . second ,
docsDir . toString ( ) ,
2021-02-09 17:06:24 +01:00
examplesDir . toString ( ) ) ;
}
2020-04-02 19:31:52 +02:00
}
2020-06-30 17:09:03 +02:00
const QVersionNumber & McuSupportOptions : : minimalQulVersion ( )
2020-03-25 15:09:02 +01:00
{
2022-02-15 12:20:44 +01:00
static const QVersionNumber v ( { 2 , 0 } ) ;
2020-03-25 15:09:02 +01:00
return v ;
}
2020-09-17 11:05:28 +02:00
void McuSupportOptions : : setQulDir ( const FilePath & dir )
2020-03-18 03:17:35 +01:00
{
deletePackagesAndTargets ( ) ;
2020-12-04 16:32:34 +01:00
qtForMCUsSdkPackage - > updateStatus ( ) ;
2021-02-15 16:20:38 +01:00
if ( qtForMCUsSdkPackage - > validStatus ( ) )
2021-09-29 17:23:11 +02:00
Sdk : : targetsAndPackages ( dir , & sdkRepository ) ;
for ( const auto & package : qAsConst ( sdkRepository . packages ) )
2022-02-14 18:01:04 +01:00
connect ( package , & McuAbstractPackage : : changed , this , & McuSupportOptions : : packagesChanged ) ;
2020-09-17 11:05:28 +02:00
2022-02-14 18:01:04 +01:00
emit packagesChanged ( ) ;
2020-03-18 03:17:35 +01:00
}
2020-09-17 11:05:28 +02:00
FilePath McuSupportOptions : : qulDirFromSettings ( )
2020-03-24 18:58:29 +01:00
{
2022-02-01 14:30:35 +01:00
return Sdk : : packagePathFromSettings ( Constants : : SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK ,
2022-02-15 12:20:44 +01:00
QSettings : : UserScope , { } ) ;
2020-03-24 18:58:29 +01:00
}
2022-02-11 13:51:42 +01:00
void McuSupportOptions : : remapQul2xCmakeVars ( Kit * kit , const EnvironmentItems & envItems )
{
const auto cmakeVars = mapEnvVarsToQul2xCmakeVars ( envItems ) ;
const auto cmakeVarNames = Utils : : transform ( cmakeVars , & CMakeConfigItem : : key ) ;
// First filter out all Qul2.x CMake vars
auto config = Utils : : filtered ( CMakeConfigurationKitAspect : : configuration ( kit ) ,
[ & ] ( const auto & configItem ) {
2022-02-15 11:18:56 +01:00
return ! cmakeVarNames . contains ( configItem . key ) ;
} ) ;
2022-02-11 13:51:42 +01:00
// Then append them with new values
config . append ( cmakeVars ) ;
CMakeConfigurationKitAspect : : setConfiguration ( kit , config ) ;
}
2020-09-17 11:05:28 +02:00
static void setKitToolchains ( Kit * k , const McuToolChainPackage * tcPackage )
2019-10-22 14:33:31 +02:00
{
2022-02-01 16:29:11 +01:00
switch ( tcPackage - > type ( ) ) {
case McuToolChainPackage : : Type : : Unsupported :
return ;
case McuToolChainPackage : : Type : : GHS :
case McuToolChainPackage : : Type : : GHSArm :
return ; // No Green Hills toolchain, because support for it is missing.
case McuToolChainPackage : : Type : : IAR :
case McuToolChainPackage : : Type : : KEIL :
case McuToolChainPackage : : Type : : MSVC :
case McuToolChainPackage : : Type : : GCC :
case McuToolChainPackage : : Type : : ArmGcc :
ToolChainKitAspect : : setToolChain ( k ,
tcPackage - > toolChain (
ProjectExplorer : : Constants : : C_LANGUAGE_ID ) ) ;
ToolChainKitAspect : : setToolChain ( k ,
tcPackage - > toolChain (
ProjectExplorer : : Constants : : CXX_LANGUAGE_ID ) ) ;
2020-04-09 23:50:03 +02:00
return ;
2022-02-01 16:29:11 +01:00
default :
Q_UNREACHABLE ( ) ;
}
2019-10-22 14:33:31 +02:00
}
2020-09-17 11:05:28 +02:00
static void setKitDebugger ( Kit * k , const McuToolChainPackage * tcPackage )
2019-10-22 14:33:31 +02:00
{
2022-02-01 16:29:11 +01:00
if ( tcPackage - > isDesktopToolchain ( ) ) {
// Qt Creator seems to be smart enough to deduce the right Kit debugger from the ToolChain
2020-04-07 18:19:32 +02:00
return ;
2022-02-01 16:29:11 +01:00
}
2020-04-07 18:19:32 +02:00
2022-02-01 16:29:11 +01:00
switch ( tcPackage - > type ( ) ) {
case McuToolChainPackage : : Type : : Unsupported :
case McuToolChainPackage : : Type : : GHS :
case McuToolChainPackage : : Type : : GHSArm :
case McuToolChainPackage : : Type : : IAR :
return ; // No Green Hills and IAR debugger, because support for it is missing.
case McuToolChainPackage : : Type : : KEIL :
case McuToolChainPackage : : Type : : MSVC :
case McuToolChainPackage : : Type : : GCC :
case McuToolChainPackage : : Type : : ArmGcc : {
const QVariant debuggerId = tcPackage - > debuggerId ( ) ;
if ( debuggerId . isValid ( ) ) {
Debugger : : DebuggerKitAspect : : setDebugger ( k , debuggerId ) ;
}
return ;
}
default :
Q_UNREACHABLE ( ) ;
}
2019-10-22 14:33:31 +02:00
}
2022-02-15 11:18:56 +01:00
static void setKitDevice ( Kit * k , const McuTarget * mcuTarget )
2019-10-22 14:33:31 +02:00
{
2020-04-07 18:19:32 +02:00
// "Device Type" Desktop is the default. We use that for the Qt for MCUs Desktop Kit
2020-09-18 11:16:37 +02:00
if ( mcuTarget - > toolChainPackage ( ) - > isDesktopToolchain ( ) )
2020-04-07 18:19:32 +02:00
return ;
2020-09-17 11:05:28 +02:00
DeviceTypeKitAspect : : setDeviceTypeId ( k , Constants : : DEVICE_TYPE ) ;
2019-10-22 14:33:31 +02:00
}
2021-09-29 17:23:11 +02:00
static bool expectsCmakeVars ( const McuTarget * mcuTarget )
{
2022-02-15 11:18:56 +01:00
return mcuTarget - > qulVersion ( ) > = QVersionNumber { 2 , 0 } ;
2021-09-29 17:23:11 +02:00
}
2022-02-15 11:18:56 +01:00
void McuSupportOptions : : setKitEnvironment ( Kit * k ,
const McuTarget * mcuTarget ,
const McuAbstractPackage * qtForMCUsSdkPackage )
2019-10-22 14:33:31 +02:00
{
2020-09-17 11:05:28 +02:00
EnvironmentItems changes ;
2019-10-22 14:33:31 +02:00
QStringList pathAdditions ;
2020-03-04 19:59:50 +01:00
2020-04-07 18:19:32 +02:00
// The Desktop version depends on the Qt shared libs in Qul_DIR/bin.
// If CMake's fileApi is avaialble, we can rely on the "Add library search path to PATH"
// feature of the run configuration. Otherwise, we just prepend the path, here.
2020-09-18 11:16:37 +02:00
if ( mcuTarget - > toolChainPackage ( ) - > isDesktopToolchain ( )
2022-02-15 11:18:56 +01:00
& & ! CMakeProjectManager : : CMakeToolManager : : defaultCMakeTool ( ) - > hasFileApi ( ) )
2021-09-30 18:30:02 +02:00
pathAdditions . append ( qtForMCUsSdkPackage - > path ( ) . pathAppended ( " bin " ) . toUserOutput ( ) ) ;
2020-04-07 18:19:32 +02:00
2022-02-11 13:51:42 +01:00
auto processPackage = [ & pathAdditions , & changes ] ( const McuAbstractPackage * package ) {
2019-10-22 14:33:31 +02:00
if ( package - > addToPath ( ) )
2021-09-30 18:30:02 +02:00
pathAdditions . append ( package - > path ( ) . toUserOutput ( ) ) ;
2019-10-22 14:33:31 +02:00
if ( ! package - > environmentVariableName ( ) . isEmpty ( ) )
2021-09-30 18:30:02 +02:00
changes . append ( { package - > environmentVariableName ( ) , package - > path ( ) . toUserOutput ( ) } ) ;
2020-04-23 23:30:40 +02:00
} ;
for ( auto package : mcuTarget - > packages ( ) )
processPackage ( package ) ;
processPackage ( qtForMCUsSdkPackage ) ;
2022-02-16 16:48:28 +01:00
if ( McuSupportOptions : : kitsNeedQtVersion ( ) )
2020-08-31 00:05:50 +02:00
changes . append ( { QLatin1String ( " LD_LIBRARY_PATH " ) , " %{Qt:QT_INSTALL_LIBS} " } ) ;
2021-09-29 17:23:11 +02:00
// Hack, this problem should be solved in lower layer
if ( expectsCmakeVars ( mcuTarget ) ) {
2022-02-11 13:51:42 +01:00
McuSupportOptions : : remapQul2xCmakeVars ( k , changes ) ;
2021-09-29 17:23:11 +02:00
}
2019-10-22 14:33:31 +02:00
EnvironmentKitAspect : : setEnvironmentChanges ( k , changes ) ;
}
2022-02-15 11:18:56 +01:00
static void setKitDependencies ( Kit * k ,
const McuTarget * mcuTarget ,
const McuAbstractPackage * qtForMCUsSdkPackage )
2021-03-09 18:28:58 +01:00
{
NameValueItems dependencies ;
2022-02-11 13:51:42 +01:00
auto processPackage = [ & dependencies ] ( const McuAbstractPackage * package ) {
2021-03-09 18:28:58 +01:00
if ( ! package - > environmentVariableName ( ) . isEmpty ( ) )
dependencies . append ( { package - > environmentVariableName ( ) ,
2022-02-15 11:18:56 +01:00
QDir : : toNativeSeparators ( package - > detectionPath ( ) ) } ) ;
2021-03-09 18:28:58 +01:00
} ;
for ( auto package : mcuTarget - > packages ( ) )
processPackage ( package ) ;
processPackage ( qtForMCUsSdkPackage ) ;
McuDependenciesKitAspect : : setDependencies ( k , dependencies ) ;
auto irrelevant = k - > irrelevantAspects ( ) ;
irrelevant . insert ( McuDependenciesKitAspect : : id ( ) ) ;
k - > setIrrelevantAspects ( irrelevant ) ;
}
2022-02-11 13:51:42 +01:00
void McuSupportOptions : : updateKitEnvironment ( Kit * k , const McuTarget * mcuTarget )
2021-04-08 17:14:55 +02:00
{
EnvironmentItems changes = EnvironmentKitAspect : : environmentChanges ( k ) ;
for ( auto package : mcuTarget - > packages ( ) ) {
const QString varName = package - > environmentVariableName ( ) ;
if ( ! varName . isEmpty ( ) & & package - > validStatus ( ) ) {
const int index = Utils : : indexOf ( changes , [ varName ] ( const EnvironmentItem & item ) {
return item . name = = varName ;
} ) ;
const EnvironmentItem item = { package - > environmentVariableName ( ) ,
2021-09-30 18:30:02 +02:00
package - > path ( ) . toUserOutput ( ) } ;
2021-04-08 17:14:55 +02:00
if ( index ! = - 1 )
changes . replace ( index , item ) ;
else
changes . append ( item ) ;
}
}
2021-09-29 17:23:11 +02:00
// Hack, this problem should be solved in lower layer
if ( expectsCmakeVars ( mcuTarget ) ) {
remapQul2xCmakeVars ( k , changes ) ;
}
2021-04-08 17:14:55 +02:00
EnvironmentKitAspect : : setEnvironmentChanges ( k , changes ) ;
}
2022-02-15 11:18:56 +01:00
static void setKitCMakeOptions ( Kit * k , const McuTarget * mcuTarget , const FilePath & qulDir )
2019-10-22 14:33:31 +02:00
{
using namespace CMakeProjectManager ;
CMakeConfig config = CMakeConfigurationKitAspect : : configuration ( k ) ;
2020-04-09 23:50:03 +02:00
// CMake ToolChain file for ghs handles CMAKE_*_COMPILER autonomously
2022-02-15 11:18:56 +01:00
if ( mcuTarget - > toolChainPackage ( ) - > type ( ) ! = McuToolChainPackage : : Type : : GHS
& & mcuTarget - > toolChainPackage ( ) - > type ( ) ! = McuToolChainPackage : : Type : : GHSArm ) {
2020-04-09 23:50:03 +02:00
config . append ( CMakeConfigItem ( " CMAKE_CXX_COMPILER " , " %{Compiler:Executable:Cxx} " ) ) ;
config . append ( CMakeConfigItem ( " CMAKE_C_COMPILER " , " %{Compiler:Executable:C} " ) ) ;
}
2020-12-04 16:32:34 +01:00
if ( ! mcuTarget - > toolChainPackage ( ) - > isDesktopToolchain ( ) ) {
2022-02-15 11:18:56 +01:00
const FilePath cMakeToolchainFile = qulDir . pathAppended (
" lib/cmake/Qul/toolchain/ " + mcuTarget - > toolChainPackage ( ) - > cmakeToolChainFileName ( ) ) ;
2020-12-04 16:32:34 +01:00
2022-02-15 11:18:56 +01:00
config . append (
CMakeConfigItem ( " CMAKE_TOOLCHAIN_FILE " , cMakeToolchainFile . toString ( ) . toUtf8 ( ) ) ) ;
2020-12-04 16:32:34 +01:00
if ( ! cMakeToolchainFile . exists ( ) ) {
2022-02-15 11:18:56 +01:00
printMessage ( McuTarget : : tr (
" Warning for target %1: missing CMake toolchain file expected at %2. " )
2022-02-14 18:01:04 +01:00
. arg ( McuKitManager : : kitName ( mcuTarget ) ,
2022-02-15 11:18:56 +01:00
cMakeToolchainFile . toUserOutput ( ) ) ,
false ) ;
2020-12-04 16:32:34 +01:00
}
}
2021-09-30 18:30:02 +02:00
const FilePath generatorsPath = qulDir . pathAppended ( " /lib/cmake/Qul/QulGenerators.cmake " ) ;
2022-02-15 11:18:56 +01:00
config . append ( CMakeConfigItem ( " QUL_GENERATORS " , generatorsPath . toString ( ) . toUtf8 ( ) ) ) ;
2020-12-04 16:32:34 +01:00
if ( ! generatorsPath . exists ( ) ) {
printMessage ( McuTarget : : tr ( " Warning for target %1: missing QulGenerators expected at %2. " )
2022-02-14 18:01:04 +01:00
. arg ( McuKitManager : : kitName ( mcuTarget ) , generatorsPath . toUserOutput ( ) ) ,
2022-02-15 11:18:56 +01:00
false ) ;
2020-12-04 16:32:34 +01:00
}
2022-02-15 11:18:56 +01:00
config . append ( CMakeConfigItem ( " QUL_PLATFORM " , mcuTarget - > platform ( ) . name . toUtf8 ( ) ) ) ;
2020-08-13 13:10:52 +02:00
2022-02-07 16:17:35 +01:00
if ( mcuTarget - > colorDepth ( ) ! = McuTarget : : UnspecifiedColorDepth )
2019-11-21 01:22:28 +01:00
config . append ( CMakeConfigItem ( " QUL_COLOR_DEPTH " ,
QString : : number ( mcuTarget - > colorDepth ( ) ) . toLatin1 ( ) ) ) ;
2022-02-16 16:48:28 +01:00
if ( McuSupportOptions : : kitsNeedQtVersion ( ) )
2020-08-31 00:05:50 +02:00
config . append ( CMakeConfigItem ( " CMAKE_PREFIX_PATH " , " %{Qt:QT_INSTALL_PREFIX} " ) ) ;
2019-12-06 17:58:38 +01:00
CMakeConfigurationKitAspect : : setConfiguration ( k , config ) ;
2021-05-10 14:20:26 +02:00
if ( HostOsInfo : : isWindowsHost ( ) ) {
auto type = mcuTarget - > toolChainPackage ( ) - > type ( ) ;
2022-02-01 16:29:11 +01:00
if ( type = = McuToolChainPackage : : Type : : GHS | | type = = McuToolChainPackage : : Type : : GHSArm ) {
2021-05-10 14:20:26 +02:00
// See https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565802&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565802
// and https://bugreports.qt.io/browse/UL-4247?focusedCommentId=565803&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-565803
CMakeGeneratorKitAspect : : setGenerator ( k , " NMake Makefiles JOM " ) ;
}
}
2019-10-22 14:33:31 +02:00
}
2020-09-17 11:05:28 +02:00
static void setKitQtVersionOptions ( Kit * k )
2020-04-07 18:19:32 +02:00
{
2022-02-16 16:48:28 +01:00
if ( ! McuSupportOptions : : kitsNeedQtVersion ( ) )
2020-08-31 00:05:50 +02:00
QtSupport : : QtKitAspect : : setQtVersion ( k , nullptr ) ;
// else: auto-select a Qt version
2020-04-07 18:19:32 +02:00
}
2021-09-30 18:30:02 +02:00
static FilePath kitDependencyPath ( const Kit * kit , const QString & variableName )
2021-03-10 16:38:45 +01:00
{
for ( const NameValueItem & nameValueItem : EnvironmentKitAspect : : environmentChanges ( kit ) ) {
if ( nameValueItem . name = = variableName )
2021-09-30 18:30:02 +02:00
return FilePath : : fromUserInput ( nameValueItem . value ) ;
2021-03-10 16:38:45 +01:00
}
2021-09-30 18:30:02 +02:00
return FilePath ( ) ;
2021-03-10 16:38:45 +01:00
}
2022-02-16 16:48:28 +01:00
McuKitManager : : UpgradeOption McuSupportOptions : : askForKitUpgrades ( )
2021-03-10 16:38:45 +01:00
{
QMessageBox upgradePopup ( Core : : ICore : : dialogParent ( ) ) ;
upgradePopup . setStandardButtons ( QMessageBox : : Cancel ) ;
2022-02-15 11:18:56 +01:00
QPushButton * replaceButton = upgradePopup . addButton ( tr ( " Replace Existing Kits " ) ,
QMessageBox : : NoRole ) ;
QPushButton * keepButton = upgradePopup . addButton ( tr ( " Create New Kits " ) , QMessageBox : : NoRole ) ;
2021-03-10 16:38:45 +01:00
upgradePopup . setWindowTitle ( tr ( " Qt for MCUs " ) ) ;
2021-07-02 15:00:36 +02:00
upgradePopup . setText ( tr ( " New version of Qt for MCUs detected. Upgrade existing kits? " ) ) ;
2021-03-10 16:38:45 +01:00
upgradePopup . exec ( ) ;
if ( upgradePopup . clickedButton ( ) = = keepButton )
2022-02-16 16:48:28 +01:00
return McuKitManager : : UpgradeOption : : Keep ;
2021-03-10 16:38:45 +01:00
if ( upgradePopup . clickedButton ( ) = = replaceButton )
2022-02-16 16:48:28 +01:00
return McuKitManager : : UpgradeOption : : Replace ;
2021-03-10 16:38:45 +01:00
2022-02-16 16:48:28 +01:00
return McuKitManager : : UpgradeOption : : Ignore ;
2021-03-10 16:38:45 +01:00
}
2020-10-16 15:10:17 +02:00
2022-02-16 16:48:28 +01:00
void McuSupportOptions : : deletePackagesAndTargets ( )
{
sdkRepository . deletePackagesAndTargets ( ) ;
2020-10-16 15:10:17 +02:00
}
2022-02-16 16:48:28 +01:00
2021-03-10 16:38:45 +01:00
void McuSupportOptions : : checkUpgradeableKits ( )
{
2021-09-29 17:23:11 +02:00
if ( ! qtForMCUsSdkPackage - > validStatus ( ) | | sdkRepository . mcuTargets . length ( ) = = 0 )
2021-03-10 16:38:45 +01:00
return ;
2021-09-29 17:23:11 +02:00
if ( Utils : : anyOf ( sdkRepository . mcuTargets , [ this ] ( const McuTarget * target ) {
2022-02-14 18:01:04 +01:00
return ! McuKitManager : : upgradeableKits ( target , this - > qtForMCUsSdkPackage ) . empty ( )
& & McuKitManager : : matchingKits ( target , this - > qtForMCUsSdkPackage ) . empty ( ) ;
2021-03-10 16:38:45 +01:00
} ) )
2022-02-16 16:48:28 +01:00
McuKitManager : : upgradeKitsByCreatingNewPackage ( askForKitUpgrades ( ) ) ;
2021-04-08 17:14:55 +02:00
}
2022-02-16 16:48:28 +01:00
bool McuSupportOptions : : kitsNeedQtVersion ( )
2021-02-09 17:27:02 +01:00
{
2022-02-16 16:48:28 +01:00
// Only on Windows, Qt is linked into the distributed qul Desktop libs. Also, the host tools
// are missing the Qt runtime libraries on non-Windows.
return ! HostOsInfo : : isWindowsHost ( ) ;
2021-02-09 17:27:02 +01:00
}
2022-02-15 11:18:56 +01:00
} // namespace Internal
} // namespace McuSupport