Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CMakeTools

Class implementing the extension. It's all here!

The class internally uses a two-phase initialization, since proper startup requires asynchrony. To ensure proper initialization. The class must be created via the create static method. This will run the two phases internally and return a promise to the new instance. This ensures that the class invariants are maintained at all times.

Some fields also require two-phase init. Their first phase is in the first phase of the CMakeTools init, ie. the constructor.

The second phases of fields will be called by the second phase of the parent class. See the _init private method for this initialization.

Hierarchy

  • CMakeTools

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

Private constructor

  • Construct a new instance. The instance isn't ready, and must be initalized.

    Parameters

    • extensionContext: vscode.ExtensionContext

      The extension context

      This is private. You must call create to get an instance.

    • workspaceContext: DirectoryContext

    Returns CMakeTools

Properties

Private _activeKit

_activeKit: Kit | null = null

Private _buildType

_buildType: Property<string> = new Property<string>('Unconfigured')

Private _cmakeDriver

_cmakeDriver: Promise<CMakeDriver | null> = Promise.resolve(null)

The object in charge of talking to CMake. It starts empty (null) because we don't know what driver to use at the current time. The driver also has two-phase init and a private constructor. The driver may be replaced at any time by the user making changes to the workspace configuration.

Private _codeModel

_codeModel: Property<null | CodeModelContent> = new Property<CodeModelContent|null>(null)

Private _codeModelDriverSub

_codeModelDriverSub: vscode.Disposable | null = null

Private _compilationDatabase

_compilationDatabase: CompilationDatabase | null = null

The compilation database for this driver.

Private _ctestController

_ctestController: CTestDriver = new CTestDriver(this.workspaceContext)

Private _ctestEnabled

_ctestEnabled: Property<boolean> = new Property<boolean>(false)

Private _driverStrand

_driverStrand: Strand = new Strand()

A strand to serialize operations with the CMake driver

Private _isBusy

_isBusy: Property<boolean> = new Property<boolean>(false)

Private _launchTargetName

_launchTargetName: Property<null | string> = new Property<string|null>(null)

Private Optional _launchTerminal

_launchTerminal: vscode.Terminal

Private _nagManager

_nagManager: NagManager = new NagManager(this.extensionContext)

Private _nagUpgradeSubscription

_nagUpgradeSubscription: Disposable = this._nagManager.onCMakeLatestVersion(info => {this.getCMakeExecutable().then(async cmake => {if (!cmake.version) {log.error('Failed to get version information for CMake during upgarde');return;}await maybeUpgradeCMake(this.extensionContext, {currentVersion: cmake.version, available: info});},e => { rollbar.exception('Error during CMake upgrade', e, info); },);})

Private _onReconfiguredEmitter

_onReconfiguredEmitter: EventEmitter<void> = new vscode.EventEmitter<void>()

Private _onTargetChangedEmitter

_onTargetChangedEmitter: EventEmitter<void> = new vscode.EventEmitter<void>()

Private _statusMessage

_statusMessage: Property<string> = new Property<string>('Initializing')

Private _targetName

_targetName: Property<string> = new Property<string>('all')

Private _termCloseSub

_termCloseSub: Disposable = vscode.window.onDidCloseTerminal(term => {if (term === this._launchTerminal) {this._launchTerminal = undefined;}})

Private _testResults

_testResults: Property<null | BasicTestResults> = new Property<BasicTestResults|null>(null)

Private _variantManager

_variantManager: VariantManager = new VariantManager(this.workspaceContext.state, this.workspaceContext.config)

The variant manager keeps track of build variants. Has two-phase init.

extensionContext

extensionContext: vscode.ExtensionContext

The extension context

This is private. You must call create to get an instance.

workspaceContext

workspaceContext: DirectoryContext

Accessors

activeKit

  • get activeKit(): Kit | null

allTargetName

  • get allTargetName(): Promise<string>
  • Get the name of the "all" target; that is, the target name for which CMake will build all default targets.

    This is required because simply using all as the target name is incorrect for some generators, such as Visual Studio and Xcode.

    This is async because it depends on checking the active generator name

    Returns Promise<string>

binaryDir

  • get binaryDir(): Promise<string>

buildType

  • get buildType(): string

cachePath

  • get cachePath(): Promise<string>

codeModel

ctestEnabled

  • get ctestEnabled(): boolean

defaultBuildTarget

  • get defaultBuildTarget(): string | null
  • The target that will be built with a regular build invocation

    Returns string | null

executableTargets

isBusy

  • get isBusy(): boolean
  • Whether the backend is busy running some task

    Returns boolean

launchTargetName

  • get launchTargetName(): null | string
  • The "launch target" (the target that will be run by debugging)

    Returns null | string

mainListFile

  • get mainListFile(): Promise<string>

onBuildTypeChanged

  • get onBuildTypeChanged(): function

onCTestEnabledChanged

  • get onCTestEnabledChanged(): function

onCodeModelChanged

  • get onCodeModelChanged(): function

onIsBusyChanged

  • get onIsBusyChanged(): function

onLaunchTargetNameChanged

  • get onLaunchTargetNameChanged(): function

onReconfigured

  • get onReconfigured(): Event<void>
  • Event fired after CMake configure runs

    Returns Event<void>

onStatusMessageChanged

  • get onStatusMessageChanged(): function

onTargetNameChanged

  • get onTargetNameChanged(): function

onTestResultsChanged

  • get onTestResultsChanged(): function

reconfigured

  • get reconfigured(): Event<void>

sourceDir

  • get sourceDir(): Promise<string>

statusMessage

  • get statusMessage(): string

targetChangedEvent

  • get targetChangedEvent(): Event<void>

targetName

  • get targetName(): string

targets

testResults

Methods

Private _allTargetName

  • _allTargetName(): Promise<string>

Private _doConfigure

  • _doConfigure(progress: ProgressHandle, cb: function): Promise<number>

Private _init

  • _init(): Promise<void>
  • Second phase of two-phase init. Called by create.

    Returns Promise<void>

Private _needsReconfigure

  • _needsReconfigure(): Promise<boolean>
  • Check if the current project needs to be (re)configured

    Returns Promise<boolean>

Private _refreshCompileDatabase

Private _setDefaultBuildTarget

  • _setDefaultBuildTarget(v: string): Promise<void>

Private _startNewCMakeDriver

asyncDispose

  • asyncDispose(): Promise<void>
  • Dispose of the extension asynchronously.

    Returns Promise<void>

build

  • build(target_?: undefined | string): Promise<number>

buildWithTarget

  • buildWithTarget(): Promise<number>

clean

  • clean(): Promise<number>

cleanConfigure

  • cleanConfigure(): Thenable<number>

cleanRebuild

  • cleanRebuild(): Promise<number>

configure

  • configure(extra_args?: string[], type?: ConfigureType): Thenable<number>
  • Implementation of cmake.configure

    Parameters

    • Default value extra_args: string[] = []
    • Default value type: ConfigureType = ConfigureType.Normal

    Returns Thenable<number>

ctest

  • ctest(): Promise<number>

debugTarget

  • debugTarget(name?: undefined | string): Promise<vscode.DebugSession | null>
  • Implementation of cmake.debugTarget

    Parameters

    • Optional name: undefined | string

    Returns Promise<vscode.DebugSession | null>

dispose

  • dispose(): void

editCache

  • editCache(): Promise<void>

ensureConfigured

  • ensureConfigured(): Promise<number | null>

execute

executeCMakeCommand

getCMakeDriverInstance

  • getCMakeDriverInstance(): Promise<CMakeDriver | null>
  • Returns, if possible a cmake driver instance. To creation the driver instance, there are preconditions that should be fulfilled, such as an active kit is selected. These preconditions are checked before it driver instance creation. When creating a driver instance, this function waits until the driver is ready before returning. This ensures that user commands can always be executed, because error criterials like exceptions would assign a null driver and it is possible to create a new driver instance later again.

    Returns Promise<CMakeDriver | null>

getCMakeExecutable

getCurrentLaunchTarget

getOrSelectLaunchTarget

install

  • install(): Promise<number>

jumpToCacheFile

  • jumpToCacheFile(): Promise<null>

launchTarget

  • launchTarget(name?: undefined | string): Promise<null | Terminal>
  • Implementation of cmake.launchTarget

    Parameters

    • Optional name: undefined | string

    Returns Promise<null | Terminal>

launchTargetPath

  • launchTargetPath(): Promise<string | null>

maybeAutoSaveAll

  • maybeAutoSaveAll(): Promise<boolean>
  • Save all open files. "maybe" because the user may have disabled auto-saving with config.saveBeforeBuild.

    Returns Promise<boolean>

prepareLaunchTargetExecutable

  • prepareLaunchTargetExecutable(name?: undefined | string): Promise<ExecutableTarget | null>

quickStart

  • quickStart(): Promise<Number>

resetState

  • resetState(): Promise<void>

selectEnvironments

  • selectEnvironments(): Promise<null>

selectLaunchTarget

  • selectLaunchTarget(name?: undefined | string): Promise<string | null>
  • Implementation of cmake.selectLaunchTarget

    Parameters

    • Optional name: undefined | string

    Returns Promise<string | null>

setBuildType

  • setBuildType(): Promise<number>

setDefaultTarget

  • setDefaultTarget(target?: string | null): Promise<void>
  • Set the default target to build. Implementation of cmake.setDefaultTarget

    Parameters

    • Optional target: string | null

      If specified, set this target instead of asking the user

    Returns Promise<void>

setKit

  • setKit(kit: Kit | null): Promise<void>

setLaunchTargetByName

  • setLaunchTargetByName(name?: string | null): Promise<null | string>
  • Used by vscode and as test interface

    Parameters

    • Optional name: string | null

    Returns Promise<null | string>

setVariant

  • setVariant(): Promise<boolean>
  • Implementation of cmake.setVariant

    Returns Promise<boolean>

showTargetSelector

  • showTargetSelector(): Promise<string | null>

stop

  • stop(): Promise<boolean>

tryCompileFile

  • tryCompileFile(filePath: string): Promise<vscode.Terminal | null>
  • Attempt to execute the compile command associated with the file. If it fails for any reason, returns null. Otherwise returns the terminal in which the compilation is running

    Parameters

    • filePath: string

      The path to a file to try and compile

    Returns Promise<vscode.Terminal | null>

viewLog

  • viewLog(): Promise<void>

Static create

  • Create an instance asynchronously

    Parameters

    • ctx: vscode.ExtensionContext

      The extension context

      The purpose of making this the only way to create an instance is to prevent us from creating uninitialized instances of the CMake Tools extension.

    • wsc: DirectoryContext

    Returns Promise<CMakeTools>

Static createForDirectory

  • createForDirectory(dirPath: string, ext: vscode.ExtensionContext): Promise<CMakeTools>
  • Create a new CMakeTools for the given directory.

    Parameters

    • dirPath: string

      Path to the directory for which to create

    • ext: vscode.ExtensionContext

      The extension context

    Returns Promise<CMakeTools>

Generated using TypeDoc