From 3cff6f447af93762fa517ec7d1a7219a368b6d64 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 7 Oct 2019 16:22:59 +0200 Subject: McuSupport: Make RunConfiguration flash and run the app For now with flash_*_and_bootloader, and later perhaps with an option to flash without bootloader and without assets. Change-Id: I861d8d4f269dcb9b57447217f78825ce232c903e Reviewed-by: Alessandro Portale --- .../mcusupport/mcusupportrunconfiguration.cpp | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/plugins/mcusupport') diff --git a/src/plugins/mcusupport/mcusupportrunconfiguration.cpp b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp index 2e05b9ff50..92dcb4181f 100644 --- a/src/plugins/mcusupport/mcusupportrunconfiguration.cpp +++ b/src/plugins/mcusupport/mcusupportrunconfiguration.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include using namespace ProjectExplorer; using namespace Utils; @@ -42,9 +44,17 @@ namespace Internal { static CommandLine flashAndRunCommand(Target *target) { - BuildConfiguration *bc = target->activeBuildConfiguration(); + const QString projectName = target->project()->displayName(); - return CommandLine(bc->environment().searchInPath("cmake"), {}); + const CMakeProjectManager::CMakeTool *tool = + CMakeProjectManager::CMakeKitAspect::cmakeTool(target->kit()); + + return CommandLine(tool->filePath(), { + "--build", + ".", + "--target", + QString("flash_%1_and_bootloader").arg(projectName) + }); } class FlashAndRunConfiguration : public ProjectExplorer::RunConfiguration @@ -57,6 +67,17 @@ public: effectiveFlashAndRunCall->setLabelText(tr("Effective flash and run call:")); effectiveFlashAndRunCall->setDisplayStyle(BaseStringAspect::TextEditDisplay); effectiveFlashAndRunCall->setReadOnly(true); + + auto updateConfiguration = [target, effectiveFlashAndRunCall] { + effectiveFlashAndRunCall->setValue(flashAndRunCommand(target).toUserOutput()); + }; + + updateConfiguration(); + + connect(target->activeBuildConfiguration(), &BuildConfiguration::buildDirectoryChanged, + this, updateConfiguration); + connect(target->project(), &Project::displayNameChanged, + this, updateConfiguration); } }; @@ -67,8 +88,11 @@ public: : SimpleTargetRunner(runControl) { setStarter([this, runControl] { - CommandLine cmd = flashAndRunCommand(runControl->target()); + ProjectExplorer::Target *target = runControl->target(); + const CommandLine cmd = flashAndRunCommand(target); Runnable r; + r.workingDirectory = + target->activeBuildConfiguration()->buildDirectory().toUserOutput(); r.setCommandLine(cmd); SimpleTargetRunner::doStart(r, {}); }); -- cgit v1.2.1