diff --git a/src/plugins/mcusupport/mcukitinformation.cpp b/src/plugins/mcusupport/mcukitinformation.cpp index 7c7bde5c7de..f4efd71f6d7 100644 --- a/src/plugins/mcusupport/mcukitinformation.cpp +++ b/src/plugins/mcusupport/mcukitinformation.cpp @@ -26,9 +26,9 @@ #include "mcukitinformation.h" #include -#include #include #include +#include using namespace ProjectExplorer; @@ -74,17 +74,17 @@ Tasks McuDependenciesKitAspect::validate(const Kit *kit) const // check paths defined in cmake variables for given dependencies exist const auto cMakeEntries = Utils::NameValueDictionary(configuration(kit)); - for (const auto &dependency: dependencies(kit)) { - auto givenPath = Utils::FilePath::fromString(cMakeEntries.value(dependency.name)); + for (const auto &dependency : dependencies(kit)) { + auto givenPath = Utils::FilePath::fromUserInput(cMakeEntries.value(dependency.name)); if (givenPath.isEmpty()) { - result << BuildSystemTask(Task::Warning, tr("CMake variable %1 not defined.").arg( - dependency.name)); + result << BuildSystemTask(Task::Warning, + tr("CMake variable %1 not defined.").arg(dependency.name)); } else { const auto detectionPath = givenPath.resolvePath(dependency.value); if (!detectionPath.exists()) { - result << BuildSystemTask(Task::Warning, tr("CMake variable %1: path %2 does not exist.").arg( - dependency.name, - detectionPath.toUserOutput())); + result << BuildSystemTask(Task::Warning, + tr("CMake variable %1: path %2 does not exist.") + .arg(dependency.name, detectionPath.toUserOutput())); } } } @@ -94,11 +94,12 @@ Tasks McuDependenciesKitAspect::validate(const Kit *kit) const void McuDependenciesKitAspect::fix(Kit *kit) { - QTC_ASSERT(kit, return); + QTC_ASSERT(kit, return ); const QVariant variant = kit->value(McuDependenciesKitAspect::id()); if (!variant.isNull() && !variant.canConvert(QVariant::List)) { - qWarning("Kit \"%s\" has a wrong mcu dependencies value set.", qPrintable(kit->displayName())); + qWarning("Kit \"%s\" has a wrong mcu dependencies value set.", + qPrintable(kit->displayName())); setDependencies(kit, Utils::NameValueItems()); } } diff --git a/src/plugins/mcusupport/mcupackage.cpp b/src/plugins/mcusupport/mcupackage.cpp index 5715e74f75e..5cc90925e1e 100644 --- a/src/plugins/mcusupport/mcupackage.cpp +++ b/src/plugins/mcusupport/mcupackage.cpp @@ -75,7 +75,7 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler, , m_downloadUrl(downloadUrl) , m_addToSystemPath(addToSystemPath) { - m_path = FilePath::fromString( + m_path = FilePath::fromUserInput( qEnvironmentVariable(m_environmentVariableName.toStdString().c_str())); if (!m_path.exists()) { m_path = this->settingsHandler->getPath(settingsKey, QSettings::UserScope, m_defaultPath); diff --git a/src/plugins/mcusupport/mcusupportsdk.cpp b/src/plugins/mcusupport/mcusupportsdk.cpp index 13eb7c1c37c..f103a770dd4 100644 --- a/src/plugins/mcusupport/mcusupportsdk.cpp +++ b/src/plugins/mcusupport/mcusupportsdk.cpp @@ -395,7 +395,7 @@ static McuPackagePtr createStm32CubeProgrammerPackage(const SettingsHandler::Ptr defaultPath = programPath; } - const FilePath detectionPath = FilePath::fromString( + const FilePath detectionPath = FilePath::fromUserInput( QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe" : "/bin/STM32_Programmer.sh")); @@ -433,7 +433,7 @@ static McuPackagePtr createMcuXpressoIdePackage(const SettingsHandler::Ptr &sett defaultPath = subDirs.first(); } } else { - const FilePath programPath = FilePath::fromString("/usr/local/mcuxpressoide/"); + const FilePath programPath = FilePath::fromUserInput("/usr/local/mcuxpressoide/"); if (programPath.exists()) defaultPath = programPath; } @@ -468,13 +468,14 @@ static McuPackagePtr createCypressProgrammerPackage(const SettingsHandler::Ptr & } } - return McuPackagePtr{new McuPackage(settingsHandler, - "Cypress Auto Flash Utility", - defaultPath, - FilePath("/bin/openocd").withExecutableSuffix(), - "CypressAutoFlashUtil", // settings key - "INFINEON_AUTO_FLASH_UTILITY_DIR", // cmake var - envVar)}; // env var + return McuPackagePtr{ + new McuPackage(settingsHandler, + "Cypress Auto Flash Utility", + defaultPath, + FilePath::fromUserInput("/bin/openocd").withExecutableSuffix(), + "CypressAutoFlashUtil", // settings key + "INFINEON_AUTO_FLASH_UTILITY_DIR", // cmake var + envVar)}; // env var } static McuPackagePtr createRenesasProgrammerPackage(const SettingsHandler::Ptr &settingsHandler) @@ -657,8 +658,8 @@ static PackageDescription parsePackage(const QJsonObject &cmakeEntry) cmakeEntry["cmakeVar"].toString(), cmakeEntry["description"].toString(), cmakeEntry["setting"].toString(), - FilePath::fromString(cmakeEntry["defaultValue"].toString()), - FilePath::fromString(cmakeEntry["validation"].toString()), + FilePath::fromUserInput(cmakeEntry["defaultValue"].toString()), + FilePath::fromUserInput(cmakeEntry["validation"].toString()), versions, parseVersionDetection(cmakeEntry), false}; @@ -728,7 +729,7 @@ McuTargetDescription parseDescriptionJson(const QByteArray &data) boardSdkPackage, { freeRTOS.value("envVar").toString(), - FilePath::fromString(freeRTOS.value("boardSdkSubDir").toString()), + FilePath::fromUserInput(freeRTOS.value("boardSdkSubDir").toString()), freeRtosEntries, }}; } @@ -778,7 +779,7 @@ McuSdkRepository targetsAndPackages(const FilePath &qtForMCUSdkPath, if (!file.open(QFile::ReadOnly)) continue; const McuTargetDescription desc = parseDescriptionJson(file.readAll()); - const auto pth = FilePath::fromString(fileInfo.filePath()); + const auto pth = FilePath::fromUserInput(fileInfo.filePath()); bool ok = false; const int compatVersion = desc.compatVersion.toInt(&ok); if (!desc.compatVersion.isEmpty() && ok && compatVersion > MAX_COMPATIBILITY_VERSION) { diff --git a/src/plugins/mcusupport/mcutargetfactory.cpp b/src/plugins/mcusupport/mcutargetfactory.cpp index 88d04c4a731..49e2aa7f9d7 100644 --- a/src/plugins/mcusupport/mcutargetfactory.cpp +++ b/src/plugins/mcusupport/mcutargetfactory.cpp @@ -67,7 +67,7 @@ McuPackageVersionDetector *createVersionDetection(const VersionDetection &versio versionDetection.xmlAttribute, versionDetection.regex}; else if (!versionDetection.executableArgs.isEmpty()) - return new McuPackageExecutableVersionDetector{Utils::FilePath::fromString( + return new McuPackageExecutableVersionDetector{Utils::FilePath::fromUserInput( versionDetection.filePattern), QStringList{versionDetection.executableArgs}, versionDetection.regex}; diff --git a/src/plugins/mcusupport/settingshandler.cpp b/src/plugins/mcusupport/settingshandler.cpp index aef86ddbd89..3bbea11ba98 100644 --- a/src/plugins/mcusupport/settingshandler.cpp +++ b/src/plugins/mcusupport/settingshandler.cpp @@ -53,7 +53,7 @@ static FilePath packagePathFromSettings(const QString &settingsKey, FilePath SettingsHandler::getPath(const QString &settingsKey, QSettings::Scope scope, - const Utils::FilePath &defaultPath) const + const FilePath &defaultPath) const { //Use the default value for empty keys if (settingsKey.isEmpty()) @@ -63,8 +63,8 @@ FilePath SettingsHandler::getPath(const QString &settingsKey, } bool SettingsHandler::write(const QString &settingsKey, - const Utils::FilePath &path, - const Utils::FilePath &defaultPath) const + const FilePath &path, + const FilePath &defaultPath) const { const FilePath savedPath = packagePathFromSettings(settingsKey, *Core::ICore::settings(QSettings::UserScope), diff --git a/src/plugins/mcusupport/test/unittest.cpp b/src/plugins/mcusupport/test/unittest.cpp index 7243c84f7fa..09d28eed83d 100644 --- a/src/plugins/mcusupport/test/unittest.cpp +++ b/src/plugins/mcusupport/test/unittest.cpp @@ -307,14 +307,15 @@ void McuSupportTest::initTestCase() EXPECT_CALL(*freeRtosPackage, cmakeVariableName()) .WillRepeatedly(Return(QString{freeRtosCMakeVar})); EXPECT_CALL(*freeRtosPackage, isValidStatus()).WillRepeatedly(Return(true)); - EXPECT_CALL(*freeRtosPackage, path()).WillRepeatedly(Return(FilePath::fromString(freeRtosPath))); + EXPECT_CALL(*freeRtosPackage, path()) + .WillRepeatedly(Return(FilePath::fromUserInput(freeRtosPath))); EXPECT_CALL(*freeRtosPackage, isAddToSystemPath()).WillRepeatedly(Return(true)); EXPECT_CALL(*freeRtosPackage, detectionPath()).WillRepeatedly(Return(FilePath{})); EXPECT_CALL(*sdkPackage, environmentVariableName()).WillRepeatedly(Return(QString{qulEnvVar})); EXPECT_CALL(*sdkPackage, cmakeVariableName()).WillRepeatedly(Return(QString{qulCmakeVar})); EXPECT_CALL(*sdkPackage, isValidStatus()).WillRepeatedly(Return(true)); - EXPECT_CALL(*sdkPackage, path()).WillRepeatedly(Return(FilePath::fromString(qtForMcuSdkPath))); + EXPECT_CALL(*sdkPackage, path()).WillRepeatedly(Return(FilePath::fromUserInput(qtForMcuSdkPath))); EXPECT_CALL(*sdkPackage, isAddToSystemPath()).WillRepeatedly(Return(true)); EXPECT_CALL(*sdkPackage, detectionPath()).WillRepeatedly(Return(FilePath{})); @@ -324,7 +325,7 @@ void McuSupportTest::initTestCase() .WillRepeatedly(Return(QString{Legacy::Constants::TOOLCHAIN_FILE_CMAKE_VARIABLE})); EXPECT_CALL(*armGccToolchainFilePackage, isValidStatus()).WillRepeatedly(Return(true)); EXPECT_CALL(*armGccToolchainFilePackage, path()) - .WillRepeatedly(Return(FilePath::fromString(armGccToolchainFilePath))); + .WillRepeatedly(Return(FilePath::fromUserInput(armGccToolchainFilePath))); EXPECT_CALL(*armGccToolchainFilePackage, isAddToSystemPath()).WillRepeatedly(Return(false)); EXPECT_CALL(*armGccToolchainFilePackage, detectionPath()).WillRepeatedly(Return(FilePath{})); @@ -829,9 +830,9 @@ void McuSupportTest::test_legacy_createTargetWithToolchainPackages() EXPECT_CALL(*settingsMockPtr, getPath(QString{Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK}, _, _)) - .WillRepeatedly(Return(FilePath::fromString(qtForMcuSdkPath))); + .WillRepeatedly(Return(FilePath::fromUserInput(qtForMcuSdkPath))); EXPECT_CALL(*settingsMockPtr, getPath(compilerSetting, _, _)) - .WillRepeatedly(Return(FilePath::fromString(compilerPath))); + .WillRepeatedly(Return(FilePath::fromUserInput(compilerPath))); const auto [targets, packages]{ targetsFromDescriptions({description}, settingsMockPtr, qtForMcuSdkPath, runLegacy)}; @@ -854,10 +855,10 @@ void McuSupportTest::test_createTargetWithToolchainPackages() QFETCH(QStringList, versions); EXPECT_CALL(*settingsMockPtr, getPath(compilerSetting, _, _)) - .WillRepeatedly(Return(FilePath::fromString(compilerPath))); + .WillRepeatedly(Return(FilePath::fromUserInput(compilerPath))); EXPECT_CALL(*settingsMockPtr, getPath(compilerSetting, _, _)) - .WillRepeatedly(Return(FilePath::fromString(compilerPath))); + .WillRepeatedly(Return(FilePath::fromUserInput(compilerPath))); const McuTargetDescription description = parseDescriptionJson(json.toLocal8Bit()); const auto [targets, packages]{ @@ -933,7 +934,7 @@ void McuSupportTest::test_legacy_createQtMCUsPackage() { EXPECT_CALL(*settingsMockPtr, getPath(QString{Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK}, _, _)) - .WillRepeatedly(Return(FilePath::fromString(qtForMcuSdkPath))); + .WillRepeatedly(Return(FilePath::fromUserInput(qtForMcuSdkPath))); McuPackagePtr qtForMCUsSDK = createQtForMCUsPackage(settingsMockPtr);