microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 454 forks source link

Feature request: Configurable "launch" (and "debug"?) button #1937

Open pearson opened 3 years ago

pearson commented 3 years ago

It would be useful to be able to configure the CMake-Tools "play" icon launch button and the "bug" icon debug button. In my case I'm working with ARM microcontrollers, and I'd like to be able to press one button to build, flash, and reset the board. I'd also like to have similar functionality for debugging that builds, flashes, and then launches cortex-debug.

Perhaps the debug configuration is already included as part of cmake.debugConfig, but the documentation is currently unavailable. (The documentation issue is mentioned in #1936 and is now a work item in #1246). I do not see any way to configure how CMake-Tools performs a non-debug launch, though.

andreeis commented 3 years ago

@pearson, thank you for the feature idea. We will look into this but it's possible that we won't be able right away. We will monitor the reactions from the community to help us find the best place for this feature in our backlog.

In the meantime, even if you can't configure the two buttons (cmake.debugConfig is not as powerful yet as VSCode debugging) you can write a launch.json and achieve all via running a command or a key shortcut (F5, Ctrl+F5, look at the debug/run commands in the pallette, VSCode general commands not CMake Tools commands).

Building will automatically happen if you don't override the "true" default for "cmake.buildBeforeDebugging". Flash/reset you can achieve with other keywords in launch.json or you can hook up tasks. If you don't know already how to leverage launch.json for your scenario I'll search around in our team, we have several embedded experts that know how to do this.

pearson commented 3 years ago

Thanks, @andreeis! I need look more deeply into launch.json and what it can do for me.

Something that might be worth considering is the cmake.tasksBuildCommand variable. I was working with an example which fed that variable to the bash shell, but that failed under Windows because PowerShell didn't like the space in "Program Files", even though it's all in quotes. (I think, anyway...)

> Executing task: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Projects/Mbed/test_blinky/build --config Debug --target all -j 26 -- <

C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.

Anyway, my thought here is that it might be useful to have the cmake.tasksBuildCommand variable split up, with the path, command, and arguments all separate. Currently I have a basic build task created, but it would be nice to automatically pass in the parameters CMake-Tools is going to use rather than hard coding them.

EDIT: Of course this completely ignored what you said about the fact that an automatic build will happen... Oops.

andreeis commented 3 years ago

Let me know if this blog post helps with your scenario.

andreeis commented 3 years ago

Adding two embedded experts: @benmcmorran and @robotdad.

vlebourl commented 3 years ago

Hi, sorry to intrude, but I'm very interested in the first feature request. In my case, lot of targets I have require specific command line arguments. I know I can write a launch.json entry for each of them, but it kind of defeats the purpose of that easy access bug button. Do you have another easy way to do that besides a launch entry? So count my vote in for that feature!

github-actions[bot] commented 1 year ago

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.