Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CMakeDriver

Base class for CMake drivers.

CMake drivers are separated because different CMake version warrant different communication methods. Older CMake versions need to be driven by the command line, but newer versions may be controlled via CMake server, which provides a much richer interface.

This class defines the basis for what a driver must implement to work.

Hierarchy

Implements

  • Disposable

Index

Constructors

Protected constructor

Properties

Private _argsSub

_argsSub: Disposable = this.ws.config.onChange('configureArgs', () => this.doConfigureSettingsChange())

Private _binaryDir

_binaryDir: string = ""

Private _compileTerms

_compileTerms: Map<string, Terminal> = new Map<string, vscode.Terminal>()

File compilation terminals. This is a map, rather than a single terminal instance for two reasons:

  1. Different compile commands may require different environment variables.
  2. Different compile commands may require different working directories.

The key of each terminal is generated deterministically in runCompileCommand() based on the CWD and environment of the compile command.

Private _copyCompileCommandsPath

_copyCompileCommandsPath: string | null = null

Private _currentProcess

_currentProcess: Subprocess | null = null

The currently running process. We keep a handle on it so we can stop it upon user request

Private _envSub

_envSub: Disposable = this.ws.config.onChange('configureEnvironment', () => this.doConfigureSettingsChange())

Private _installDir

_installDir: string | null = null

Protected _isBusy

_isBusy: boolean = false

Private _kit

_kit: Kit | null = null

The current Kit. Starts out null, but once set, is never null again. We do some separation here to protect ourselves: The _baseKit property is private, so derived classes cannot change it, except via _setBaseKit, which only allows non-null kits. This prevents the derived classes from resetting the kit back to null.

Private _kitEnvironmentVariables

_kitEnvironmentVariables: Map<string, string> = new Map<string, string>()

The environment variables required by the current kit

Private _settingsSub

_settingsSub: Disposable = this.ws.config.onChange('configureSettings', () => this.doConfigureSettingsChange())

Subscribe to changes that affect the CMake configuration

Private _sourceDirectory

_sourceDirectory: string = ""

Private _variantBuildType

_variantBuildType: string = "Debug"

The CMAKE_BUILD_TYPE to use

Private _variantConfigureSettings

_variantConfigureSettings: ConfigureArguments

The arguments to pass to CMake during a configuration according to the current variant

Private _variantEnv

Environment variables defined by the current variant

Private _variantLinkage

_variantLinkage: null | "static" | "shared" = null

Determine if we set BUILD_SHARED_LIBS to TRUE or FALSE

cmake

ws

Accessors

Private _workspaceRootPath

  • get _workspaceRootPath(): null | string
  • Get the vscode root workspace folder.

    Returns null | string

    Returns the vscode root workspace folder. Returns null if no folder is open or the folder uri is not a file:// scheme.

allTargetName

  • get allTargetName(): string

binaryDir

  • get binaryDir(): string
  • Directory where build output is stored.

    Returns string

cachePath

  • get cachePath(): string
  • brief

    Get the path to the CMakeCache file in the build directory

    Returns string

cmakeCacheEntries

compilerID

  • get compilerID(): string | null
  • The ID of the current compiler, as best we can tell

    Returns string | null

copyCompileCommandsPath

  • get copyCompileCommandsPath(): string | null
  • Path to copy compile_commands.json to

    Returns string | null

currentBuildType

  • get currentBuildType(): string
  • Get the current build type, according to the current selected variant.

    This is the value passed to CMAKE_BUILD_TYPE or --config for multiconf

    Returns string

executableTargets

expansionOptions

generatorName

  • get generatorName(): string | null
  • Get the name of the current CMake generator, or null if we have not yet configured the project.

    Returns string | null

installDir

  • get installDir(): string | null
  • Directory where the targets will be installed.

    Returns string | null

isBusy

  • get isBusy(): boolean
  • Is the driver busy? ie. running a configure/build/test

    Returns boolean

isMultiConf

  • get isMultiConf(): boolean

linkerID

  • get linkerID(): string | null

mainListFile

  • get mainListFile(): string
  • Path to where the root CMakeLists.txt file should be

    Returns string

onProgress

sourceDir

  • get sourceDir(): string
  • The source directory, where the root CMakeLists.txt lives.

    note

    This is distinct from the config values, since we do variable substitution.

    Returns string

targets

  • get targets(): api.Target[]
  • List of targets known to CMake

    Returns api.Target[]

Methods

Private _baseInit

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

Private _beforeConfigureOrBuild

  • _beforeConfigureOrBuild(): Promise<boolean>
  • Execute pre-configure/build tasks to check if we are ready to run a full configure. This should be called by a derived driver before any configuration tasks are run

    Returns Promise<boolean>

Protected _cleanPriorConfiguration

  • _cleanPriorConfiguration(): Promise<void>
  • Remove the prior CMake configuration files.

    Returns Promise<void>

Private _doCMakeBuild

  • _doCMakeBuild(target: string, consumer?: proc.OutputConsumer): Promise<Subprocess | null>
  • Parameters

    • target: string
    • Optional consumer: proc.OutputConsumer

    Returns Promise<Subprocess | null>

Private _refreshExpansions

  • _refreshExpansions(): Promise<void>

Private _setKit

  • _setKit(kit: Kit): Promise<void>

Abstract asyncDispose

  • asyncDispose(): Promise<void>
  • Do any necessary disposal for the driver. For the CMake Server driver, this entails shutting down the server process and closing the open pipes.

    The reason this is separate from the regular dispose() is so that the driver shutdown may be awaited on to ensure full shutdown.

    Returns Promise<void>

build

  • build(target: string, consumer?: proc.OutputConsumer): Promise<number | null>
  • Parameters

    • target: string
    • Optional consumer: proc.OutputConsumer

    Returns Promise<number | null>

Abstract checkNeedsReconfigure

  • checkNeedsReconfigure(): Promise<boolean>
  • Check if we need to reconfigure, such as if an important file has changed

    Returns Promise<boolean>

Abstract cleanConfigure

  • cleanConfigure(consumer?: proc.OutputConsumer): Promise<number>
  • Perform a clean configure. Deletes cached files before running the config

    Parameters

    • Optional consumer: proc.OutputConsumer

      The output consumer

    Returns Promise<number>

configure

  • configure(extra_args: string[], consumer?: proc.OutputConsumer): Promise<number>
  • Parameters

    • extra_args: string[]
    • Optional consumer: proc.OutputConsumer

    Returns Promise<number>

dispose

  • dispose(): void
  • Dispose the driver. This disposes some things synchronously, but also calls the asyncDispose() method to start any asynchronous shutdown.

    Returns void

Protected Abstract doConfigure

  • doConfigure(extra_args: string[], consumer?: proc.OutputConsumer): Promise<number>
  • Do the configuration process for the current project.

    Parameters

    • extra_args: string[]
    • Optional consumer: proc.OutputConsumer

    Returns Promise<number>

    The exit code from CMake

Protected Abstract doConfigureSettingsChange

  • doConfigureSettingsChange(): void

Protected Abstract doInit

  • doInit(): Promise<void>

Protected doPostBuild

  • doPostBuild(): Promise<boolean>

Protected doPreBuild

  • doPreBuild(): Promise<boolean>

Protected doRefreshExpansions

  • doRefreshExpansions(cb: function): Promise<void>
  • Parameters

    • cb: function
        • (): Promise<void>
        • Returns Promise<void>

    Returns Promise<void>

Protected Abstract doSetKit

  • doSetKit(needsClean: boolean, cb: function): Promise<void>
  • Parameters

    • needsClean: boolean
    • cb: function
        • (): Promise<void>
        • Returns Promise<void>

    Returns Promise<void>

executeCommand

  • executeCommand(command: string, args: string[], consumer?: proc.OutputConsumer, options?: proc.ExecutionOptions): Subprocess
  • Parameters

    • command: string
    • args: string[]
    • Optional consumer: proc.OutputConsumer
    • Optional options: proc.ExecutionOptions

    Returns Subprocess

getBaseConfigureEnvironment

  • getBaseConfigureEnvironment(): Promise<object>
  • Get the configure environment and apply any needed substitutions before returning it.

    Returns Promise<object>

getBestGenerator

getConfigureEnvironment

getEffectiveSubprocessEnvironment

getExpandedEnvironment

  • getExpandedEnvironment(): Promise<object>
  • Get the environment and apply any needed substitutions before returning it.

    Returns Promise<object>

getKitEnvironmentVariablesObject

getPreferredGenerators

runCompileCommand

  • Launch the given compilation command in an embedded terminal.

    Parameters

    • cmd: CompileCommand

      The compilation command from a compilation database to run

    Returns vscode.Terminal

setKit

  • setKit(kit: Kit): Promise<void>
  • Change the current kit. This lets the driver reload, if necessary.

    Parameters

    • kit: Kit

      The new kit

    Returns Promise<void>

setVariantOptions

  • Change the current options from the variant.

    Parameters

    Returns Promise<void>

stopCurrentProcess

  • stopCurrentProcess(): Promise<boolean>
  • Stops the currently running process at user request

    Returns Promise<boolean>

Private testHaveCommand

  • testHaveCommand(program: string, args?: string[]): Promise<boolean>
  • Parameters

    • program: string
    • Default value args: string[] = ['--version']

    Returns Promise<boolean>

Static createDerived

  • createDerived<T>(inst: T, kit: Kit | null): Promise<T>
  • Asynchronous initialization. Should be called by base classes during their initialization.

    Type parameters

    Parameters

    • inst: T
    • kit: Kit | null

    Returns Promise<T>

Generated using TypeDoc