From 5a55e9ca423fec8eaed99736ecbf5e1a27021b94 Mon Sep 17 00:00:00 2001 From: RichardLuo <22096448+RichardLuo0@users.noreply.github.com> Date: Tue, 18 Oct 2022 11:34:45 +0800 Subject: [PATCH 1/5] Support different debug config for different targets --- src/extension.ts | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index c9324d86f..9a7c1a000 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1302,34 +1302,52 @@ class ExtensionManager implements vscode.Disposable { return this.runCMakeCommand(cmakeProject => cmakeProject.quickStart(cmakeWorkspaceFolder)); } - launchTargetPath(folder?: vscode.WorkspaceFolder | string) { + launchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetPath" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.launchTargetPath(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.launchTargetPath(); + }, folder); } - launchTargetDirectory(folder?: vscode.WorkspaceFolder | string) { + launchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetDirectory" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.launchTargetDirectory(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.launchTargetDirectory(); + }, folder); } - launchTargetFilename(folder?: vscode.WorkspaceFolder | string) { + launchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetFilename" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.launchTargetFilename(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.launchTargetFilename(); + }, folder); } - getLaunchTargetPath(folder?: vscode.WorkspaceFolder | string) { + getLaunchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetPath" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.getLaunchTargetPath(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.getLaunchTargetPath(); + }, folder); } - getLaunchTargetDirectory(folder?: vscode.WorkspaceFolder | string) { + getLaunchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetDirectory" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.getLaunchTargetDirectory(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.getLaunchTargetDirectory(); + }, folder); } - getLaunchTargetFilename(folder?: vscode.WorkspaceFolder | string) { + getLaunchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetFilename" }); - return this.queryCMakeProject(cmakeProject => cmakeProject.getLaunchTargetFilename(), folder); + return this.queryCMakeProject(cmakeProject => { + if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return cmakeProject.getLaunchTargetFilename(); + }, folder); } buildTargetName(folder?: vscode.WorkspaceFolder | string) { From f336029b5e81eb0abe5c3c8ff4be3d81370dce5b Mon Sep 17 00:00:00 2001 From: RichardLuo <22096448+RichardLuo0@users.noreply.github.com> Date: Tue, 18 Oct 2022 13:29:25 +0800 Subject: [PATCH 2/5] Wait for launch target to be set --- src/extension.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 9a7c1a000..2430acff9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1304,48 +1304,48 @@ class ExtensionManager implements vscode.Disposable { launchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetPath" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.launchTargetPath(); }, folder); } launchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetDirectory" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.launchTargetDirectory(); }, folder); } launchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetFilename" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.launchTargetFilename(); }, folder); } getLaunchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetPath" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.getLaunchTargetPath(); }, folder); } getLaunchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetDirectory" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.getLaunchTargetDirectory(); }, folder); } getLaunchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetFilename" }); - return this.queryCMakeProject(cmakeProject => { - if (targetName != null) cmakeProject.setLaunchTargetByName(targetName); + return this.queryCMakeProject(async cmakeProject => { + if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); return cmakeProject.getLaunchTargetFilename(); }, folder); } From e65ea4f3b8a8bc316491d3141acab555d2cfb4f4 Mon Sep 17 00:00:00 2001 From: RichardLuo <22096448+RichardLuo0@users.noreply.github.com> Date: Wed, 19 Oct 2022 08:37:00 +0800 Subject: [PATCH 3/5] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0818051d2..af69df7cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Improvements: - Use upper case drive letters on Windows for `cmake.sourceDirectory`. [PR #2665](https://github.com/microsoft/vscode-cmake-tools/pull/2665) [@Danielmelody](https://github.com/Danielmelody) - Custom browse configuration should not include (redundant) per-file arguments. [#2645](https://github.com/microsoft/vscode-cmake-tools/issues/2645) - Support optional generator in `configurePresets` for version 3 and higher. [#2734](https://github.com/microsoft/vscode-cmake-tools/issues/2734) [@jochil](https://github.com/jochil) +- Support different debug config for different targets. [PR #2801](https://github.com/microsoft/vscode-cmake-tools/pull/2801) [@RichardLuo0](https://github.com/RichardLuo0) Bug Fixes: - Fix warning message that appears when using a default build preset with a multi-config generator. [#2353](https://github.com/microsoft/vscode-cmake-tools/issues/2353) From 11df9872edbee9a283e8376cc549f2fac776cd6f Mon Sep 17 00:00:00 2001 From: RichardLuo <22096448+RichardLuo0@users.noreply.github.com> Date: Wed, 28 Dec 2022 14:27:23 +0800 Subject: [PATCH 4/5] Fix eslint issue --- src/extension.ts | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index e28352019..20f9c0f13 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1252,50 +1252,62 @@ export class ExtensionManager implements vscode.Disposable { return this.runCMakeCommandForProject(cmakeProject => cmakeProject.quickStart(folder)); } - launchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + launchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetPath" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.launchTargetPath(); }, folder); } - launchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + launchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetDirectory" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.launchTargetDirectory(); }, folder); } - launchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + launchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetFilename" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.launchTargetFilename(); }, folder); } - getLaunchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + getLaunchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetPath" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.getLaunchTargetPath(); }, folder); } - getLaunchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + getLaunchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetDirectory" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.getLaunchTargetDirectory(); }, folder); } - getLaunchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string, targetName?: string }) { + getLaunchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetFilename" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName != null) await cmakeProject.setLaunchTargetByName(targetName); + if (targetName !== null) { + await cmakeProject.setLaunchTargetByName(targetName); + } return cmakeProject.getLaunchTargetFilename(); }, folder); } From be358747019d9fe3c0e4f30e7e6cc08ee8f9bbac Mon Sep 17 00:00:00 2001 From: RichardLuo <22096448+RichardLuo0@users.noreply.github.com> Date: Fri, 11 Aug 2023 02:04:56 +0800 Subject: [PATCH 5/5] check for undefined and null --- src/extension.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index d4717d5c0..a8f6ac8ea 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1344,60 +1344,66 @@ export class ExtensionManager implements vscode.Disposable { launchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetPath" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.launchTargetPath(); + const targetPath = await cmakeProject.launchTargetPath(); + return targetPath; }, folder); } launchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetDirectory" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.launchTargetDirectory(); + const targetDirectory = await cmakeProject.launchTargetDirectory(); + return targetDirectory; }, folder); } launchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "launchTargetFilename" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.launchTargetFilename(); + const targetFilename = await cmakeProject.launchTargetFilename(); + return targetFilename; }, folder); } getLaunchTargetPath({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetPath" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.getLaunchTargetPath(); + const targetPath = await cmakeProject.getLaunchTargetPath(); + return targetPath; }, folder); } getLaunchTargetDirectory({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetDirectory" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.getLaunchTargetDirectory(); + const targetDirectory = await cmakeProject.getLaunchTargetDirectory(); + return targetDirectory; }, folder); } getLaunchTargetFilename({ folder, targetName }: { folder?: vscode.WorkspaceFolder | string; targetName?: string }) { telemetry.logEvent("substitution", { command: "getLaunchTargetFilename" }); return this.queryCMakeProject(async cmakeProject => { - if (targetName !== null) { + if (targetName !== undefined && targetName !== null) { await cmakeProject.setLaunchTargetByName(targetName); } - return cmakeProject.getLaunchTargetFilename(); + const targetFilename = await cmakeProject.getLaunchTargetFilename(); + return targetFilename; }, folder); }