From b0ea4311e8c2394e4ce4d039622ae4182742d6a8 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 14 Aug 2019 11:48:13 +0200 Subject: [PATCH] Short live McuSupport Medium term to be merged with BareMetal/RemoteLinux/... Change-Id: I444c65bcfa8e3cf8642ff64e964459720814860a Reviewed-by: Alessandro Portale --- src/plugins/CMakeLists.txt | 1 + src/plugins/mcusupport/CMakeLists.txt | 12 + src/plugins/mcusupport/McuSupport.json.in | 20 + .../mcusupport/images/mcusupportdevice.png | Bin 0 -> 238 bytes .../mcusupport/images/mcusupportdevice@2x.png | Bin 0 -> 431 bytes .../images/mcusupportdevicesmall.png | Bin 0 -> 163 bytes .../images/mcusupportdevicesmall@2x.png | Bin 0 -> 274 bytes src/plugins/mcusupport/mcusupport.pro | 22 + src/plugins/mcusupport/mcusupport.qbs | 28 + src/plugins/mcusupport/mcusupport.qrc | 13 + .../mcusupport/mcusupport_dependencies.pri | 10 + src/plugins/mcusupport/mcusupport_global.h | 34 + src/plugins/mcusupport/mcusupportconstants.h | 49 ++ src/plugins/mcusupport/mcusupportdevice.cpp | 72 ++ src/plugins/mcusupport/mcusupportdevice.h | 57 ++ .../mcusupport/mcusupportoptionspage.cpp | 672 ++++++++++++++++++ .../mcusupport/mcusupportoptionspage.h | 51 ++ src/plugins/mcusupport/mcusupportplugin.cpp | 89 +++ src/plugins/mcusupport/mcusupportplugin.h | 49 ++ .../mcusupport/mcusupportrunconfiguration.cpp | 91 +++ .../mcusupport/mcusupportrunconfiguration.h | 43 ++ .../wizards/application/CMakeLists.txt | 10 + .../wizards/application/main.qml.tpl | 13 + .../wizards/application/wizard.json | 58 ++ src/plugins/mcusupport/wizards/icon.png | Bin 0 -> 612 bytes src/plugins/mcusupport/wizards/icon@2x.png | Bin 0 -> 1072 bytes src/plugins/plugins.pro | 3 +- src/plugins/plugins.qbs | 1 + src/tools/icons/qtcreatoricons.svg | 258 +++++-- 29 files changed, 1579 insertions(+), 77 deletions(-) create mode 100644 src/plugins/mcusupport/CMakeLists.txt create mode 100644 src/plugins/mcusupport/McuSupport.json.in create mode 100644 src/plugins/mcusupport/images/mcusupportdevice.png create mode 100644 src/plugins/mcusupport/images/mcusupportdevice@2x.png create mode 100644 src/plugins/mcusupport/images/mcusupportdevicesmall.png create mode 100644 src/plugins/mcusupport/images/mcusupportdevicesmall@2x.png create mode 100644 src/plugins/mcusupport/mcusupport.pro create mode 100644 src/plugins/mcusupport/mcusupport.qbs create mode 100644 src/plugins/mcusupport/mcusupport.qrc create mode 100644 src/plugins/mcusupport/mcusupport_dependencies.pri create mode 100644 src/plugins/mcusupport/mcusupport_global.h create mode 100644 src/plugins/mcusupport/mcusupportconstants.h create mode 100644 src/plugins/mcusupport/mcusupportdevice.cpp create mode 100644 src/plugins/mcusupport/mcusupportdevice.h create mode 100644 src/plugins/mcusupport/mcusupportoptionspage.cpp create mode 100644 src/plugins/mcusupport/mcusupportoptionspage.h create mode 100644 src/plugins/mcusupport/mcusupportplugin.cpp create mode 100644 src/plugins/mcusupport/mcusupportplugin.h create mode 100644 src/plugins/mcusupport/mcusupportrunconfiguration.cpp create mode 100644 src/plugins/mcusupport/mcusupportrunconfiguration.h create mode 100644 src/plugins/mcusupport/wizards/application/CMakeLists.txt create mode 100644 src/plugins/mcusupport/wizards/application/main.qml.tpl create mode 100644 src/plugins/mcusupport/wizards/application/wizard.json create mode 100644 src/plugins/mcusupport/wizards/icon.png create mode 100644 src/plugins/mcusupport/wizards/icon@2x.png diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index d1eae35d24a..8d3f734c2b6 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -85,3 +85,4 @@ add_subdirectory(boot2qt) add_subdirectory(qmldesigner) add_subdirectory(qnx) add_subdirectory(webassembly) +add_subdirectory(mcusupport) diff --git a/src/plugins/mcusupport/CMakeLists.txt b/src/plugins/mcusupport/CMakeLists.txt new file mode 100644 index 00000000000..deed8605aec --- /dev/null +++ b/src/plugins/mcusupport/CMakeLists.txt @@ -0,0 +1,12 @@ +add_qtc_plugin(McuSupport + DEPENDS Qt5::Core + PLUGIN_DEPENDS Core ProjectExplorer CMakeProjectManager + SOURCES + mcusupport.qrc + mcusupport_global.h + mcusupportconstants.h + mcusupportdevice.cpp mcusupportdevice.h + mcusupportoptionspage.cpp mcusupportoptionspage.h + mcusupportplugin.cpp mcusupportplugin.h + mcusupportrunconfiguration.cpp mcusupportrunconfiguration.h +) diff --git a/src/plugins/mcusupport/McuSupport.json.in b/src/plugins/mcusupport/McuSupport.json.in new file mode 100644 index 00000000000..a2f42400394 --- /dev/null +++ b/src/plugins/mcusupport/McuSupport.json.in @@ -0,0 +1,20 @@ +{ + \"Name\" : \"McuSupport\", + \"Version\" : \"$$QTCREATOR_VERSION\", + \"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\", + \"Experimental\" : true, + \"Vendor\" : \"The Qt Company Ltd\", + \"Copyright\" : \"(C) $$QTCREATOR_COPYRIGHT_YEAR The Qt Company Ltd\", + \"License\" : [ \"Commercial Usage\", + \"\", + \"Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt 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.\", + \"\", + \"GNU General Public License Usage\", + \"\", + \"Alternatively, this plugin 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 plugin. 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.\" + ], + \"Category\" : \"Device Support\", + \"Description\" : \"Helper for MCU related projects.\", + \"Url\" : \"http://www.qt.io\", + $$dependencyList +} diff --git a/src/plugins/mcusupport/images/mcusupportdevice.png b/src/plugins/mcusupport/images/mcusupportdevice.png new file mode 100644 index 0000000000000000000000000000000000000000..821be66aa4fe6e55694b2d6665d1b2f4bc352999 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0y~yU{C^K4h9AW26>$jIR*xXt)4E9Ar_~TfA|X+@Pw)I zcyyF`eJeIlVC?%l!;6peh`BJ5t}s3nTOg!x zz<|}0mAOq*K$VB5?)$r+%wLm&nT&tUneoDs%|O20m4~NaLPE~S;P3JDi_C0ow=Jd| z(6L&$u4+!>!{tK8dEGkS?7dSHGVIqi-Bw~_`^%ePZ~b5k2gi*CS{tHU%$Yj6j~#B( n=u`|W(6{vLsykWjky6dD>P`N!vnNXbgFNEt>gTe~DWM4fuLDtK literal 0 HcmV?d00001 diff --git a/src/plugins/mcusupport/images/mcusupportdevice@2x.png b/src/plugins/mcusupport/images/mcusupportdevice@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b516eb127b6df389785a1839b82706a42906134d GIT binary patch literal 431 zcmeAS@N?(olHy`uVBq!ia0y~yU~mCp4h9AW2HA=;c?=AUWu7jMArXg@fB3T=FvvQw zLXkO-gPFOk=*k2}vnNyanEe)f?6Gi;du8x|(MrG5kmUv6#7S&23qoXOM@x7ZF}G_< zw7oFsm}>TbacL5d6$@`-!hvkI3nFJC4kdXoGdff|CrsoBechnjq}b-bAlQ~*+Ppzg zSY?I;Z=J%O_1-p1z*{I=sF|9<#s)k7 zy>HJ{vMh7>a`OBc9v&ZgzlkXvyUOM6GEFp>W8xIsboj|_Q-R8t(ynbaY|=$ftzFyh z>}CFTj(ZZ1BmWI&drL`)i2d>mMl=8Yd7h@AUAF4~_2S~NKl-d2@%<@oW-t?B3Ibhlr>oI+gA?fLWc)0y?g%7R+^&i$$S za^GD=H2$D~=h3D5@z3pRSm4u#7IUs@@?Z5DI!4QmzMh5F2A z)_)gPC|@C@e%-U%KJeCxYr%HQ2SKa}X=*D3jEk8K=4v>&v@lfM zHn>%F;3H4N7Ul+rE+;01iwBZjQy7F5x24Klw^EUupxWWhYZJD_oMHKvgAeyHMP7O! z&|$cVnXhd7`qCM>hc4Vutx>-AyI@EC*8I<`$39P7EjurD?b}t`)`Z{v{A*V<|1mdKI;Vst0F-HMYXATM literal 0 HcmV?d00001 diff --git a/src/plugins/mcusupport/mcusupport.pro b/src/plugins/mcusupport/mcusupport.pro new file mode 100644 index 00000000000..9bb79364f86 --- /dev/null +++ b/src/plugins/mcusupport/mcusupport.pro @@ -0,0 +1,22 @@ +include(../../qtcreatorplugin.pri) + +DEFINES += MCUSUPPORT_LIBRARY + +QT += gui network + +HEADERS += \ + mcusupport_global.h \ + mcusupportconstants.h \ + mcusupportdevice.h \ + mcusupportoptionspage.h \ + mcusupportplugin.h \ + mcusupportrunconfiguration.h + +SOURCES += \ + mcusupportdevice.cpp \ + mcusupportoptionspage.cpp \ + mcusupportplugin.cpp \ + mcusupportrunconfiguration.cpp + +RESOURCES += \ + mcusupport.qrc diff --git a/src/plugins/mcusupport/mcusupport.qbs b/src/plugins/mcusupport/mcusupport.qbs new file mode 100644 index 00000000000..cb8ef1afcee --- /dev/null +++ b/src/plugins/mcusupport/mcusupport.qbs @@ -0,0 +1,28 @@ +import qbs 1.0 + +QtcPlugin { + name: "McuSupport" + + Depends { name: "Qt.core" } + Depends { name: "Qt.widgets" } + Depends { name: "Utils" } + + Depends { name: "Core" } + Depends { name: "ProjectExplorer" } + Depends { name: "CMakeProjectManager" } + Depends { name: "QtSupport" } + + files: [ + "mcusupport.qrc", + "mcusupport_global.h", + "mcusupportconstants.h", + "mcusupportdevice.cpp", + "mcusupportdevice.h", + "mcusupportoptionspage.cpp", + "mcusupportoptionspage.h", + "mcusupportplugin.cpp", + "mcusupportplugin.h", + "mcusupportrunconfiguration.cpp", + "mcusupportrunconfiguration.h", + ] +} diff --git a/src/plugins/mcusupport/mcusupport.qrc b/src/plugins/mcusupport/mcusupport.qrc new file mode 100644 index 00000000000..c38ede5929c --- /dev/null +++ b/src/plugins/mcusupport/mcusupport.qrc @@ -0,0 +1,13 @@ + + + images/mcusupportdevice.png + images/mcusupportdevice@2x.png + images/mcusupportdevicesmall.png + images/mcusupportdevicesmall@2x.png + wizards/icon.png + wizards/icon@2x.png + wizards/application/CMakeLists.txt + wizards/application/main.qml.tpl + wizards/application/wizard.json + + diff --git a/src/plugins/mcusupport/mcusupport_dependencies.pri b/src/plugins/mcusupport/mcusupport_dependencies.pri new file mode 100644 index 00000000000..b6fd4f9e6b6 --- /dev/null +++ b/src/plugins/mcusupport/mcusupport_dependencies.pri @@ -0,0 +1,10 @@ +QTC_PLUGIN_NAME = McuSupport + +QTC_LIB_DEPENDS += \ + extensionsystem \ + utils + +QTC_PLUGIN_DEPENDS += \ + coreplugin \ + projectexplorer \ + cmakeprojectmanager diff --git a/src/plugins/mcusupport/mcusupport_global.h b/src/plugins/mcusupport/mcusupport_global.h new file mode 100644 index 00000000000..3039bf660b6 --- /dev/null +++ b/src/plugins/mcusupport/mcusupport_global.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 + +#if defined(MCUSUPPORT_LIBRARY) +# define MCUSUPPORTSHARED_EXPORT Q_DECL_EXPORT +#else +# define MCUSUPPORTSHARED_EXPORT Q_DECL_IMPORT +#endif diff --git a/src/plugins/mcusupport/mcusupportconstants.h b/src/plugins/mcusupport/mcusupportconstants.h new file mode 100644 index 00000000000..2cc5bee41a1 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportconstants.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 + +namespace McuSupport { +namespace Constants { + +const char TOOLCHAIN_TYPEID[] = "McuSupport.ToolChain.ARM-GCC"; +const char DEVICE_TYPE[] = "McuSupport.DeviceType"; +const char DEVICE_ID[] = "McuSupport.Device"; +const char MCUSUPPORT_QT_VERSION[] = "Qt4ProjectManager.QtVersion.McuSupport"; +const char RUNCONFIGURATION[] = "McuSupport.RunConfiguration"; +const char SETTINGS_ID[] = "CC.McuSupport.Configuration"; +const char KIT_BOARD_MODEL_KEY[] = "McuSupport.BoardModel"; + +const char ENVVAR_ARMGCC_DIR[] = "ARMGCC_DIR"; +const char ENVVAR_STM32CUBE_FW_F7_SDK_PATH[] = "STM32Cube_FW_F7_SDK_PATH"; + +const char SETTINGS_GROUP[] = "McuSupport"; +const char SETTINGS_KEY_PACKAGE_PREFIX[] = "package_"; +const char SETTINGS_KEY_PACKAGE_ARMGCC[] = "ArmGcc"; +const char SETTINGS_KEY_STM32CUBE_FW_F7_SDK_PATH[] = "STM32Cube_FW_F7_SDK_PATH"; +const char SETTINGS_KEY_STM32CUBE_PROGRAMMER_PATH[] = "STM32Cube_Cube_Programmer_Path"; + +} // namespace McuSupport +} // namespace Constants diff --git a/src/plugins/mcusupport/mcusupportdevice.cpp b/src/plugins/mcusupport/mcusupportdevice.cpp new file mode 100644 index 00000000000..17fb3d2471c --- /dev/null +++ b/src/plugins/mcusupport/mcusupportdevice.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 "mcusupportdevice.h" + +#include +#include + +using namespace ProjectExplorer; +using namespace Utils; + +namespace McuSupport { +namespace Internal { + +McuSupportDevice::McuSupportDevice() +{ + setupId(IDevice::AutoDetected, Constants::DEVICE_ID); + setType(Constants::DEVICE_TYPE); + const QString displayNameAndType = tr("MCU Device"); + setDefaultDisplayName(displayNameAndType); + setDisplayType(displayNameAndType); + setDeviceState(IDevice::DeviceStateUnknown); + setMachineType(IDevice::Hardware); + setOsType(Utils::OsTypeOther); +} + +ProjectExplorer::IDevice::Ptr McuSupportDevice::create() +{ + auto device = new McuSupportDevice; + return ProjectExplorer::IDevice::Ptr(device); +} + +McuSupportDeviceFactory::McuSupportDeviceFactory() + : ProjectExplorer::IDeviceFactory(Constants::DEVICE_TYPE) +{ + setDisplayName(tr("MCU Device")); + setCombinedIcon(":/mcusupport/images/mcusupportdevicesmall.png", + ":/mcusupport/images/mcusupportdevice.png"); + setCanCreate(true); + setConstructionFunction(&McuSupportDevice::create); +} + +ProjectExplorer::IDevice::Ptr McuSupportDeviceFactory::create() const +{ + return McuSupportDevice::create(); +} + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportdevice.h b/src/plugins/mcusupport/mcusupportdevice.h new file mode 100644 index 00000000000..50c505eb489 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportdevice.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 + +#include + +namespace McuSupport { +namespace Internal { + +class McuSupportDevice : public ProjectExplorer::DesktopDevice +{ + Q_DECLARE_TR_FUNCTIONS(McuSupport::Internal::McuSupportDevice) + +public: + static ProjectExplorer::IDevice::Ptr create(); + +private: + McuSupportDevice(); +}; + +class McuSupportDeviceFactory : public ProjectExplorer::IDeviceFactory +{ + Q_OBJECT + +public: + McuSupportDeviceFactory(); + + ProjectExplorer::IDevice::Ptr create() const override; +}; + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportoptionspage.cpp b/src/plugins/mcusupport/mcusupportoptionspage.cpp new file mode 100644 index 00000000000..4e1b6fda893 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportoptionspage.cpp @@ -0,0 +1,672 @@ +/**************************************************************************** +** +** 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 "mcusupportoptionspage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace McuSupport { +namespace Internal { + +class PackageOptions : public QObject +{ + Q_OBJECT + +public: + enum Status { + InvalidPath, + ValidPathInvalidPackage, + ValidPackage + }; + + PackageOptions(const QString &label, const QString &defaultPath, const QString &detectionPath, + const QString &settingsKey); + + QString path() const; + QString label() const; + QString detectionPath() const; + Status status() const; + void setDownloadUrl(const QUrl &url); + void setEnvironmentVariableName(const QString &name); + void setAddToPath(bool addToPath); + bool addToPath() const; + void writeToSettings() const; + + QWidget *widget(); + + + QString environmentVariableName() const; + +signals: + void changed(); + +private: + void updateStatus(); + + QWidget *m_widget = nullptr; + Utils::PathChooser *m_fileChooser = nullptr; + QLabel *m_statusIcon = nullptr; + QLabel *m_statusLabel = nullptr; + + const QString m_label; + const QString m_defaultPath; + const QString m_detectionPath; + const QString m_settingsKey; + + QString m_path; + QUrl m_downloadUrl; + QString m_environmentVariableName; + bool m_addToPath = false; + + Status m_status = InvalidPath; +}; + +PackageOptions::PackageOptions(const QString &label, const QString &defaultPath, + const QString &detectionPath, const QString &settingsKey) + : m_label(label) + , m_defaultPath(defaultPath) + , m_detectionPath(detectionPath) + , m_settingsKey(settingsKey) +{ + QSettings *s = Core::ICore::settings(); + s->beginGroup(Constants::SETTINGS_GROUP); + m_path = s->value(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey, + m_defaultPath).toString(); + s->endGroup(); +} + +QString PackageOptions::path() const +{ + return m_fileChooser->path(); +} + +QString PackageOptions::label() const +{ + return m_label; +} + +QString PackageOptions::detectionPath() const +{ + return m_detectionPath; +} + +QWidget *PackageOptions::widget() +{ + if (m_widget) + return m_widget; + + m_widget = new QWidget; + m_fileChooser = new Utils::PathChooser; + QObject::connect(m_fileChooser, &Utils::PathChooser::pathChanged, + [this](){ + updateStatus(); + emit changed(); + }); + + auto layout = new QGridLayout(m_widget); + layout->setContentsMargins(0, 0, 0, 0); + m_statusIcon = new QLabel; + m_statusIcon->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); + m_statusIcon->setAlignment(Qt::AlignTop); + m_statusLabel = new QLabel; + m_statusLabel->setWordWrap(true); + m_statusLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); + + if (!m_downloadUrl.isEmpty()) { + auto downLoadButton = new QToolButton; + downLoadButton->setIcon(Utils::Icons::DOWNLOAD.icon()); + downLoadButton->setToolTip(McuSupportOptionsPage::tr("Download from \"%1\"") + .arg(m_downloadUrl.toString())); + QObject::connect(downLoadButton, &QToolButton::pressed, [this]{ + QDesktopServices::openUrl(m_downloadUrl); + }); + layout->addWidget(downLoadButton, 0, 2); + } + + layout->addWidget(m_fileChooser, 0, 0, 1, 2); + layout->addWidget(m_statusIcon, 1, 0); + layout->addWidget(m_statusLabel, 1, 1, 1, -1); + + m_fileChooser->setPath(m_path); // Triggers updateStatus() call + return m_widget; +} + +PackageOptions::Status PackageOptions::status() const +{ + return m_status; +} + +void PackageOptions::setDownloadUrl(const QUrl &url) +{ + m_downloadUrl = url; +} + +void PackageOptions::setEnvironmentVariableName(const QString &name) +{ + m_environmentVariableName = name; +} + +QString PackageOptions::environmentVariableName() const +{ + return m_environmentVariableName; +} + +void PackageOptions::setAddToPath(bool addToPath) +{ + m_addToPath = addToPath; +} + +bool PackageOptions::addToPath() const +{ + return m_addToPath; +} + +void PackageOptions::writeToSettings() const +{ + if (m_path.compare(m_defaultPath) == 0) + return; + QSettings *s = Core::ICore::settings(); + s->beginGroup(Constants::SETTINGS_GROUP); + s->setValue(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey, m_path); + s->endGroup(); +} + +void PackageOptions::updateStatus() +{ + m_path = m_fileChooser->rawPath(); + const bool validPath = m_fileChooser->isValid(); + const Utils::FilePath detectionPath = Utils::FilePath::fromString( + m_fileChooser->path() + "/" + m_detectionPath); + const QString displayDetectionPath = Utils::FilePath::fromString(m_detectionPath).toUserOutput(); + const bool validPackage = detectionPath.exists(); + + m_status = validPath ? (validPackage ? ValidPackage : ValidPathInvalidPackage) : InvalidPath; + + static const QPixmap okIcon = Utils::Icons::OK.pixmap(); + static const QPixmap notOkIcon = Utils::Icons::BROKEN.pixmap(); + m_statusIcon->setPixmap(m_status == ValidPackage ? okIcon : notOkIcon); + + QString statusText; + switch (m_status) { + case ValidPackage: + statusText = McuSupportOptionsPage::tr( + "Path is valid, \"%1\" was found.").arg(displayDetectionPath); + break; + case ValidPathInvalidPackage: + statusText = McuSupportOptionsPage::tr( + "Path exists, but does not contain \"%1\".").arg(displayDetectionPath); + break; + case InvalidPath: + statusText = McuSupportOptionsPage::tr("Path does not exist."); + break; + } + m_statusLabel->setText(statusText); +} + +class BoardOptions : public QObject +{ + Q_OBJECT + +public: + BoardOptions(const QString &model, const QString &toolChainFile, + const QVector &packages); + + QString model() const; + QString toolChainFile() const; + QVector packages() const; + +private: + const QString m_model; + const QString m_toolChainFile; + const QVector m_packages; +}; + +BoardOptions::BoardOptions(const QString &model, const QString &toolChainFileName, + const QVector &packages) + : m_model(model) + , m_toolChainFile(toolChainFileName) + , m_packages(packages) +{ +} + +QString BoardOptions::model() const +{ + return m_model; +} + +QString BoardOptions::toolChainFile() const +{ + return m_toolChainFile; +} + +QVector BoardOptions::packages() const +{ + return m_packages; +} + +class McuSupportOptions : public QObject +{ + Q_OBJECT + +public: + McuSupportOptions(QObject *parent = nullptr); + ~McuSupportOptions() override; + + QVector validBoards() const; + + QVector packages; + QVector boards; + PackageOptions* toolchainPackage = nullptr; + +signals: + void changed(); +}; + +McuSupportOptions::McuSupportOptions(QObject *parent) + : QObject(parent) +{ + auto qulPackage = new PackageOptions( + McuSupportOptionsPage::tr("Qt MCU SDK"), + QDir::homePath(), + Utils::HostOsInfo::withExecutableSuffix("bin/qmltocpp"), + "qulSdk"); + qulPackage->setEnvironmentVariableName("Qul_DIR"); + + const QString armGccDefaultPath = + Utils::HostOsInfo::isWindowsHost() ? + QDir::fromNativeSeparators(qEnvironmentVariable("ProgramFiles(x86)")) + + "/GNU Tools ARM Embedded/" + : QString("%{Env:ARMGCC_DIR}"); + auto armGcc = new PackageOptions( + McuSupportOptionsPage::tr("GNU Arm Embedded Toolchain"), + armGccDefaultPath, + Utils::HostOsInfo::withExecutableSuffix("bin/arm-none-eabi-g++"), + Constants::SETTINGS_KEY_PACKAGE_ARMGCC); + armGcc->setDownloadUrl( + QUrl::fromUserInput("https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads")); + armGcc->setEnvironmentVariableName("ARMGCC_DIR"); + toolchainPackage = armGcc; + + auto stm32CubeFwF7Sdk = new PackageOptions( + McuSupportOptionsPage::tr("STM32Cube SDK"), + "%{Env:STM32Cube_FW_F7_SDK_PATH}", + "Drivers/STM32F7xx_HAL_Driver", + "stm32CubeFwF7Sdk"); + stm32CubeFwF7Sdk->setDownloadUrl( + QUrl::fromUserInput("https://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef7.html")); + stm32CubeFwF7Sdk->setEnvironmentVariableName("STM32Cube_FW_F7_SDK_PATH"); + + const QString stm32CubeProgrammerDefaultPath = + Utils::HostOsInfo::isWindowsHost() ? + QDir::fromNativeSeparators(qEnvironmentVariable("ProgramFiles")) + + "/STMicroelectronics/STM32Cube/STM32CubeProgrammer/" + : QDir::homePath(); + auto stm32CubeProgrammer = new PackageOptions( + McuSupportOptionsPage::tr("STM32CubeProgrammer"), + stm32CubeProgrammerDefaultPath, + "bin", + "stm32CubeProgrammer"); + stm32CubeProgrammer->setDownloadUrl( + QUrl::fromUserInput("https://www.st.com/en/development-tools/stm32cubeprog.html")); + stm32CubeProgrammer->setAddToPath(true); + + auto evkbImxrt1050Sdk = new PackageOptions( + McuSupportOptionsPage::tr("NXP EVKB-IMXRT1050 SDK"), + "%{Env:EVKB_IMXRT1050_SDK_PATH}", + "EVKB-IMXRT1050_manifest_v3_5.xml", + "evkbImxrt1050Sdk"); + evkbImxrt1050Sdk->setDownloadUrl( + QUrl::fromUserInput("https://mcuxpresso.nxp.com/en/welcome")); + + const QString seggerJLinkDefaultPath = + Utils::HostOsInfo::isWindowsHost() ? + QDir::fromNativeSeparators(qEnvironmentVariable("ProgramFiles")) + "/SEGGER/JLink" + : QString("%{Env:SEGGER_JLINK_SOFTWARE_AND_DOCUMENTATION_PATH}"); + auto seggerJLink = new PackageOptions( + McuSupportOptionsPage::tr("SEGGER JLink"), + seggerJLinkDefaultPath, + Utils::HostOsInfo::withExecutableSuffix("JLink"), + "seggerJLink"); + seggerJLink->setDownloadUrl( + QUrl::fromUserInput("https://www.segger.com/downloads/jlink")); + + auto stmPackages = {armGcc, stm32CubeFwF7Sdk, stm32CubeProgrammer, qulPackage}; + auto nxpPackages = {armGcc, evkbImxrt1050Sdk, seggerJLink, qulPackage}; + packages = {armGcc, stm32CubeFwF7Sdk, stm32CubeProgrammer, + evkbImxrt1050Sdk, seggerJLink, + qulPackage}; + + boards.append(new BoardOptions( + "stm32f7508", "CMake/stm32f7508-discovery.cmake", stmPackages)); + boards.append(new BoardOptions( + "stm32f769i", "CMake/stm32f769i-discovery.cmake", stmPackages)); + boards.append(new BoardOptions( + "evkbimxrt1050", "CMake/evkbimxrt1050-toolchain.cmake", nxpPackages)); + + for (auto package : packages) + connect(package, &PackageOptions::changed, [this](){ + emit changed(); + }); +} + +McuSupportOptions::~McuSupportOptions() +{ + qDeleteAll(packages); + packages.clear(); + qDeleteAll(boards); + boards.clear(); +} + +QVector McuSupportOptions::validBoards() const +{ + return Utils::filtered(boards, [](BoardOptions *board){ + return !Utils::anyOf(board->packages(), [](PackageOptions *package){ + return package->status() != PackageOptions::ValidPackage;}); + }); +} + +class McuSupportOptionsWidget : public QWidget +{ +public: + McuSupportOptionsWidget(const McuSupportOptions *options, QWidget *parent = nullptr); + + void updateStatus(); + void showBoardPackages(int boardIndex); + +private: + QString m_armGccPath; + const McuSupportOptions *m_options; + int m_currentBoardIndex = 0; + QMap m_packageWidgets; + QMap m_boardPacketWidgets; + QFormLayout *m_packagesLayout = nullptr; + QLabel *m_statusLabel = nullptr; +}; + +McuSupportOptionsWidget::McuSupportOptionsWidget(const McuSupportOptions *options, QWidget *parent) + : QWidget(parent) + , m_options(options) +{ + auto mainLayout = new QVBoxLayout(this); + + auto boardChooserlayout = new QHBoxLayout; + auto boardChooserLabel = new QLabel(McuSupportOptionsPage::tr("MCU board:")); + boardChooserlayout->addWidget(boardChooserLabel); + auto boardComboBox = new QComboBox; + boardChooserLabel->setBuddy(boardComboBox); + boardChooserLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + boardComboBox->addItems(Utils::transform(m_options->boards, [](BoardOptions *b){ + return b->model();})); + boardChooserlayout->addWidget(boardComboBox); + mainLayout->addLayout(boardChooserlayout); + + auto m_packagesGroupBox = new QGroupBox(McuSupportOptionsPage::tr("Packages")); + mainLayout->addWidget(m_packagesGroupBox); + m_packagesLayout = new QFormLayout; + m_packagesGroupBox->setLayout(m_packagesLayout); + + m_statusLabel = new QLabel; + mainLayout->addWidget(m_statusLabel); + m_statusLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + m_statusLabel->setWordWrap(true); + m_statusLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); + + connect(options, &McuSupportOptions::changed, this, &McuSupportOptionsWidget::updateStatus); + connect(boardComboBox, QOverload::of(&QComboBox::currentIndexChanged), + this, &McuSupportOptionsWidget::showBoardPackages); + + showBoardPackages(m_currentBoardIndex); +} + +static QString ulOfBoardModels(const QVector &validBoards) +{ + return "
  • " + + Utils::transform(validBoards,[](BoardOptions* board) + {return board->model();}).join("
  • ") + + "
"; +} + +void McuSupportOptionsWidget::updateStatus() +{ + const QVector validBoards = m_options->validBoards(); + m_statusLabel->setText(validBoards.isEmpty() + ? McuSupportOptionsPage::tr("No devices and kits can currently be generated. " + "Select a board and provide the package paths. " + "Afterwards, press Apply to generate device and kit for " + "your board.") + : McuSupportOptionsPage::tr("Devices and kits for the following boards can be generated: " + "%1 " + "Press Apply to generate device and kit for " + "your board.").arg(ulOfBoardModels(validBoards))); +} + +void McuSupportOptionsWidget::showBoardPackages(int boardIndex) +{ + while (m_packagesLayout->rowCount() > 0) { + QFormLayout::TakeRowResult row = m_packagesLayout->takeRow(0); + row.labelItem->widget()->hide(); + row.fieldItem->widget()->hide(); + } + + const BoardOptions *currentBoard = m_options->boards.at(boardIndex); + + for (auto package : m_options->packages) { + QWidget *packageWidget = package->widget(); + if (!currentBoard->packages().contains(package)) + continue; + m_packagesLayout->addRow(package->label(), packageWidget); + packageWidget->show(); + } +} + +McuSupportOptionsPage::McuSupportOptionsPage(QObject* parent) + : Core::IOptionsPage(parent) +{ + setId(Core::Id(Constants::SETTINGS_ID)); + setDisplayName(tr("MCU")); + setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY); +} + +QWidget* McuSupportOptionsPage::widget() +{ + if (!m_options) + m_options = new McuSupportOptions(this); + if (!m_widget) + m_widget = new McuSupportOptionsWidget(m_options); + return m_widget; +} + +static ProjectExplorer::ToolChain* armGccToolchain(const Utils::FilePath &path, Core::Id language) +{ + using namespace ProjectExplorer; + + ToolChain *toolChain = ToolChainManager::toolChain([&path, language](const ToolChain *t){ + return t->compilerCommand() == path && t->language() == language; + }); + if (!toolChain) { + ToolChainFactory *gccFactory = + Utils::findOrDefault(ToolChainFactory::allToolChainFactories(), [](ToolChainFactory *f){ + return f->supportedToolChainType() == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID; + }); + if (gccFactory) { + const QList detected = gccFactory->detectForImport({path, language}); + if (!detected.isEmpty()) { + toolChain = detected.first(); + toolChain->setDetection(ToolChain::ManualDetection); + toolChain->setDisplayName("Arm GCC"); + ToolChainManager::registerToolChain(toolChain); + } + } + } + + return toolChain; +} + +static void setKitProperties(ProjectExplorer::Kit *k, const BoardOptions* board) +{ + using namespace ProjectExplorer; + + k->setUnexpandedDisplayName("Qt MCU - " + board->model()); + k->setValue(Constants::KIT_BOARD_MODEL_KEY, board->model()); + k->setAutoDetected(false); + k->setIrrelevantAspects({ + SysRootKitAspect::id(), + "QtSupport.QtInformation" // QtKitAspect::id() + }); +} + +static void setKitToolchains(ProjectExplorer::Kit *k, const QString &armGccPath) +{ + using namespace ProjectExplorer; + + const QString compileNameScheme = Utils::HostOsInfo::withExecutableSuffix( + armGccPath + "/bin/arm-none-eabi-%1"); + ToolChain *cTc = armGccToolchain( + Utils::FilePath::fromUserInput(compileNameScheme.arg("gcc")), + ProjectExplorer::Constants::C_LANGUAGE_ID); + ToolChain *cxxTc = armGccToolchain( + Utils::FilePath::fromUserInput(compileNameScheme.arg("g++")), + ProjectExplorer::Constants::CXX_LANGUAGE_ID); + ToolChainKitAspect::setToolChain(k, cTc); + ToolChainKitAspect::setToolChain(k, cxxTc); +} + +static void setKitDevice(ProjectExplorer::Kit *k) +{ + using namespace ProjectExplorer; + + DeviceTypeKitAspect::setDeviceTypeId(k, Constants::DEVICE_TYPE); +} + +static void setKitEnvironment(ProjectExplorer::Kit *k, const BoardOptions* board) +{ + using namespace ProjectExplorer; + + Utils::EnvironmentItems changes; + QStringList pathAdditions; + for (auto package : board->packages()) { + if (package->addToPath()) + pathAdditions.append(QDir::toNativeSeparators(package->path())); + if (!package->environmentVariableName().isEmpty()) + changes.append({package->environmentVariableName(), + QDir::toNativeSeparators(package->path())}); + } + if (!pathAdditions.isEmpty()) { + pathAdditions.append("${Path}"); + changes.append({"Path", pathAdditions.join(Utils::HostOsInfo::pathListSeparator())}); + } + EnvironmentKitAspect::setEnvironmentChanges(k, changes); +} + +static void setCMakeOptions(ProjectExplorer::Kit *k, const BoardOptions* board) +{ + using namespace CMakeProjectManager; + + CMakeConfig config = CMakeConfigurationKitAspect::configuration(k); + config.append(CMakeConfigItem("CMAKE_TOOLCHAIN_FILE", + ("%{CurrentBuild:Env:Qul_DIR}/" + + board->toolChainFile()).toUtf8())); + CMakeConfigurationKitAspect::setConfiguration(k, config); +} + +static ProjectExplorer::Kit* boardKit(const BoardOptions* board, const QString &armGccPath) +{ + using namespace ProjectExplorer; + + Kit *kit = KitManager::kit([board](const Kit *k){ + return board->model() == k->value(Constants::KIT_BOARD_MODEL_KEY).toString(); + }); + if (!kit) { + const auto init = [board, &armGccPath](Kit *k) { + KitGuard kitGuard(k); + + setKitProperties(k, board); + setKitToolchains(k, armGccPath); + setKitDevice(k); + setKitEnvironment(k, board); + setCMakeOptions(k, board); + + k->setup(); + k->fix(); + }; + kit = KitManager::registerKit(init); + } + return kit; +} + +void McuSupportOptionsPage::apply() +{ + for (auto package : m_options->packages) + package->writeToSettings(); + + QTC_ASSERT(m_options->toolchainPackage, return); + + const QVector validBoards = m_options->validBoards(); + + using namespace ProjectExplorer; + + for (auto board : validBoards) { + Kit *kit = boardKit(board, m_options->toolchainPackage->path()); + } +} + +void McuSupportOptionsPage::finish() +{ + delete m_options; + m_options = nullptr; + delete m_widget; +} + +} // Internal +} // McuSupport + +#include "mcusupportoptionspage.moc" diff --git a/src/plugins/mcusupport/mcusupportoptionspage.h b/src/plugins/mcusupport/mcusupportoptionspage.h new file mode 100644 index 00000000000..6d92142e005 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportoptionspage.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 + +#include + +namespace McuSupport { +namespace Internal { + +class McuSupportOptionsPage : public Core::IOptionsPage +{ + Q_OBJECT + +public: + explicit McuSupportOptionsPage(QObject *parent = nullptr); + QWidget *widget() override; + void apply() override; + void finish() override; + +private: + QPointer m_widget; + class McuSupportOptions *m_options = nullptr; +}; + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportplugin.cpp b/src/plugins/mcusupport/mcusupportplugin.cpp new file mode 100644 index 00000000000..68ec688c5f2 --- /dev/null +++ b/src/plugins/mcusupport/mcusupportplugin.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 "mcusupportplugin.h" +#include "mcusupportconstants.h" +#include "mcusupportdevice.h" +#include "mcusupportoptionspage.h" +#include "mcusupportrunconfiguration.h" + +#include +#include +#include + +#include +#include + +using namespace ProjectExplorer; + +namespace McuSupport { +namespace Internal { + +class McuSupportPluginPrivate +{ +public: + McuSupportDeviceFactory deviceFactory; + EmrunRunConfigurationFactory emrunRunConfigurationFactory; + RunWorkerFactory emrunRunWorkerFactory{ + makeFlashAndRunWorker(), + {ProjectExplorer::Constants::NORMAL_RUN_MODE}, + {Constants::RUNCONFIGURATION} + }; + McuSupportOptionsPage optionsPage; +}; + +static McuSupportPluginPrivate *dd = nullptr; + +McuSupportPlugin::McuSupportPlugin() +{ + setObjectName("McuSupportPlugin"); +} + +McuSupportPlugin::~McuSupportPlugin() +{ + delete dd; + dd = nullptr; +} + +bool McuSupportPlugin::initialize(const QStringList& arguments, QString* errorString) +{ + Q_UNUSED(arguments) + Q_UNUSED(errorString) + + dd = new McuSupportPluginPrivate; + + ProjectExplorer::JsonWizardFactory::addWizardPath( + Utils::FilePath::fromString(":/mcusupport/wizards/")); + + return true; +} + +void McuSupportPlugin::extensionsInitialized() +{ + ProjectExplorer::DeviceManager::instance()->addDevice(McuSupportDevice::create()); +} + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportplugin.h b/src/plugins/mcusupport/mcusupportplugin.h new file mode 100644 index 00000000000..9a5def94fbb --- /dev/null +++ b/src/plugins/mcusupport/mcusupportplugin.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 "mcusupport_global.h" + +#include + +namespace McuSupport { +namespace Internal { + +class McuSupportPlugin : public ExtensionSystem::IPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "McuSupport.json") + +public: + McuSupportPlugin(); + ~McuSupportPlugin() override; + + bool initialize(const QStringList &arguments, QString *errorString) override; + void extensionsInitialized() override; +}; + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportrunconfiguration.cpp b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp new file mode 100644 index 00000000000..2e05b9ff50d --- /dev/null +++ b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 "mcusupportrunconfiguration.h" +#include "mcusupportconstants.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace Utils; + +namespace McuSupport { +namespace Internal { + +static CommandLine flashAndRunCommand(Target *target) +{ + BuildConfiguration *bc = target->activeBuildConfiguration(); + + return CommandLine(bc->environment().searchInPath("cmake"), {}); +} + +class FlashAndRunConfiguration : public ProjectExplorer::RunConfiguration +{ +public: + FlashAndRunConfiguration(Target *target, Core::Id id) + : RunConfiguration(target, id) + { + auto effectiveFlashAndRunCall = addAspect(); + effectiveFlashAndRunCall->setLabelText(tr("Effective flash and run call:")); + effectiveFlashAndRunCall->setDisplayStyle(BaseStringAspect::TextEditDisplay); + effectiveFlashAndRunCall->setReadOnly(true); + } +}; + +class FlashAndRunWorker : public SimpleTargetRunner +{ +public: + FlashAndRunWorker(RunControl *runControl) + : SimpleTargetRunner(runControl) + { + setStarter([this, runControl] { + CommandLine cmd = flashAndRunCommand(runControl->target()); + Runnable r; + r.setCommandLine(cmd); + SimpleTargetRunner::doStart(r, {}); + }); + } +}; + +RunWorkerFactory::WorkerCreator makeFlashAndRunWorker() +{ + return RunWorkerFactory::make(); +} + +EmrunRunConfigurationFactory::EmrunRunConfigurationFactory() + : FixedRunConfigurationFactory(FlashAndRunConfiguration::tr("Flash and run")) +{ + registerRunConfiguration(Constants::RUNCONFIGURATION); + addSupportedTargetDeviceType(Constants::DEVICE_TYPE); +} + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/mcusupportrunconfiguration.h b/src/plugins/mcusupport/mcusupportrunconfiguration.h new file mode 100644 index 00000000000..2ab9c65380a --- /dev/null +++ b/src/plugins/mcusupport/mcusupportrunconfiguration.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 +#include + +namespace McuSupport { +namespace Internal { + +class EmrunRunConfigurationFactory : public ProjectExplorer::FixedRunConfigurationFactory +{ +public: + EmrunRunConfigurationFactory(); +}; + +ProjectExplorer::RunWorkerFactory::WorkerCreator makeFlashAndRunWorker(); + +} // namespace Internal +} // namespace McuSupport diff --git a/src/plugins/mcusupport/wizards/application/CMakeLists.txt b/src/plugins/mcusupport/wizards/application/CMakeLists.txt new file mode 100644 index 00000000000..bc7b4523db0 --- /dev/null +++ b/src/plugins/mcusupport/wizards/application/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required (VERSION 3.13) + +project(%{ProjectName} VERSION 0.0.1 LANGUAGES CXX) + +find_package(Qul) + +add_executable(%{ProjectName}) +QUL_ADD_QML(%{ProjectName} %{MainQmlFile}) + +target_link_libraries(%{ProjectName} Qul::QuickUltralite) diff --git a/src/plugins/mcusupport/wizards/application/main.qml.tpl b/src/plugins/mcusupport/wizards/application/main.qml.tpl new file mode 100644 index 00000000000..a9098ee8512 --- /dev/null +++ b/src/plugins/mcusupport/wizards/application/main.qml.tpl @@ -0,0 +1,13 @@ +pragma main; +import QtQuick + +Rectangle { + width: 480 + height: 272 + + Text { + anchors.centerIn: parent + color: "salmon" + text: "Hello World!" + } +} diff --git a/src/plugins/mcusupport/wizards/application/wizard.json b/src/plugins/mcusupport/wizards/application/wizard.json new file mode 100644 index 00000000000..4583b48c2ba --- /dev/null +++ b/src/plugins/mcusupport/wizards/application/wizard.json @@ -0,0 +1,58 @@ +{ + "version": 1, + "supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ], + "id": "A.McuSupportApplication", + "category": "F.Application", + "trDescription": "Creates an Mcu Support application with an empty UI.", + "trDisplayName": "Mcu Support Application", + "trDisplayCategory": "Application", + "icon": "../icon.png", + "enabled": true, + + "options": + [ + { "key": "MainQmlFile", "value": "%{ProjectName}.qml" }, + { "key": "CMakeFile", "value": "%{ProjectDirectory}/CMakeLists.txt" } + ], + + "pages": + [ + { + "trDisplayName": "Project Location", + "trShortTitle": "Location", + "typeId": "Project" + }, + { + "trDisplayName": "Kit Selection", + "trShortTitle": "Kits", + "typeId": "Kits", + "enabled": "%{JS: !value('IsSubproject')}", + "data": { + "projectFilePath": "%{CMakeFile}" + } + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators": + [ + { + "typeId": "File", + "data": + [ + { + "source": "CMakeLists.txt", + "openAsProject": true + }, + { + "source": "main.qml.tpl", + "target": "%{ProjectDirectory}/%{MainQmlFile}", + "openInEditor": true + } + ] + } + ] +} diff --git a/src/plugins/mcusupport/wizards/icon.png b/src/plugins/mcusupport/wizards/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ef9160b74cfda0e5ffbcbb81a4601b4080857c78 GIT binary patch literal 612 zcmeAS@N?(olHy`uVBq!ia0y~yU@!n-4rT@hhJ-tuTNxM_t_JvoxH2#>@PGj~H#Zj- zm!F@XKN!S;Kzw|BLPA1fVq#KCN@{9qdRkgWMn+afW_ET?UQTX7ZeC$teodHC}GqgVeQzyAO9?f(}a z{=fY6|JA4euRs5P{pJ6gFaO_u`~Uv?|Mx%sfBOCZ^Y8!P{{R2}|No!=|Ns35fuE~p z9%5i%;3x_53uX`%laRc0`MTJGFK-zb7|lFg978;gznywAh{;gIRdR`KQ$y3{6&l-a zbuD_-q2PDt|9=(nwV^_j{G6w1@9owJ`mR#BJ?MR^Q8Lr-S6AYhH?hu{HGlS(=S)H( zPjsGN=TmM!G_})O=&za50y#HMuGcJXR-OMexO%rJe99<$V7+7g-!|PV5*?`wVgD@* zzNze%Pv_;^FU^p!Tf4NJVL}jt^rg#-w{Yr2FmB$kZPtd>W*$L37QswAB&RO;QTUqW zjQU#dV*N(S|goTTpC`Ydo*QVFA1^>;`p%c zS=H6)mp(a6dbf%}*7Nth^&79eDk3T^$!Tten2h(w?`QvLG@UD1SMIej%y+-F zYH;rfhPwUPXKtKWmN)e#)7G#e<8$ekgvI`UVLocS>C^w_TCE4d%&qOObT+8!ac<}6q< zZ_&C%%Qh`qwt4BwZOc~eSiWZG>h=3JZacbZ`|-^?j&I#{dfV>P+xMK=bMW%sLst%+ zxOL*(!xQHpojm{e)WxS~Ek4nug+h4b>Z6U3)kOVyz%zZ&39LBf4q9<)3v*w zZ`}WS-*=zzy0?A-S_|RzyJUI=l_?#|G)nI|Ly<(@Bjb*`v3p;|Nnpf|Nr+N z1VYj~UobE*aFhi31v7+%hDXQz{?qg1%o+v;rhHEq$B>MBZ)d&?zU&}zY;{H@ZCZwg*+NxoKD&0=wmp}h!yEj%CZUA)+RrwY z_8R4;;C+k-4deYax;z57Wka}KmfYBCYVou^ac%Z%0YOgLsm%Wz9n$x|`cZpy%Xw8s z&rF76Kc_K#uCaFL`ZJX=Hm_(_&Bht7D?jNny!>>T+3HjC0ds|q_xGKi%o{Od*Cxe4 zmJcj9jGdR{|9ef|tjx7jky`NFq@)z{Ru{;=%(2CJHof4VmQych01iL6-p$Ks4z+2ZYy zTNs2-**CY9A4oFMQBvw(_*9mmNArJy<`wM+D?jybV))Zo_;h|sA^)?7u1Tl?PEuP$8i z<>29H*OyzFWc)%_&##Sb?BJPpKE`4%NAT%YyZff|ed!i=`18en>!s@Oqs$53%=_48 z)rdFnFi$u6>DTbpzH&qK)I-zH0~8GH<`2+vQ5ZW{nOsyv;B(E zeUX@_yVh3f2~50a+Pa40R*id;<38bo8uuF$X3YP~&L!RyS!d!UW+W*u-c + + + + + + + + + + @@ -9817,52 +9864,55 @@ id="use5913-0-8-1-5-6-8-1" width="100%" height="100%" /> - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + +