Skip to content

Commit

Permalink
Add vendor hostOs targetOs targetArch versionMajor versionMinor attri…
Browse files Browse the repository at this point in the history
…butes for kit.

Remove the usage of translation clang.for.msvc
  • Loading branch information
lygstate committed Jul 23, 2020
1 parent f0ef42c commit 195d0ba
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 63 deletions.
6 changes: 6 additions & 0 deletions docs/cmake-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ Some options support the replacement of special values in their string value by
|`${workspaceRootFolderName}`| The name of the leaf directory in the workspace directory path.|
|`${buildType}`|The current CMake build type. For example: `Debug`, `Release`, `MinSizeRel`|
|`${buildKit}`| The current CMake kit name. For example: `GCC 7.3.0`|
|`${buildKitVendor}`| The current CMake kit vendor. Possible values: `gnu|msvc|llvm` and so on, all lowercase|
|`${buildKitHostOs}`| The current CMake kit host OS. Possible values: `win32|osx|linux` and so on, all lowercase|
|`${buildKitTargetOs}`| The current CMake kit target OS. Possible values: `win32|osx|linux` and so on, all lowercase|
|`${buildKitTargetArch}`| The current CMake kit target architecture. Possible values `x86,x64,arm,aarch64` and so on, all lowercase|
|`${buildKitVersionMajor}`| The current CMake kit major version. For example: `7`|
|`${buildKitVersionMinor}`| The current CMake kit minor version. For example: `3`|
|`${generator}`| The name of the CMake generator. For example: `Ninja`|
|`${projectName}`|**DEPRECATED**. Expands to the constant string `"ProjectName"` CMake does not consider there to be just one project name to use. The concept of a single project does not work in CMake. Use `${workspaceRootFolderName}`, instead.|
|`${userHome}`| The full path to the current user's home directory. |
Expand Down
24 changes: 24 additions & 0 deletions schemas/kits-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@
"type": "string",
"description": "Name of this kit"
},
"vendor": {
"type": "string",
"description": "The vendor of this kit"
},
"hostOs": {
"type": "string",
"description": "The host OS of this kit"
},
"targetOs": {
"type": "string",
"description": "The target OS of this kit"
},
"targetArch": {
"type": "string",
"description": "The target architecture of this kit"
},
"versionMajor": {
"type": "string",
"description": "The major version of this kit"
},
"versionMinor": {
"type": "string",
"description": "The minor version of this kit"
},
"keep": {
"type": "boolean",
"description": "If `true`, this kit will be kept even if it appears out-of-date."
Expand Down
11 changes: 10 additions & 1 deletion src/drivers/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {CMakeOutputConsumer} from '@cmt/diagnostics/cmake';
import {RawDiagnosticParser} from '@cmt/diagnostics/util';
import {ProgressMessage} from '@cmt/drivers/cms-client';
import * as expand from '@cmt/expand';
import {CMakeGenerator, effectiveKitEnvironment, Kit, kitChangeNeedsClean} from '@cmt/kit';
import {CMakeGenerator, effectiveKitEnvironment, Kit, kitChangeNeedsClean, KitExpand, getKitExpand} from '@cmt/kit';
import * as logging from '@cmt/logging';
import paths from '@cmt/paths';
import {fs} from '@cmt/pr';
Expand Down Expand Up @@ -167,6 +167,8 @@ export abstract class CMakeDriver implements vscode.Disposable {
*/
private _kit: Kit|null = null;

private _kitExpand: KitExpand|null = null;

/**
* Get the environment and apply any needed
* substitutions before returning it.
Expand Down Expand Up @@ -218,6 +220,12 @@ export abstract class CMakeDriver implements vscode.Disposable {
generator: this.generatorName || 'null',
userHome: paths.userHome,
buildKit: this._kit ? this._kit.name : '__unknownkit__',
buildKitVendor: this._kitExpand?.vendor ?? '__unknow_vendor__',
buildKitHostOs: this._kitExpand?.hostOs ?? '__unknow_host_os__',
buildKitTargetOs: this._kitExpand?.targetOs ?? '__unknow_target_os__',
buildKitTargetArch: this._kitExpand?.targetArch ?? '__unknow_target_arch__',
buildKitVersionMajor: this._kitExpand?.versionMajor ?? '__unknow_version_major__',
buildKitVersionMinor: this._kitExpand?.versionMinor ?? '__unknow_version_minor__',
// DEPRECATED EXPANSION: Remove this in the future:
projectName: 'ProjectName',
};
Expand Down Expand Up @@ -325,6 +333,7 @@ export abstract class CMakeDriver implements vscode.Disposable {

private async _setKit(kit: Kit, preferredGenerators: CMakeGenerator[]): Promise<void> {
this._kit = Object.seal({...kit});
this._kitExpand = await getKitExpand(this._kit);
log.debug(localize('cmakedriver.kit.set.to', 'CMakeDriver Kit set to {0}', kit.name));
this._kitEnvironmentVariables = await effectiveKitEnvironment(kit, this.expansionOptions);

Expand Down
6 changes: 6 additions & 0 deletions src/expand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export interface RequiredExpansionContextVars {
workspaceFolder: string;
buildType: string;
buildKit: string;
buildKitVendor: string;
buildKitHostOs: string;
buildKitTargetOs: string;
buildKitTargetArch: string;
buildKitVersionMajor: string;
buildKitVersionMinor: string;
workspaceRootFolderName: string;
workspaceFolderBasename: string;
generator: string;
Expand Down
Loading

0 comments on commit 195d0ba

Please sign in to comment.