Skip to content

Commit 293a61e

Browse files
Copilotsnehara99
andauthored
Add cmake.selectBuildAndLaunchTarget command to set both targets simultaneously (#4732)
* Initial plan * feat: add cmake.selectBuildAndLaunchTarget command to set both targets at once Co-authored-by: snehara99 <[email protected]> * docs: add selectBuildAndLaunchTarget to CHANGELOG.md under 1.23 features Co-authored-by: snehara99 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: snehara99 <[email protected]>
1 parent b7e50f6 commit 293a61e

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77
- Add command to clear build diagnostics from the Problems pane. [#4691](https://github.com/microsoft/vscode-cmake-tools/pull/4691)
88
- Add individual CTest test nodes to the Project Outline with inline run/debug buttons, and enable debugging tests from both the Outline and Test Explorer without requiring a launch.json. [#4721](https://github.com/microsoft/vscode-cmake-tools/pull/4721)
99
- Add "Delete Cache, Reconfigure and Build" command that chains cache deletion, reconfiguration, and build into a single action. [#4723](https://github.com/microsoft/vscode-cmake-tools/pull/4723)
10+
- Add "Set Build and Launch/Debug Target" command that sets both the build target and launch target simultaneously. [#4732](https://github.com/microsoft/vscode-cmake-tools/pull/4732)
1011

1112
Improvements:
1213
- Improve CMake syntax highlighting with command-scoped keyword rules, expanded variable recognition, and better generator-expression support. Remove obsolete deprecated-keyword entries that caused false positives on user-defined names. [#4709](https://github.com/microsoft/vscode-cmake-tools/issues/4709) [#4508](https://github.com/microsoft/vscode-cmake-tools/issues/4508) [#4613](https://github.com/microsoft/vscode-cmake-tools/issues/4613)

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@
795795
"when": "cmake:enableFullFeatureSet",
796796
"category": "CMake"
797797
},
798+
{
799+
"command": "cmake.selectBuildAndLaunchTarget",
800+
"title": "%cmake-tools.command.cmake.selectBuildAndLaunchTarget.title%",
801+
"when": "cmake:enableFullFeatureSet",
802+
"category": "CMake"
803+
},
798804
{
799805
"command": "cmake.outline.setLaunchTarget",
800806
"when": "cmake:enableFullFeatureSet",
@@ -1442,6 +1448,10 @@
14421448
"command": "cmake.selectLaunchTarget",
14431449
"when": "cmake:enableFullFeatureSet"
14441450
},
1451+
{
1452+
"command": "cmake.selectBuildAndLaunchTarget",
1453+
"when": "cmake:enableFullFeatureSet"
1454+
},
14451455
{
14461456
"command": "cmake.stop",
14471457
"when": "cmake:enableFullFeatureSet"

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"cmake-tools.command.cmake.launchTarget.title": "Run Without Debugging",
7575
"cmake-tools.command.cmake.launchTargetAll.title": "Run All Projects Without Debugging",
7676
"cmake-tools.command.cmake.selectLaunchTarget.title": "Set Launch/Debug Target",
77+
"cmake-tools.command.cmake.selectBuildAndLaunchTarget.title": "Set Build and Launch/Debug Target",
7778
"cmake-tools.command.cmake.stop.title": "Cancel Build",
7879
"cmake-tools.command.cmake.stopAll.title": "Cancel Build for All Projects",
7980
"cmake-tools.command.cmake.resetState.title": {

src/cmakeProject.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,21 @@ export class CMakeProject {
26432643
return this.setLaunchTargetByName(name);
26442644
}
26452645

2646+
/**
2647+
* Implementation of `cmake.selectBuildAndLaunchTarget`
2648+
* Sets both the build target and the launch target simultaneously.
2649+
*/
2650+
async selectBuildAndLaunchTarget(name?: string): Promise<string | null> {
2651+
const result = await this.setLaunchTargetByName(name);
2652+
if (result !== null) {
2653+
const launchTargetName = this._launchTargetName.value;
2654+
if (launchTargetName) {
2655+
await this.setDefaultBuildTarget(launchTargetName);
2656+
}
2657+
}
2658+
return result;
2659+
}
2660+
26462661
/**
26472662
* Used by vscode and as test interface
26482663
*/

src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,10 @@ export class ExtensionManager implements vscode.Disposable {
19181918
return this.runCMakeCommand(cmakeProject => cmakeProject.selectLaunchTarget(name), folder, undefined, undefined, sourceDir);
19191919
}
19201920

1921+
selectBuildAndLaunchTarget(folder?: vscode.WorkspaceFolder, name?: string, sourceDir?: string) {
1922+
return this.runCMakeCommand(cmakeProject => cmakeProject.selectBuildAndLaunchTarget(name), folder, undefined, undefined, sourceDir);
1923+
}
1924+
19211925
async resetState(folder?: vscode.WorkspaceFolder) {
19221926
telemetry.logEvent("resetExtension");
19231927
if (folder) {
@@ -2471,6 +2475,7 @@ async function setup(context: vscode.ExtensionContext, progress?: ProgressHandle
24712475
'launchTarget',
24722476
'launchTargetAll',
24732477
'selectLaunchTarget',
2478+
'selectBuildAndLaunchTarget',
24742479
'setDefaultTarget',
24752480
'resetState',
24762481
'openSettings',

0 commit comments

Comments
 (0)