Skip to content

Commit

Permalink
Add new commands, cmake.buildType and cmake.buildDirectory (#726)
Browse files Browse the repository at this point in the history
* Add cmake.buildType and cmake.buildDirectory
  • Loading branch information
notskm authored and bobbrow committed Aug 9, 2019
1 parent 74810b2 commit ad633ef
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions src/api.ts
Expand Up @@ -289,6 +289,16 @@ export interface CMakeToolsAPI extends Disposable {
*/
launchTargetDirectory(): Thenable<string|null>;

/**
* Get the selected build type
*/
currentBuildType(): Thenable<string|null>;

/**
* Get the build directory.
*/
buildDirectory(): Thenable<string|null>;

/**
* Get the build command string for the active target
*/
Expand Down
22 changes: 22 additions & 0 deletions src/cmake-tools.ts
Expand Up @@ -974,6 +974,28 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
return path.dirname(targetPath);
}

/**
* Implementation of `cmake.buildType`
*/
async currentBuildType(): Promise<string|null> {
if (this.buildType == 'Unconfigured') {
return null;
}
return this.buildType;
}

/**
* Implementation of `cmake.buildDirectory`
*/
async buildDirectory(): Promise<string|null> {
const binaryDir = await this.binaryDir;
if (binaryDir) {
return binaryDir;
} else {
return null;
}
}

async prepareLaunchTargetExecutable(name?: string): Promise<api.ExecutableTarget|null> {
let chosen: api.ExecutableTarget;
if (name) {
Expand Down
36 changes: 31 additions & 5 deletions src/extension.ts
Expand Up @@ -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)); }
Expand Down Expand Up @@ -1131,11 +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',
'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',
'tasksBuildCommand'
// 'toggleCoverageDecorations', // XXX: Should coverage decorations be revived?
];
Expand Down

0 comments on commit ad633ef

Please sign in to comment.