microsoft / vscode-cmake-tools

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

Add command substitution for getLaunchTarget so the current debug target name can be consumed in tasks.json #1895

Open hwmaier opened 3 years ago

hwmaier commented 3 years ago

This is a feature request.

Currently a list of CMake variables are available for command substitution in task commands, for example cmake.buildTargetName. Refer to https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md

While the build target name is exposed as substitution, the corresponding debug target name is not.

It would be beneficial to add a substitution for getLaunchTarget so the current debug target name is also available and can be consumed in tasks. This is very useful to support utility targets like code signing or embedded flash programming.

Please note, the getLaunchTargetFilename (equivalent to CMake API nameOnDisk) is already exposed, but this is a different value than the itself launchTarget (CMake API value name) and has the file extension .exe or .elf appended.

andreeis commented 3 years ago

Good idea, thank you for the feature request.

andreeis commented 3 years ago

This would be a very simple change and this is a good example PR that added similar new commands in the past (in case anyone would be interested to implement this). https://github.com/microsoft/vscode-cmake-tools/pull/1488

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.

hwmaier commented 3 weeks ago

Hi Garrett, has this been implemented?

gcampbell-msft commented 3 weeks ago

@hwmaier From what I can tell, we currently have the three commands:

cmake.getLaunchTargetPath cmake.getLaunchTargetDirectory cmake.getLaunchTargetFileName

Do these work for you? Re-opening this issue until this is confirmed.

hwmaier commented 3 weeks ago

cmake.getLaunchTargetPath cmake.getLaunchTargetDirectory cmake.getLaunchTargetFileName

Do these work for you? Re-opening this issue until this is confirmed.

Thank you for re-opening. I am aware of those, but as stated in the initial post, these three values have extensions (.exe) and paths added and are not the same value as the target name.

The idea is the have an equivalent to cmake.buildTargetName which exposes the selected launch target name not its underlaying file name.

gcampbell-msft commented 2 weeks ago

@hwmaier Got it, thanks for the additional information.