diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2020-03-12 14:25:49 +0100 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2020-03-17 09:29:21 +0000 |
commit | 550e4bb98c3ab955ae288824f482d378c7a5266a (patch) | |
tree | 8c80fa9c8ae7e48359942eabb316bd4ef2d8499a /src/plugins/mcusupport | |
parent | e0d38ab353b12b91ee9015ce4e27974af5ba4ddd (diff) |
McuSupport: Prepare for dynamic targets detection of SDK
Move around some code to keep the following changes understandable.
Task-number: UL-2012
Change-Id: Ib05699b893d2f7d1cf846507adb198b893187954
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/mcusupport')
-rw-r--r-- | src/plugins/mcusupport/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/mcusupport/mcusupport.pro | 2 | ||||
-rw-r--r-- | src/plugins/mcusupport/mcusupport.qbs | 2 | ||||
-rw-r--r-- | src/plugins/mcusupport/mcusupportoptions.cpp | 169 | ||||
-rw-r--r-- | src/plugins/mcusupport/mcusupportsdk.cpp | 208 | ||||
-rw-r--r-- | src/plugins/mcusupport/mcusupportsdk.h | 45 |
6 files changed, 263 insertions, 164 deletions
diff --git a/src/plugins/mcusupport/CMakeLists.txt b/src/plugins/mcusupport/CMakeLists.txt index ef25f4f45c9..f2c8cf9b762 100644 --- a/src/plugins/mcusupport/CMakeLists.txt +++ b/src/plugins/mcusupport/CMakeLists.txt @@ -9,5 +9,6 @@ add_qtc_plugin(McuSupport mcusupportoptions.cpp mcusupportoptions.h mcusupportoptionspage.cpp mcusupportoptionspage.h mcusupportplugin.cpp mcusupportplugin.h + mcusupportsdk.cpp mcusupportsdk.h mcusupportrunconfiguration.cpp mcusupportrunconfiguration.h ) diff --git a/src/plugins/mcusupport/mcusupport.pro b/src/plugins/mcusupport/mcusupport.pro index 3f6d598f598..b6564b27b5c 100644 --- a/src/plugins/mcusupport/mcusupport.pro +++ b/src/plugins/mcusupport/mcusupport.pro @@ -11,6 +11,7 @@ HEADERS += \ mcusupportoptions.h \ mcusupportoptionspage.h \ mcusupportplugin.h \ + mcusupportsdk.h \ mcusupportrunconfiguration.h SOURCES += \ @@ -18,6 +19,7 @@ SOURCES += \ mcusupportoptions.cpp \ mcusupportoptionspage.cpp \ mcusupportplugin.cpp \ + mcusupportsdk.cpp \ mcusupportrunconfiguration.cpp RESOURCES += \ diff --git a/src/plugins/mcusupport/mcusupport.qbs b/src/plugins/mcusupport/mcusupport.qbs index 35e3e9a4719..f3bb8a12e99 100644 --- a/src/plugins/mcusupport/mcusupport.qbs +++ b/src/plugins/mcusupport/mcusupport.qbs @@ -24,6 +24,8 @@ QtcPlugin { "mcusupportoptionspage.h", "mcusupportplugin.cpp", "mcusupportplugin.h", + "mcusupportsdk.cpp", + "mcusupportsdk.h", "mcusupportrunconfiguration.cpp", "mcusupportrunconfiguration.h", ] diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index a9839965416..571d841e7a6 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -25,6 +25,7 @@ #include "mcusupportconstants.h" #include "mcusupportoptions.h" +#include "mcusupportsdk.h" #include <coreplugin/icore.h> #include <cmakeprojectmanager/cmakekitinformation.h> @@ -329,173 +330,13 @@ void McuTarget::setColorDepth(int colorDepth) m_colorDepth = colorDepth; } -static QString findInProgramFiles(const QString &folder) -{ - for (auto envVar : {"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"}) { - if (!qEnvironmentVariableIsSet(envVar)) - continue; - const Utils::FilePath dir = - Utils::FilePath::fromUserInput(qEnvironmentVariable(envVar) + "/" + folder); - if (dir.exists()) - return dir.toString(); - } - return {}; -} - -static McuPackage *createQtForMCUsPackage() -{ - auto result = new McuPackage( - McuPackage::tr("Qt for MCUs SDK"), - QDir::homePath(), - Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"), - "QtForMCUsSdk"); - result->setEnvironmentVariableName("Qul_DIR"); - return result; -} - -static McuToolChainPackage *createArmGccPackage() -{ - const char envVar[] = "ARMGCC_DIR"; - - QString defaultPath; - if (qEnvironmentVariableIsSet(envVar)) - defaultPath = qEnvironmentVariable(envVar); - if (defaultPath.isEmpty() && Utils::HostOsInfo::isWindowsHost()) { - const QDir installDir(findInProgramFiles("/GNU Tools ARM Embedded/")); - if (installDir.exists()) { - // If GNU Tools installation dir has only one sub dir, - // select the sub dir, otherwise the installation dir. - const QFileInfoList subDirs = - installDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); - if (subDirs.count() == 1) - defaultPath = subDirs.first().filePath() + '/'; - } - } - if (defaultPath.isEmpty()) - defaultPath = QDir::homePath(); - - auto result = new McuToolChainPackage( - McuPackage::tr("GNU Arm Embedded Toolchain"), - defaultPath, - Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++"), - "GNUArmEmbeddedToolchain", - McuToolChainPackage::TypeArmGcc); - result->setDownloadUrl( - "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads"); - result->setEnvironmentVariableName(envVar); - return result; -} - -static McuPackage *createStm32CubeFwF7SdkPackage() -{ - auto result = new McuPackage( - McuPackage::tr("STM32Cube SDK"), - "%{Env:STM32Cube_FW_F7_SDK_PATH}", - "Drivers/STM32F7xx_HAL_Driver", - "Stm32CubeFwF7Sdk"); - result->setDownloadUrl( - "https://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef7.html"); - result->setEnvironmentVariableName("STM32Cube_FW_F7_SDK_PATH"); - return result; -} - -static McuPackage *createStm32CubeProgrammerPackage() -{ - - QString defaultPath = QDir::homePath(); - if (Utils::HostOsInfo::isWindowsHost()) { - const QString programPath = - findInProgramFiles("/STMicroelectronics/STM32Cube/STM32CubeProgrammer/"); - if (!programPath.isEmpty()) - defaultPath = programPath; - } - auto result = new McuPackage( - McuPackage::tr("STM32CubeProgrammer"), - defaultPath, - QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe" - : "/bin/STM32_Programmer.sh"), - "Stm32CubeProgrammer"); - result->setRelativePathModifier("/bin"); - result->setDownloadUrl( - "https://www.st.com/en/development-tools/stm32cubeprog.html"); - result->setAddToPath(true); - return result; -} - -static McuPackage *createEvkbImxrt1050SdkPackage() -{ - auto result = new McuPackage( - McuPackage::tr("NXP i.MXRT SDK"), - "%{Env:EVKB_IMXRT1050_SDK_PATH}", // TODO: Try to not use 1050 specifics - "EVKB-IMXRT1050_manifest_v3_5.xml", - "EvkbImxrt1050Sdk"); - result->setDownloadUrl("https://mcuxpresso.nxp.com/en/welcome"); - return result; -} - -static McuPackage *createSeggerJLinkPackage() -{ - QString defaultPath = QString("%{Env:SEGGER_JLINK_SOFTWARE_AND_DOCUMENTATION_PATH}"); - if (Utils::HostOsInfo::isWindowsHost()) { - const QString programPath = findInProgramFiles("/SEGGER/JLink"); - if (!programPath.isEmpty()) - defaultPath = programPath; - } - auto result = new McuPackage( - McuPackage::tr("SEGGER JLink"), - defaultPath, - Utils::HostOsInfo::withExecutableSuffix("JLink"), - "SeggerJLink"); - result->setDownloadUrl("https://www.segger.com/downloads/jlink"); - result->setEnvironmentVariableName("SEGGER_JLINK_SOFTWARE_AND_DOCUMENTATION_PATH"); - return result; -} - McuSupportOptions::McuSupportOptions(QObject *parent) : QObject(parent) - , qtForMCUsSdkPackage(createQtForMCUsPackage()) -{ - McuToolChainPackage* armGccPackage = createArmGccPackage(); - McuPackage* stm32CubeFwF7SdkPackage = createStm32CubeFwF7SdkPackage(); - McuPackage* stm32CubeProgrammerPackage = createStm32CubeProgrammerPackage(); - McuPackage* evkbImxrt1050SdkPackage = createEvkbImxrt1050SdkPackage(); - McuPackage* seggerJLinkPackage = createSeggerJLinkPackage(); - - QVector<McuPackage*> stmEvalPackages = { - armGccPackage, stm32CubeProgrammerPackage}; - QVector<McuPackage*> nxpEvalPackages = { - armGccPackage, seggerJLinkPackage}; - QVector<McuPackage*> desktopPackages = {}; - packages = { - armGccPackage, stm32CubeFwF7SdkPackage, stm32CubeProgrammerPackage, evkbImxrt1050SdkPackage, - seggerJLinkPackage, qtForMCUsSdkPackage}; - - const QString vendorStm = "STM"; - const QString vendorNxp = "NXP"; - const QString vendorQt = "Qt"; - - // STM - auto mcuTarget = new McuTarget(vendorStm, "STM32F7508-DISCOVERY", stmEvalPackages, - armGccPackage); - mcuTarget->setColorDepth(32); - mcuTargets.append(mcuTarget); - - mcuTarget = new McuTarget(vendorStm, "STM32F7508-DISCOVERY", stmEvalPackages, armGccPackage); - mcuTarget->setColorDepth(16); - mcuTargets.append(mcuTarget); - - mcuTarget = new McuTarget(vendorStm, "STM32F769I-DISCOVERY", stmEvalPackages, armGccPackage); - mcuTargets.append(mcuTarget); - - // NXP - mcuTarget = new McuTarget(vendorNxp, "MIMXRT1050-EVK", nxpEvalPackages, armGccPackage); - mcuTargets.append(mcuTarget); - - // Desktop (Qt) - mcuTarget = new McuTarget(vendorQt, "Qt", desktopPackages, nullptr); - mcuTarget->setColorDepth(32); - mcuTargets.append(mcuTarget); + , qtForMCUsSdkPackage(Sdk::createQtForMCUsPackage()) +{ + Sdk::hardcodedTargetsAndPackages(qtForMCUsSdkPackage, &packages, &mcuTargets); + packages.append(qtForMCUsSdkPackage); for (auto package : packages) connect(package, &McuPackage::changed, [this](){ emit changed(); diff --git a/src/plugins/mcusupport/mcusupportsdk.cpp b/src/plugins/mcusupport/mcusupportsdk.cpp new file mode 100644 index 00000000000..87ca70b610a --- /dev/null +++ b/src/plugins/mcusupport/mcusupportsdk.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2016 BlackBerry Limited. All rights reserved. +** Contact: BlackBerry (qt@blackberry.com) +** +** 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. +** +****************************************************************************/ + +#include "mcusupportconstants.h" +#include "mcusupportoptions.h" +#include "mcusupportsdk.h" + +#include <utils/hostosinfo.h> +#include <utils/fileutils.h> + +#include <QDir> + +namespace McuSupport { +namespace Internal { +namespace Sdk { + +static QString findInProgramFiles(const QString &folder) +{ + for (auto envVar : {"ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"}) { + if (!qEnvironmentVariableIsSet(envVar)) + continue; + const Utils::FilePath dir = + Utils::FilePath::fromUserInput(qEnvironmentVariable(envVar) + "/" + folder); + if (dir.exists()) + return dir.toString(); + } + return {}; +} + +McuPackage *createQtForMCUsPackage() +{ + auto result = new McuPackage( + McuPackage::tr("Qt for MCUs SDK"), + QDir::homePath(), + Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"), + "QtForMCUsSdk"); + result->setEnvironmentVariableName("Qul_DIR"); + return result; +} + +static McuToolChainPackage *createArmGccPackage() +{ + const char envVar[] = "ARMGCC_DIR"; + + QString defaultPath; + if (qEnvironmentVariableIsSet(envVar)) + defaultPath = qEnvironmentVariable(envVar); + if (defaultPath.isEmpty() && Utils::HostOsInfo::isWindowsHost()) { + const QDir installDir(findInProgramFiles("/GNU Tools ARM Embedded/")); + if (installDir.exists()) { + // If GNU Tools installation dir has only one sub dir, + // select the sub dir, otherwise the installation dir. + const QFileInfoList subDirs = + installDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + if (subDirs.count() == 1) + defaultPath = subDirs.first().filePath() + '/'; + } + } + if (defaultPath.isEmpty()) + defaultPath = QDir::homePath(); + + auto result = new McuToolChainPackage( + McuPackage::tr("GNU Arm Embedded Toolchain"), + defaultPath, + Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++"), + "GNUArmEmbeddedToolchain", + McuToolChainPackage::TypeArmGcc); + result->setDownloadUrl( + "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads"); + result->setEnvironmentVariableName(envVar); + return result; +} + +static McuPackage *createStm32CubeFwF7SdkPackage() +{ + auto result = new McuPackage( + McuPackage::tr("STM32Cube SDK"), + "%{Env:STM32Cube_FW_F7_SDK_PATH}", + "Drivers/STM32F7xx_HAL_Driver", + "Stm32CubeFwF7Sdk"); + result->setDownloadUrl( + "https://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef7.html"); + result->setEnvironmentVariableName("STM32Cube_FW_F7_SDK_PATH"); + return result; +} + +static McuPackage *createStm32CubeProgrammerPackage() +{ + + QString defaultPath = QDir::homePath(); + if (Utils::HostOsInfo::isWindowsHost()) { + const QString programPath = + findInProgramFiles("/STMicroelectronics/STM32Cube/STM32CubeProgrammer/"); + if (!programPath.isEmpty()) + defaultPath = programPath; + } + auto result = new McuPackage( + McuPackage::tr("STM32CubeProgrammer"), + defaultPath, + QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe" + : "/bin/STM32_Programmer.sh"), + "Stm32CubeProgrammer"); + result->setRelativePathModifier("/bin"); + result->setDownloadUrl( + "https://www.st.com/en/development-tools/stm32cubeprog.html"); + result->setAddToPath(true); + return result; +} + +static McuPackage *createEvkbImxrt1050SdkPackage() +{ + auto result = new McuPackage( + McuPackage::tr("NXP i.MXRT SDK"), + "%{Env:EVKB_IMXRT1050_SDK_PATH}", // TODO: Try to not use 1050 specifics + "EVKB-IMXRT1050_manifest_v3_5.xml", + "EvkbImxrt1050Sdk"); + result->setDownloadUrl("https://mcuxpresso.nxp.com/en/welcome"); + return result; +} + +static McuPackage *createSeggerJLinkPackage() +{ + QString defaultPath = QString("%{Env:SEGGER_JLINK_SOFTWARE_AND_DOCUMENTATION_PATH}"); + if (Utils::HostOsInfo::isWindowsHost()) { + const QString programPath = findInProgramFiles("/SEGGER/JLink"); + if (!programPath.isEmpty()) + defaultPath = programPath; + } + auto result = new McuPackage( + McuPackage::tr("SEGGER JLink"), + defaultPath, + Utils::HostOsInfo::withExecutableSuffix("JLink"), + "SeggerJLink"); + result->setDownloadUrl("https://www.segger.com/downloads/jlink"); + result->setEnvironmentVariableName("SEGGER_JLINK_SOFTWARE_AND_DOCUMENTATION_PATH"); + return result; +} + +void hardcodedTargetsAndPackages(const McuPackage* qtForMCUsSdkPackage, + QVector<McuPackage *> *packages, QVector<McuTarget *> *mcuTargets) +{ + McuToolChainPackage* armGccPackage = Sdk::createArmGccPackage(); + McuPackage* stm32CubeFwF7SdkPackage = Sdk::createStm32CubeFwF7SdkPackage(); + McuPackage* stm32CubeProgrammerPackage = Sdk::createStm32CubeProgrammerPackage(); + McuPackage* evkbImxrt1050SdkPackage = Sdk::createEvkbImxrt1050SdkPackage(); + McuPackage* seggerJLinkPackage = Sdk::createSeggerJLinkPackage(); + + QVector<McuPackage*> stmEvalPackages = { + armGccPackage, stm32CubeProgrammerPackage}; + QVector<McuPackage*> nxpEvalPackages = { + armGccPackage, seggerJLinkPackage}; + QVector<McuPackage*> desktopPackages = {}; + *packages = { + armGccPackage, stm32CubeFwF7SdkPackage, stm32CubeProgrammerPackage, evkbImxrt1050SdkPackage, + seggerJLinkPackage}; + + const QString vendorStm = "STM"; + const QString vendorNxp = "NXP"; + const QString vendorQt = "Qt"; + + // STM + auto mcuTarget = new McuTarget(vendorStm, "STM32F7508-DISCOVERY", stmEvalPackages, + armGccPackage); + mcuTarget->setColorDepth(32); + mcuTargets->append(mcuTarget); + + mcuTarget = new McuTarget(vendorStm, "STM32F7508-DISCOVERY", stmEvalPackages, armGccPackage); + mcuTarget->setColorDepth(16); + mcuTargets->append(mcuTarget); + + mcuTarget = new McuTarget(vendorStm, "STM32F769I-DISCOVERY", stmEvalPackages, armGccPackage); + mcuTargets->append(mcuTarget); + + // NXP + mcuTarget = new McuTarget(vendorNxp, "MIMXRT1050-EVK", nxpEvalPackages, armGccPackage); + mcuTargets->append(mcuTarget); + + // Desktop (Qt) + mcuTarget = new McuTarget(vendorQt, "Qt", desktopPackages, nullptr); + mcuTarget->setColorDepth(32); + mcuTargets->append(mcuTarget); +} + +} // namespace Sdk +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportsdk.h b/src/plugins/mcusupport/mcusupportsdk.h new file mode 100644 index 00000000000..b3116810f24 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportsdk.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2016 BlackBerry Limited. All rights reserved. +** Contact: BlackBerry (qt@blackberry.com) +** +** 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 + +#include <QVector> + +namespace McuSupport { +namespace Internal { +class McuPackage; +class McuToolChainPackage; +class McuTarget; +namespace Sdk { + +McuPackage *createQtForMCUsPackage(); + +// Legacy: List of targets supported by Qt for MCUs 1.0 +void hardcodedTargetsAndPackages(const McuPackage* const qtForMCUsSdkPackage, + QVector<McuPackage*> *packages, QVector<McuTarget*> *mcuTargets); + +} // namespace Sdk +} // namespace Internal +} // namespace McuSupport |