From 8e8256bd4de7e523c9bedb56019ef2af6e8bcafb Mon Sep 17 00:00:00 2001 From: notskm Date: Sat, 3 Aug 2019 22:42:17 -0400 Subject: [PATCH 1/2] Add cmake.buildType and cmake.buildDirectory --- package.json | 2 ++ src/api.ts | 10 ++++++++++ src/cmake-tools.ts | 22 ++++++++++++++++++++++ src/extension.ts | 37 +++++++++++++++++++++++++++++++------ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1074fdd99..d6a716683 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,8 @@ "onCommand:cmake.launchTarget", "onCommand:cmake.launchTargetPath", "onCommand:cmake.launchTargetDirectory", + "onCommand:cmake.buildType", + "onCommand:cmake.buildDirectory", "onCommand:cmake.tasksBuildCommand", "onCommand:cmake.quickStart", "onCommand:cmake.resetState", diff --git a/src/api.ts b/src/api.ts index 8ec44369e..256a086db 100644 --- a/src/api.ts +++ b/src/api.ts @@ -289,6 +289,16 @@ export interface CMakeToolsAPI extends Disposable { */ launchTargetDirectory(): Thenable; + /** + * Get the selected build type + */ + currentBuildType(): Thenable; + + /** + * Get the build directory. + */ + buildDirectory(): Thenable; + /** * Get the build command string for the active target */ diff --git a/src/cmake-tools.ts b/src/cmake-tools.ts index b26f76bac..b4571ca20 100644 --- a/src/cmake-tools.ts +++ b/src/cmake-tools.ts @@ -974,6 +974,28 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI { return path.dirname(targetPath); } + /** + * Implementation of `cmake.buildType` + */ + async currentBuildType(): Promise { + if (this.buildType == 'Unconfigured') { + return null; + } + return this.buildType; + } + + /** + * Implementation of `cmake.buildDirectory` + */ + async buildDirectory(): Promise { + const binaryDir = await this.binaryDir; + if (binaryDir) { + return binaryDir; + } else { + return null; + } + } + async prepareLaunchTargetExecutable(name?: string): Promise { let chosen: api.ExecutableTarget; if (name) { diff --git a/src/extension.ts b/src/extension.ts index 2e22c9bdb..7f9ced0d4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1069,6 +1069,10 @@ class ExtensionManager implements vscode.Disposable { launchTargetDirectory() { return this.withCMakeTools(null, cmt => cmt.launchTargetDirectory()); } + buildType() { return this.withCMakeTools(null, cmt => cmt.currentBuildType()); } + + buildDirectory() { return this.withCMakeTools(null, cmt => cmt.buildDirectory()); } + tasksBuildCommand() { return this.withCMakeTools(null, cmt => cmt.tasksBuildCommand()); } debugTarget(name?: string) { return this.withCMakeTools(null, cmt => cmt.debugTarget(name)); } @@ -1131,12 +1135,33 @@ async function setup(context: vscode.ExtensionContext, progress: ProgressHandle) // List of functions that will be bound commands const funs: (keyof ExtensionManager)[] = [ - 'editKits', 'scanForKits', 'selectKit', 'setKitByName', 'cleanConfigure', - 'configure', 'build', 'setVariant', 'install', 'editCache', - 'clean', 'cleanRebuild', 'buildWithTarget', 'setDefaultTarget', 'ctest', - 'stop', 'quickStart', 'launchTargetPath', 'launchTargetDirectory', 'debugTarget', - 'launchTarget', 'selectLaunchTarget', 'resetState', 'viewLog', 'compileFile', - 'tasksBuildCommand' + 'editKits', + 'scanForKits', + 'selectKit', + 'setKitByName', + 'cleanConfigure', + 'configure', + 'build', + 'setVariant', + 'install', + 'editCache', + 'clean', + 'cleanRebuild', + 'buildWithTarget', + 'setDefaultTarget', + 'ctest', + 'stop', + 'quickStart', + 'launchTargetPath', + 'launchTargetDirectory', + 'buildType', + 'buildDirectory', + 'debugTarget', + 'launchTarget', + 'selectLaunchTarget', + 'resetState', + 'viewLog', + 'compileFile', // 'toggleCoverageDecorations', // XXX: Should coverage decorations be revived? ]; From 98e9fac43aabe6138c393645e60987091864c582 Mon Sep 17 00:00:00 2001 From: notskm Date: Fri, 9 Aug 2019 02:45:31 -0400 Subject: [PATCH 2/2] Add tasksBuildCommand back in --- src/extension.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extension.ts b/src/extension.ts index 7f9ced0d4..421d2dc90 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1162,6 +1162,7 @@ async function setup(context: vscode.ExtensionContext, progress: ProgressHandle) 'resetState', 'viewLog', 'compileFile', + 'tasksBuildCommand' // 'toggleCoverageDecorations', // XXX: Should coverage decorations be revived? ];