forked from qt-creator/qt-creator
Make (and return) more properties as const-ref in McuPackage
This implies that those properties are now passed into the constructor, and their setters are removed. Change-Id: I34b4d9d7450897e6a7a72b8edaffdc05961546d1 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <piotr.mucko@qt.io>
This commit is contained in:
committed by
piotr.mucko
parent
6b6b35f59e
commit
32f8ed7b66
@@ -52,12 +52,15 @@ static bool automaticKitCreationFromSettings(QSettings::Scope scope = QSettings:
|
|||||||
|
|
||||||
McuPackage::McuPackage(const QString &label, const FilePath &defaultPath,
|
McuPackage::McuPackage(const QString &label, const FilePath &defaultPath,
|
||||||
const QString &detectionPath, const QString &settingsKey,
|
const QString &detectionPath, const QString &settingsKey,
|
||||||
|
const QString &envVarName, const QString &downloadUrl,
|
||||||
const McuPackageVersionDetector *versionDetector)
|
const McuPackageVersionDetector *versionDetector)
|
||||||
: m_label(label)
|
: m_label(label)
|
||||||
, m_defaultPath(Sdk::packagePathFromSettings(settingsKey, QSettings::SystemScope, defaultPath))
|
, m_defaultPath(Sdk::packagePathFromSettings(settingsKey, QSettings::SystemScope, defaultPath))
|
||||||
, m_detectionPath(detectionPath)
|
, m_detectionPath(detectionPath)
|
||||||
, m_settingsKey(settingsKey)
|
, m_settingsKey(settingsKey)
|
||||||
, m_versionDetector(versionDetector)
|
, m_versionDetector(versionDetector)
|
||||||
|
, m_environmentVariableName(envVarName)
|
||||||
|
, m_downloadUrl(downloadUrl)
|
||||||
{
|
{
|
||||||
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
m_path = Sdk::packagePathFromSettings(settingsKey, QSettings::UserScope, m_defaultPath);
|
||||||
m_automaticKitCreation = automaticKitCreationFromSettings(QSettings::UserScope);
|
m_automaticKitCreation = automaticKitCreationFromSettings(QSettings::UserScope);
|
||||||
@@ -144,17 +147,7 @@ bool McuPackage::validStatus() const
|
|||||||
return m_status == McuPackage::ValidPackage || m_status == McuPackage::ValidPackageMismatchedVersion;
|
return m_status == McuPackage::ValidPackage || m_status == McuPackage::ValidPackageMismatchedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void McuPackage::setDownloadUrl(const QString &url)
|
const QString &McuPackage::environmentVariableName() const
|
||||||
{
|
|
||||||
m_downloadUrl = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void McuPackage::setEnvironmentVariableName(const QString &name)
|
|
||||||
{
|
|
||||||
m_environmentVariableName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString McuPackage::environmentVariableName() const
|
|
||||||
{
|
{
|
||||||
return m_environmentVariableName;
|
return m_environmentVariableName;
|
||||||
}
|
}
|
||||||
@@ -295,9 +288,9 @@ McuToolChainPackage::McuToolChainPackage(const QString &label,
|
|||||||
const FilePath &defaultPath,
|
const FilePath &defaultPath,
|
||||||
const QString &detectionPath,
|
const QString &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
McuToolChainPackage::Type type,
|
McuToolChainPackage::Type type, const QString &envVarName,
|
||||||
const McuPackageVersionDetector *versionDetector)
|
const McuPackageVersionDetector *versionDetector)
|
||||||
: McuPackage(label, defaultPath, detectionPath, settingsKey, versionDetector)
|
: McuPackage(label, defaultPath, detectionPath, settingsKey, envVarName, {}, versionDetector)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
McuPackage(const QString &label, const Utils::FilePath &defaultPath,
|
McuPackage(const QString &label, const Utils::FilePath &defaultPath,
|
||||||
const QString &detectionPath, const QString &settingsKey,
|
const QString &detectionPath, const QString &settingsKey,
|
||||||
|
const QString &envVarName = {}, const QString &downloadUrl = {},
|
||||||
const McuPackageVersionDetector *versionDetector = nullptr);
|
const McuPackageVersionDetector *versionDetector = nullptr);
|
||||||
virtual ~McuPackage() = default;
|
virtual ~McuPackage() = default;
|
||||||
|
|
||||||
@@ -74,8 +75,6 @@ public:
|
|||||||
|
|
||||||
Status status() const;
|
Status status() const;
|
||||||
bool validStatus() const;
|
bool validStatus() const;
|
||||||
void setDownloadUrl(const QString &url);
|
|
||||||
void setEnvironmentVariableName(const QString &name);
|
|
||||||
void setAddToPath(bool addToPath);
|
void setAddToPath(bool addToPath);
|
||||||
bool addToPath() const;
|
bool addToPath() const;
|
||||||
void writeGeneralSettings() const;
|
void writeGeneralSettings() const;
|
||||||
@@ -88,7 +87,7 @@ public:
|
|||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget();
|
||||||
|
|
||||||
QString environmentVariableName() const;
|
const QString &environmentVariableName() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
@@ -112,8 +111,8 @@ private:
|
|||||||
QString m_relativePathModifier; // relative path to m_path to be returned by path()
|
QString m_relativePathModifier; // relative path to m_path to be returned by path()
|
||||||
QString m_detectedVersion;
|
QString m_detectedVersion;
|
||||||
QStringList m_versions;
|
QStringList m_versions;
|
||||||
QString m_downloadUrl;
|
const QString m_environmentVariableName;
|
||||||
QString m_environmentVariableName;
|
const QString m_downloadUrl;
|
||||||
bool m_addToPath = false;
|
bool m_addToPath = false;
|
||||||
bool m_automaticKitCreation = true;
|
bool m_automaticKitCreation = true;
|
||||||
|
|
||||||
@@ -139,6 +138,7 @@ public:
|
|||||||
const QString &detectionPath,
|
const QString &detectionPath,
|
||||||
const QString &settingsKey,
|
const QString &settingsKey,
|
||||||
Type type,
|
Type type,
|
||||||
|
const QString &envVarName = {},
|
||||||
const McuPackageVersionDetector *versionDetector = nullptr
|
const McuPackageVersionDetector *versionDetector = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -269,7 +269,7 @@ McuTarget::McuTarget(const QVersionNumber &qulVersion,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<McuPackage *> McuTarget::packages() const
|
const QVector<McuPackage *> &McuTarget::packages() const
|
||||||
{
|
{
|
||||||
return m_packages;
|
return m_packages;
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ McuTarget::OS McuTarget::os() const
|
|||||||
return m_os;
|
return m_os;
|
||||||
}
|
}
|
||||||
|
|
||||||
McuTarget::Platform McuTarget::platform() const
|
const McuTarget::Platform &McuTarget::platform() const
|
||||||
{
|
{
|
||||||
return m_platform;
|
return m_platform;
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ void McuTarget::printPackageProblems() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVersionNumber McuTarget::qulVersion() const
|
const QVersionNumber &McuTarget::qulVersion() const
|
||||||
{
|
{
|
||||||
return m_qulVersion;
|
return m_qulVersion;
|
||||||
}
|
}
|
||||||
|
@@ -75,10 +75,10 @@ public:
|
|||||||
const QVector<McuPackage *> &packages,
|
const QVector<McuPackage *> &packages,
|
||||||
const McuToolChainPackage *toolChainPackage);
|
const McuToolChainPackage *toolChainPackage);
|
||||||
|
|
||||||
QVersionNumber qulVersion() const;
|
const QVersionNumber &qulVersion() const;
|
||||||
QVector<McuPackage *> packages() const;
|
const QVector<McuPackage *> &packages() const;
|
||||||
const McuToolChainPackage *toolChainPackage() const;
|
const McuToolChainPackage *toolChainPackage() const;
|
||||||
Platform platform() const;
|
const Platform &platform() const;
|
||||||
OS os() const;
|
OS os() const;
|
||||||
void setColorDepth(int colorDepth);
|
void setColorDepth(int colorDepth);
|
||||||
int colorDepth() const;
|
int colorDepth() const;
|
||||||
|
@@ -65,13 +65,11 @@ static FilePath findInProgramFiles(const QString &folder)
|
|||||||
|
|
||||||
McuPackage *createQtForMCUsPackage()
|
McuPackage *createQtForMCUsPackage()
|
||||||
{
|
{
|
||||||
auto result = new McuPackage(
|
return new McuPackage(McuPackage::tr("Qt for MCUs SDK"),
|
||||||
McuPackage::tr("Qt for MCUs SDK"),
|
FileUtils::homePath(), // defaultPath
|
||||||
FileUtils::homePath(),
|
FilePath("bin/qmltocpp").withExecutableSuffix().toString(), // detectionPath
|
||||||
FilePath("bin/qmltocpp").withExecutableSuffix().toString(),
|
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK, // settingsKey
|
||||||
Constants::SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK);
|
QStringLiteral("Qul_DIR")); // envVarName
|
||||||
result->setEnvironmentVariableName("Qul_DIR");
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createMsvcToolChainPackage()
|
static McuToolChainPackage *createMsvcToolChainPackage()
|
||||||
@@ -114,15 +112,13 @@ static McuToolChainPackage *createArmGccPackage()
|
|||||||
"\\b(\\d+\\.\\d+\\.\\d+)\\b"
|
"\\b(\\d+\\.\\d+\\.\\d+)\\b"
|
||||||
);
|
);
|
||||||
|
|
||||||
auto result = new McuToolChainPackage(
|
return new McuToolChainPackage(McuPackage::tr("GNU Arm Embedded Toolchain"),
|
||||||
McuPackage::tr("GNU Arm Embedded Toolchain"),
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
detectionPath,
|
detectionPath,
|
||||||
"GNUArmEmbeddedToolchain",
|
"GNUArmEmbeddedToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeArmGcc,
|
McuToolChainPackage::TypeArmGcc,
|
||||||
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(envVar);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createGhsToolchainPackage()
|
static McuToolChainPackage *createGhsToolchainPackage()
|
||||||
@@ -137,15 +133,14 @@ static McuToolChainPackage *createGhsToolchainPackage()
|
|||||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
||||||
);
|
);
|
||||||
|
|
||||||
auto result = new McuToolChainPackage(
|
return new McuToolChainPackage("Green Hills Compiler",
|
||||||
"Green Hills Compiler",
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("ccv850"),
|
Utils::HostOsInfo::withExecutableSuffix(
|
||||||
"GHSToolchain",
|
"ccv850"), // detectionPath
|
||||||
|
"GHSToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeGHS,
|
McuToolChainPackage::TypeGHS,
|
||||||
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(envVar);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createGhsArmToolchainPackage()
|
static McuToolChainPackage *createGhsArmToolchainPackage()
|
||||||
@@ -160,15 +155,13 @@ static McuToolChainPackage *createGhsArmToolchainPackage()
|
|||||||
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
"\\bv(\\d+\\.\\d+\\.\\d+)\\b"
|
||||||
);
|
);
|
||||||
|
|
||||||
auto result = new McuToolChainPackage(
|
return new McuToolChainPackage("Green Hills Compiler for ARM",
|
||||||
"Green Hills Compiler for ARM",
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("cxarm"),
|
Utils::HostOsInfo::withExecutableSuffix("cxarm"), // detectionPath
|
||||||
"GHSArmToolchain",
|
"GHSArmToolchain", // settingsKey
|
||||||
McuToolChainPackage::TypeGHSArm,
|
McuToolChainPackage::TypeGHSArm,
|
||||||
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(envVar);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuToolChainPackage *createIarToolChainPackage()
|
static McuToolChainPackage *createIarToolChainPackage()
|
||||||
@@ -196,15 +189,13 @@ static McuToolChainPackage *createIarToolChainPackage()
|
|||||||
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b"
|
"\\bV(\\d+\\.\\d+\\.\\d+)\\.\\d+\\b"
|
||||||
);
|
);
|
||||||
|
|
||||||
auto result = new McuToolChainPackage(
|
return new McuToolChainPackage("IAR ARM Compiler",
|
||||||
"IAR ARM Compiler",
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
detectionPath,
|
detectionPath,
|
||||||
"IARToolchain",
|
"IARToolchain", // settings key
|
||||||
McuToolChainPackage::TypeIAR,
|
McuToolChainPackage::TypeIAR,
|
||||||
|
envVar,
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(envVar);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createRGLPackage()
|
static McuPackage *createRGLPackage()
|
||||||
@@ -225,13 +216,11 @@ static McuPackage *createRGLPackage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = new McuPackage(
|
return new McuPackage("Renesas Graphics Library",
|
||||||
"Renesas Graphics Library",
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
{},
|
{}, // detection path
|
||||||
"RGL");
|
"RGL",
|
||||||
result->setEnvironmentVariableName(envVar);
|
envVar);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createStm32CubeProgrammerPackage()
|
static McuPackage *createStm32CubeProgrammerPackage()
|
||||||
@@ -247,15 +236,16 @@ static McuPackage *createStm32CubeProgrammerPackage()
|
|||||||
if (programPath.exists())
|
if (programPath.exists())
|
||||||
defaultPath = programPath;
|
defaultPath = programPath;
|
||||||
}
|
}
|
||||||
auto result = new McuPackage(
|
auto result
|
||||||
McuPackage::tr("STM32CubeProgrammer"),
|
= new McuPackage(McuPackage::tr("STM32CubeProgrammer"),
|
||||||
defaultPath,
|
defaultPath,
|
||||||
QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "/bin/STM32_Programmer_CLI.exe"
|
QLatin1String(Utils::HostOsInfo::isWindowsHost()
|
||||||
: "/bin/STM32_Programmer.sh"),
|
? "/bin/STM32_Programmer_CLI.exe"
|
||||||
"Stm32CubeProgrammer");
|
: "/bin/STM32_Programmer.sh"), // detection path
|
||||||
|
"Stm32CubeProgrammer",
|
||||||
|
{}, // env var
|
||||||
|
"https://www.st.com/en/development-tools/stm32cubeprog.html"); // download url
|
||||||
result->setRelativePathModifier("/bin");
|
result->setRelativePathModifier("/bin");
|
||||||
result->setDownloadUrl(
|
|
||||||
"https://www.st.com/en/development-tools/stm32cubeprog.html");
|
|
||||||
result->setAddToPath(true);
|
result->setAddToPath(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -283,14 +273,13 @@ static McuPackage *createMcuXpressoIdePackage()
|
|||||||
defaultPath = programPath;
|
defaultPath = programPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = new McuPackage(
|
return new McuPackage("MCUXpresso IDE",
|
||||||
"MCUXpresso IDE",
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("ide/binaries/crt_emu_cm_redlink"),
|
Utils::HostOsInfo::withExecutableSuffix(
|
||||||
"MCUXpressoIDE");
|
"ide/binaries/crt_emu_cm_redlink"), // detection path
|
||||||
result->setDownloadUrl("https://www.nxp.com/mcuxpresso/ide");
|
"MCUXpressoIDE", // settings key
|
||||||
result->setEnvironmentVariableName(envVar);
|
envVar,
|
||||||
return result;
|
"https://www.nxp.com/mcuxpresso/ide"); // download url
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createCypressProgrammerPackage()
|
static McuPackage *createCypressProgrammerPackage()
|
||||||
@@ -315,8 +304,8 @@ static McuPackage *createCypressProgrammerPackage()
|
|||||||
"Cypress Auto Flash Utility",
|
"Cypress Auto Flash Utility",
|
||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("/bin/openocd"),
|
Utils::HostOsInfo::withExecutableSuffix("/bin/openocd"),
|
||||||
"CypressAutoFlashUtil");
|
"CypressAutoFlashUtil",
|
||||||
result->setEnvironmentVariableName(envVar);
|
envVar);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,8 +331,8 @@ static McuPackage *createRenesasProgrammerPackage()
|
|||||||
"Renesas Flash Programmer",
|
"Renesas Flash Programmer",
|
||||||
defaultPath,
|
defaultPath,
|
||||||
Utils::HostOsInfo::withExecutableSuffix("rfp-cli"),
|
Utils::HostOsInfo::withExecutableSuffix("rfp-cli"),
|
||||||
"RenesasFlashProgrammer");
|
"RenesasFlashProgrammer",
|
||||||
result->setEnvironmentVariableName(envVar);
|
envVar);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,14 +411,13 @@ static McuPackage *createBoardSdkPackage(const McuTargetDescription& desc)
|
|||||||
|
|
||||||
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
|
const auto versionDetector = generatePackageVersionDetector(desc.boardSdk.envVar);
|
||||||
|
|
||||||
auto result = new McuPackage(
|
return new McuPackage(sdkName,
|
||||||
sdkName,
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
{},
|
{}, // detection path
|
||||||
desc.boardSdk.envVar,
|
desc.boardSdk.envVar, // settings key
|
||||||
|
desc.boardSdk.envVar, // env var
|
||||||
|
{}, // download URL
|
||||||
versionDetector);
|
versionDetector);
|
||||||
result->setEnvironmentVariableName(desc.boardSdk.envVar);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const FilePath &boardSdkDir,
|
static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const FilePath &boardSdkDir,
|
||||||
@@ -443,14 +431,12 @@ static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, const Fil
|
|||||||
else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty())
|
else if (!boardSdkDir.isEmpty() && !freeRTOSBoardSdkSubDir.isEmpty())
|
||||||
defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir;
|
defaultPath = boardSdkDir / freeRTOSBoardSdkSubDir;
|
||||||
|
|
||||||
auto result = new McuPackage(
|
return new McuPackage(QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix),
|
||||||
QString::fromLatin1("FreeRTOS Sources (%1)").arg(envVarPrefix),
|
|
||||||
defaultPath,
|
defaultPath,
|
||||||
{},
|
{},
|
||||||
QString::fromLatin1("FreeRTOSSourcePackage_%1").arg(envVarPrefix));
|
QString::fromLatin1("FreeRTOSSourcePackage_%1").arg(envVarPrefix),
|
||||||
result->setDownloadUrl("https://freertos.org");
|
envVar,
|
||||||
result->setEnvironmentVariableName(envVar);
|
"https://freertos.org");
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct McuTargetFactory
|
struct McuTargetFactory
|
||||||
|
Reference in New Issue
Block a user