Skip to content

Add cmake.launchConfig setting for customizable run configurations#4916

Draft
hanniavalera wants to merge 4 commits into
mainfrom
dev/hanniavalera/embeddedDbug
Draft

Add cmake.launchConfig setting for customizable run configurations#4916
hanniavalera wants to merge 4 commits into
mainfrom
dev/hanniavalera/embeddedDbug

Conversation

@hanniavalera
Copy link
Copy Markdown
Contributor

This pull request introduces a major new feature to VS Code CMake Tools: the ability to customize the "Run Without Debugging" command via a new cmake.launchConfig setting. This allows users to delegate launching to a VS Code task or to run a custom program (such as a firmware flashing tool), with support for argument, environment, and working directory customization. The implementation includes schema, documentation, and UI/logic changes, as well as telemetry and user guidance for the new behavior. Suggested by @positron96 and addresses #4904

Key changes include:

New Feature: Customizable Run Without Debugging

  • Added the cmake.launchConfig setting, allowing users to configure "Run Without Debugging" to either delegate to a VS Code task (task) or run a custom program (program). This supports variable substitution and custom arguments, environment, and working directory. [1] [2] [3] [4]

Core Implementation and Lifecycle Management

  • Implemented logic in CMakeProject to handle the new launch modes, including running a VS Code task or a custom program instead of the default executable, with proper terminal/task lifecycle and cleanup. [1] [2] [3] [4] [5]
  • Added telemetry event logging to track usage of the new launch modes.

Configuration and API Updates

  • Extended the configuration schema and settings interface to support the new launchConfig property and expose it through the configuration reader. [1] [2] [3]

User Guidance and Documentation

  • Updated documentation and settings descriptions, including warnings when both cmake.launchConfig and cmake.debugConfig fields are set (as the latter are ignored for the launch path), and improved error/warning messages for ambiguous or missing tasks. [1] [2]

These changes provide advanced users and embedded developers with much more flexibility for customizing their build/run workflows directly from CMake Tools.

@gcampbell-msft
Copy link
Copy Markdown
Collaborator

With any new feature, let's be verbose in the description of the PR and include screenshots of the feature. While I plan to checkout and try it out, it makes reviewing a little bit simpler when new UI is added.

Copy link
Copy Markdown
Collaborator

@gcampbell-msft gcampbell-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review, more review to come 👍

Comment thread src/ui/projectStatus.ts
}

dispose(): void {
this.launchTarget?.dispose();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious on what about this needs to be disposed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understood, it releases the config.onChange('launchConfig', ...) subscription registered in initialize() so the node stops reacting to setting changes after teardown, let me know if it makes sense!

Comment thread src/ui/projectStatus.ts

private updateLaunchConfigDescription(): void {
const launchCfg = treeDataProvider.cmakeProject?.workspaceContext.config.launchConfig;
if (launchCfg?.task) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are task and program mutually exclusive? If so, we should make sure we document which we prefer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes they are! I added on to task in addition to the program description to make note of this!

Comment thread src/cmakeProject.ts
this.disposeEmitter.fire();
this.termCloseSub.dispose();
this.launchTaskEndSub.dispose();
this.launchTerminals.forEach(term => term.dispose());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also clear the launchTerminals?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for calling this out! I now added this.launchTerminals.clear() after the dispose loop, matching the pattern used right next to it for launchTaskExecutions, does that make sense to you?

Comment thread package.json
"type": "string",
"description": "%cmake-tools.configuration.cmake.launchConfig.program.description%"
},
"args": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the args and following properties apply to both scenarios of task and program? I imagine that the task itself has these already, how is this handled?

Copy link
Copy Markdown
Contributor Author

@hanniavalera hanniavalera May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They only apply to program mode as VS Code tasks already own those fields. I've tightened the descriptions to say "(ignored in task mode)" and added a defensive log.warning in runLaunchAsTask if a user sets them anyway, so the override is visible without being disruptive.

@hanniavalera
Copy link
Copy Markdown
Contributor Author

With any new feature, let's be verbose in the description of the PR and include screenshots of the feature. While I plan to checkout and try it out, it makes reviewing a little bit simpler when new UI is added.

@gcampbell-msft sounds fair, forgot to put the screenshots up, will do!

@hanniavalera hanniavalera force-pushed the dev/hanniavalera/embeddedDbug branch 2 times, most recently from 63d70bc to b7c9780 Compare May 1, 2026 21:20
- Introduced `cmake.launchConfig` to allow users to customize the "Run Without Debugging" command, enabling delegation to a VS Code task or a custom program.
- Updated documentation and changelog to reflect this new feature.
- Added unit tests to ensure correct functionality and regression coverage for the new launch configuration.
@hanniavalera hanniavalera force-pushed the dev/hanniavalera/embeddedDbug branch from b7c9780 to 36b1c29 Compare May 4, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Make "Run without debuggnig" configurable (for embedded dev)

2 participants