Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new commands, cmake.buildType and cmake.buildDirectory #726

Merged
merged 2 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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',
bobbrow marked this conversation as resolved.
Show resolved Hide resolved
'tasksBuildCommand'
// 'toggleCoverageDecorations', // XXX: Should coverage decorations be revived?
];
Expand Down