forked from qt-creator/qt-creator
McuSupport: Unify, simplify and improve kit name creation
Change-Id: I27ffa3d89226eedc8396c37249e124f846a630d3 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -425,11 +425,12 @@ static bool isDesktop(const BoardOptions* board)
|
||||
return board->qulPlatform() == "Qt";
|
||||
}
|
||||
|
||||
static void setKitProperties(ProjectExplorer::Kit *k, const BoardOptions* board)
|
||||
static void setKitProperties(const McuSupportOptions *options, ProjectExplorer::Kit *k,
|
||||
const BoardOptions* board)
|
||||
{
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
k->setUnexpandedDisplayName("QtMCU - " + board->model());
|
||||
k->setUnexpandedDisplayName(options->kitName(board));
|
||||
k->setValue(Constants::KIT_BOARD_VENDOR_KEY, board->vendor());
|
||||
k->setValue(Constants::KIT_BOARD_MODEL_KEY, board->model());
|
||||
k->setAutoDetected(false);
|
||||
@@ -527,6 +528,12 @@ static void setKitCMakeOptions(ProjectExplorer::Kit *k, const BoardOptions* boar
|
||||
CMakeGeneratorKitAspect::setGenerator(k, "NMake Makefiles JOM");
|
||||
}
|
||||
|
||||
QString McuSupportOptions::kitName(const BoardOptions *board) const
|
||||
{
|
||||
// TODO: get version from qulSdkPackage and insert into name
|
||||
return QString::fromLatin1("QtMCU - %1 %2").arg(board->vendor(), board->model());
|
||||
}
|
||||
|
||||
ProjectExplorer::Kit *McuSupportOptions::kit(const BoardOptions* board)
|
||||
{
|
||||
using namespace ProjectExplorer;
|
||||
@@ -536,10 +543,10 @@ ProjectExplorer::Kit *McuSupportOptions::kit(const BoardOptions* board)
|
||||
});
|
||||
if (!kit) {
|
||||
const QString armGccPath = toolchainPackage->path();
|
||||
const auto init = [board, &armGccPath](Kit *k) {
|
||||
const auto init = [this, board, &armGccPath](Kit *k) {
|
||||
KitGuard kitGuard(k);
|
||||
|
||||
setKitProperties(k, board);
|
||||
setKitProperties(this, k, board);
|
||||
if (!isDesktop(board)) {
|
||||
setKitToolchains(k, armGccPath);
|
||||
setKitDebugger(k, armGccPath);
|
||||
|
@@ -132,6 +132,8 @@ public:
|
||||
QVector<BoardOptions*> boards;
|
||||
PackageOptions *toolchainPackage = nullptr;
|
||||
|
||||
QString kitName(const BoardOptions* board) const;
|
||||
|
||||
ProjectExplorer::Kit *kit(const BoardOptions* board);
|
||||
|
||||
signals:
|
||||
|
@@ -96,26 +96,22 @@ McuSupportOptionsWidget::McuSupportOptionsWidget(const McuSupportOptions *option
|
||||
showBoardPackages(m_currentBoardIndex);
|
||||
}
|
||||
|
||||
static QString ulOfBoardModels(const QVector<BoardOptions*> &validBoards)
|
||||
{
|
||||
return "<ul><li>"
|
||||
+ Utils::transform<QStringList>(validBoards,[](BoardOptions* board)
|
||||
{return board->model();}).join("</li><li>")
|
||||
+ "</li></ul>";
|
||||
}
|
||||
|
||||
void McuSupportOptionsWidget::updateStatus()
|
||||
{
|
||||
const QVector<BoardOptions*> validBoards = m_options->validBoards();
|
||||
m_statusLabel->setText(validBoards.isEmpty()
|
||||
? McuSupportOptionsPage::tr("No kits can currently be generated. "
|
||||
"Select a target and provide the package paths. "
|
||||
"Afterwards, press Apply to generate a kit for "
|
||||
"your board.")
|
||||
: McuSupportOptionsPage::tr("Kits for the following targets can be generated: "
|
||||
"%1 "
|
||||
"Press Apply to generate a kit for "
|
||||
"your target.").arg(ulOfBoardModels(validBoards)));
|
||||
|
||||
QString list("<ul>");
|
||||
for (auto board : validBoards)
|
||||
list.append("<li>" + m_options->kitName(board) + "</li>");
|
||||
list.append("</ul>");
|
||||
|
||||
m_statusLabel->setText(
|
||||
validBoards.isEmpty()
|
||||
? QString::fromLatin1("No kits can currently be generated. "
|
||||
"Select a target and provide the package paths. "
|
||||
"Afterwards, press Apply to generate a kit for your target.")
|
||||
: QString::fromLatin1("The following Kits can be generated: %1 "
|
||||
"Press Apply to generate a kit for your target.").arg(list));
|
||||
}
|
||||
|
||||
void McuSupportOptionsWidget::showBoardPackages(int boardIndex)
|
||||
|
Reference in New Issue
Block a user