McuSupport: default paths for 3rd party dependencies left empty

If QtCreator is installed via the Qt Installer, sensible defaults are
provided at installation time. For not provided software, $HOME
is not a useful default. Leaving the field empty signals the
user that they need to provide one manually, more clearly than
providing an invalid path.

Task-number: UL-4939
Change-Id: I8ef79e563366ebdbea53df8183a1eca82bd7be4a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christiaan Janssen
2021-11-23 16:20:52 +01:00
parent 300ec4119f
commit 4a50a582e7

View File

@@ -104,8 +104,6 @@ static McuToolChainPackage *createArmGccPackage()
defaultPath = subDirs.first(); defaultPath = subDirs.first();
} }
} }
if (defaultPath.isEmpty())
defaultPath = FileUtils::homePath();
const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++"); const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++");
const auto versionDetector = new McuPackageExecutableVersionDetector( const auto versionDetector = new McuPackageExecutableVersionDetector(
@@ -129,8 +127,7 @@ static McuToolChainPackage *createGhsToolchainPackage()
{ {
const char envVar[] = "GHS_COMPILER_DIR"; const char envVar[] = "GHS_COMPILER_DIR";
const FilePath defaultPath = qEnvironmentVariableIsSet(envVar) const FilePath defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
? FilePath::fromUserInput(qEnvironmentVariable(envVar)) : FileUtils::homePath();
const auto versionDetector = new McuPackageExecutableVersionDetector( const auto versionDetector = new McuPackageExecutableVersionDetector(
Utils::HostOsInfo::withExecutableSuffix("as850"), Utils::HostOsInfo::withExecutableSuffix("as850"),
@@ -153,8 +150,7 @@ static McuToolChainPackage *createGhsArmToolchainPackage()
{ {
const char envVar[] = "GHS_ARM_COMPILER_DIR"; const char envVar[] = "GHS_ARM_COMPILER_DIR";
const FilePath defaultPath = qEnvironmentVariableIsSet(envVar) const FilePath defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
? FilePath::fromUserInput(qEnvironmentVariable(envVar)) : FileUtils::homePath();
const auto versionDetector = new McuPackageExecutableVersionDetector( const auto versionDetector = new McuPackageExecutableVersionDetector(
Utils::HostOsInfo::withExecutableSuffix("asarm"), Utils::HostOsInfo::withExecutableSuffix("asarm"),
@@ -189,8 +185,6 @@ static McuToolChainPackage *createIarToolChainPackage()
const FilePath compilerExecPath = tc->compilerCommand(); const FilePath compilerExecPath = tc->compilerCommand();
defaultPath = compilerExecPath.parentDir().parentDir(); defaultPath = compilerExecPath.parentDir().parentDir();
} }
else
defaultPath = FileUtils::homePath();
} }
const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/iccarm"); const QString detectionPath = Utils::HostOsInfo::withExecutableSuffix("bin/iccarm");
@@ -219,8 +213,9 @@ static McuPackage *createRGLPackage()
if (qEnvironmentVariableIsSet(envVar)) { if (qEnvironmentVariableIsSet(envVar)) {
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar)); defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
} else if (Utils::HostOsInfo::isWindowsHost()) { } else if (Utils::HostOsInfo::isWindowsHost()) {
defaultPath = FilePath::fromUserInput(QDir::rootPath() + "Renesas_Electronics/D1x_RGL"); const FilePath rglPath = FilePath::fromString(QDir::rootPath()) / "Renesas_Electronics/D1x_RGL";
if (defaultPath.exists()) { if (rglPath.exists()) {
defaultPath = rglPath;
const FilePaths subDirs = const FilePaths subDirs =
defaultPath.dirEntries({QLatin1String("rgl_ghs_D1Mx_*")}, defaultPath.dirEntries({QLatin1String("rgl_ghs_D1Mx_*")},
QDir::Dirs | QDir::NoDotAndDotDot); QDir::Dirs | QDir::NoDotAndDotDot);
@@ -240,7 +235,7 @@ static McuPackage *createRGLPackage()
static McuPackage *createStm32CubeProgrammerPackage() static McuPackage *createStm32CubeProgrammerPackage()
{ {
FilePath defaultPath = FileUtils::homePath(); FilePath defaultPath;
const QString cubePath = "STMicroelectronics/STM32Cube/STM32CubeProgrammer"; const QString cubePath = "STMicroelectronics/STM32Cube/STM32CubeProgrammer";
if (HostOsInfo::isWindowsHost()) { if (HostOsInfo::isWindowsHost()) {
const FilePath programPath = findInProgramFiles(cubePath); const FilePath programPath = findInProgramFiles(cubePath);
@@ -272,8 +267,9 @@ static McuPackage *createMcuXpressoIdePackage()
if (qEnvironmentVariableIsSet(envVar)) { if (qEnvironmentVariableIsSet(envVar)) {
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar)); defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
} else if (HostOsInfo::isWindowsHost()) { } else if (HostOsInfo::isWindowsHost()) {
defaultPath = FilePath::fromString(QDir::rootPath() + "nxp"); const FilePath programPath = FilePath::fromString(QDir::rootPath()) / "nxp";
if (defaultPath.exists()) { if (programPath.exists()) {
defaultPath = programPath;
// If default dir has exactly one sub dir that could be the IDE path, pre-select that. // If default dir has exactly one sub dir that could be the IDE path, pre-select that.
const FilePaths subDirs = const FilePaths subDirs =
defaultPath.dirEntries({QLatin1String("MCUXpressoIDE*")}, defaultPath.dirEntries({QLatin1String("MCUXpressoIDE*")},
@@ -282,7 +278,9 @@ static McuPackage *createMcuXpressoIdePackage()
defaultPath = subDirs.first(); defaultPath = subDirs.first();
} }
} else { } else {
defaultPath = "/usr/local/mcuxpressoide/"; const FilePath programPath = FilePath::fromString("/usr/local/mcuxpressoide/");
if (programPath.exists())
defaultPath = programPath;
} }
auto result = new McuPackage( auto result = new McuPackage(
@@ -303,17 +301,11 @@ static McuPackage *createCypressProgrammerPackage()
if (qEnvironmentVariableIsSet(envVar)) { if (qEnvironmentVariableIsSet(envVar)) {
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar)); defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar));
} else if (HostOsInfo::isWindowsHost()) { } else if (HostOsInfo::isWindowsHost()) {
FilePath candidate = findInProgramFiles("Cypress/Cypress Auto Flash Utility 1.0"); const FilePath candidate = findInProgramFiles("Cypress/Cypress Auto Flash Utility 1.0");
if (candidate.exists()) { if (candidate.exists())
defaultPath = candidate; defaultPath = candidate;
}
} else {
defaultPath = "/usr";
} }
if (defaultPath.isEmpty())
defaultPath = FileUtils::homePath();
auto result = new McuPackage( auto result = new McuPackage(
"Cypress Auto Flash Utility", "Cypress Auto Flash Utility",
defaultPath, defaultPath,
@@ -393,7 +385,7 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
if (defaultPath.exists()) if (defaultPath.exists())
return defaultPath; return defaultPath;
} }
return FileUtils::homePath(); return FilePath();
}(); }();
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar); const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
@@ -418,8 +410,6 @@ static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const Fil
defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar.toLatin1())); defaultPath = FilePath::fromUserInput(qEnvironmentVariable(envVar.toLatin1()));
else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty()) else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty())
defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir; defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir;
else
defaultPath = FileUtils::homePath();
auto result = new McuPackage( auto result = new McuPackage(
QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix), QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix),
@@ -634,7 +624,7 @@ static QVector<McuTarget *> targetsFromDescriptions(const QList<McuTargetDescrip
Utils::FilePath kitsPath(const Utils::FilePath &dir) Utils::FilePath kitsPath(const Utils::FilePath &dir)
{ {
return dir + "/kits/"; return dir / "kits/";
} }
static QFileInfoList targetDescriptionFiles(const Utils::FilePath &dir) static QFileInfoList targetDescriptionFiles(const Utils::FilePath &dir)