Using eslint (#1882)
This commit is contained in:
Родитель
5156572364
Коммит
e86a553ec2
|
@ -0,0 +1,4 @@
|
|||
*.js
|
||||
test/**/index.ts
|
||||
test/**/runTest.ts
|
||||
tools/prepublish.js
|
|
@ -0,0 +1,156 @@
|
|||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": "tsconfig.json",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"@typescript-eslint/tslint",
|
||||
"eslint-plugin-jsdoc",
|
||||
"@typescript-eslint/eslint-plugin-tslint",
|
||||
"eslint-plugin-import",
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/naming-convention": [
|
||||
"error",
|
||||
{
|
||||
"selector": "typeLike",
|
||||
"format": ["PascalCase"]
|
||||
}
|
||||
],
|
||||
//"@typescript-eslint/indent": "error",
|
||||
"@typescript-eslint/member-delimiter-style": [
|
||||
"error",
|
||||
{
|
||||
"multiline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": true
|
||||
},
|
||||
"singleline": {
|
||||
"delimiter": "semi",
|
||||
"requireLast": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
//"@typescript-eslint/no-namespace": "error",
|
||||
//"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
||||
"@typescript-eslint/no-this-alias": "error",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
||||
//"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-function-type": "error",
|
||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||
"@typescript-eslint/semi": "error",
|
||||
"@typescript-eslint/triple-slash-reference": "error",
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
//"@typescript-eslint/unified-signatures": "error",
|
||||
"arrow-body-style": "error",
|
||||
// Note: You can use auto-fix to apply this rule only after making indentation rule available.
|
||||
//"brace-style": "error",
|
||||
"comma-dangle": "error",
|
||||
"constructor-super": "error",
|
||||
"curly": "error",
|
||||
"eol-last": "error",
|
||||
"eqeqeq": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
//"import/no-default-export": "error",
|
||||
"import/no-unassigned-import": "error",
|
||||
"jsdoc/no-types": "error",
|
||||
"new-parens": "error",
|
||||
"no-bitwise": "error",
|
||||
"no-caller": "error",
|
||||
"no-cond-assign": "error",
|
||||
//"no-debugger": "error",
|
||||
"no-duplicate-case": "error",
|
||||
//"no-duplicate-imports": "error",
|
||||
"no-eval": "error",
|
||||
"no-fallthrough": "error",
|
||||
//"no-invalid-this": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1, "maxBOF": 0 }],
|
||||
"no-new-wrappers": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-return-await": "error",
|
||||
"no-sequences": "error",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-var": "error",
|
||||
"one-var": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"prefer-const": "error",
|
||||
"prefer-object-spread": "error",
|
||||
"space-in-parens": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
/*"spaced-comment": [
|
||||
"error",
|
||||
"always"
|
||||
],*/
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "error",
|
||||
"yoda": "error",
|
||||
"@typescript-eslint/tslint/config": [
|
||||
"error",
|
||||
{
|
||||
"rules": {
|
||||
"encoding": true,
|
||||
/*"file-header": [
|
||||
true,
|
||||
".*"
|
||||
],*/
|
||||
"import-spacing": true,
|
||||
"match-default-export-name": true,
|
||||
"no-boolean-literal-compare": true,
|
||||
"no-mergeable-namespace": true,
|
||||
"no-reference-import": true,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"number-literal-format": true,
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
"check-finally",
|
||||
"check-else",
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"prefer-method-signature": true,
|
||||
"prefer-while": true,
|
||||
/*"typedef": [
|
||||
true,
|
||||
"variable-declaration",
|
||||
"call-signature",
|
||||
"variable-declaration-ignore-function"
|
||||
],*/
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-preblock",
|
||||
"check-type"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
16
gulpfile.js
16
gulpfile.js
|
@ -6,6 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
const eslint = require('gulp-eslint');
|
||||
const fs = require('fs');
|
||||
const nls = require('vscode-nls-dev');
|
||||
const path = require('path');
|
||||
|
@ -253,3 +254,18 @@ const generateJsonSchemaLoc = () => {
|
|||
};
|
||||
|
||||
gulp.task('translations-generate', gulp.series(generatedSrcLocBundle, generatedAdditionalLocFiles, generateJsonSchemaLoc));
|
||||
|
||||
const allTypeScript = [
|
||||
'src/**/*.ts',
|
||||
'!**/*.d.ts',
|
||||
'!**/typings**'
|
||||
];
|
||||
|
||||
gulp.task('lint', function () {
|
||||
// Un-comment these parts for applying auto-fix.
|
||||
return gulp.src(allTypeScript)
|
||||
.pipe(eslint({ configFile: ".eslintrc.js" /*, fix: true*/ }))
|
||||
.pipe(eslint.format())
|
||||
//.pipe(gulp.dest(file => file.base))
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
10
package.json
10
package.json
|
@ -1904,8 +1904,7 @@
|
|||
"translations-import": "gulp translations-import",
|
||||
"pretest": "tsc -p test.tsconfig.json",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"lint": "node ./node_modules/tslint/bin/tslint -p . --fix",
|
||||
"lint:nofix": "node ./node_modules/tslint/bin/tslint -p .",
|
||||
"lint": "gulp lint",
|
||||
"docs": "node ./node_modules/typedoc/bin/typedoc --excludeExternals --out build/docs/dev --readme none src/ types/"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1923,13 +1922,20 @@
|
|||
"@types/tmp": "^0.2.0",
|
||||
"@types/which": "~2.0.0",
|
||||
"@types/xml2js": "^0.4.8",
|
||||
"@typescript-eslint/eslint-plugin": "^4.22.1",
|
||||
"@typescript-eslint/eslint-plugin-tslint": "^4.22.1",
|
||||
"@typescript-eslint/parser": "^4.22.1",
|
||||
"chai": "^4.3.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-string": "^1.5.0",
|
||||
"clang-format": "^1.5.0",
|
||||
"eslint": "^7.25.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jsdoc": "^33.1.0",
|
||||
"event-stream": "^4.0.1",
|
||||
"fs-extra": "^9.1.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-eslint": "^6.0.0",
|
||||
"gulp-filter": "^6.0.0",
|
||||
"gulp-sourcemaps": "^3.0.0",
|
||||
"gulp-typescript": "^5.0.1",
|
||||
|
|
|
@ -107,8 +107,8 @@ Invoke-ChronicCommand "Compiling TypeScript" $yarn run compile-production
|
|||
# Now compile test code
|
||||
Invoke-ChronicCommand "Compiling Tests" $yarn run pretest
|
||||
|
||||
# Run TSLint to check for silly mistakes
|
||||
Invoke-ChronicCommand "Running TSLint" $yarn run lint:nofix
|
||||
# Run EsLint to check for silly mistakes
|
||||
Invoke-ChronicCommand "Running TSLint" $yarn run lint
|
||||
|
||||
# Get the CMake binary that we will use to run our tests
|
||||
$cmake_binary = Install-TestCMake -Version "3.16.2"
|
||||
|
|
|
@ -312,4 +312,4 @@ export interface CMakeToolsAPI extends Disposable {
|
|||
* Get the build kit
|
||||
*/
|
||||
buildKit(): Thenable<string|null>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ export interface IOption {
|
|||
dirty: boolean; // if the variable was edited in the UI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This object manages the webview rendering.
|
||||
*/
|
||||
|
@ -28,7 +27,9 @@ export class ConfigurationWebview {
|
|||
|
||||
// The dirty state of the whole webview.
|
||||
private _dirty: boolean = false;
|
||||
get dirty(): boolean { return this._dirty; }
|
||||
get dirty(): boolean {
|
||||
return this._dirty;
|
||||
}
|
||||
set dirty(d: boolean) {
|
||||
this._dirty = d;
|
||||
|
||||
|
@ -422,7 +423,7 @@ export class ConfigurationWebview {
|
|||
const vscode = acquireVsCodeApi();
|
||||
function toggleKey(id) {
|
||||
const label = document.getElementById('LABEL_' + id);
|
||||
label.textContent = label.textContent == 'ON' ? 'OFF' : 'ON';
|
||||
label.textContent = label.textContent === 'ON' ? 'OFF' : 'ON';
|
||||
const checkbox = document.getElementById(id);
|
||||
vscode.postMessage({key: id, type: "Bool", value: checkbox.checked});
|
||||
document.getElementById('not-saved').classList.remove('invisible');
|
||||
|
@ -493,4 +494,4 @@ export class ConfigurationWebview {
|
|||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
46
src/cache.ts
46
src/cache.ts
|
@ -15,7 +15,6 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|||
|
||||
const log = logging.createLogger('cache');
|
||||
|
||||
|
||||
/**
|
||||
* Implements access to CMake cache entries. See `api.CacheEntry` for more
|
||||
* information. This type is immutable.
|
||||
|
@ -27,17 +26,29 @@ export class Entry implements api.CacheEntry {
|
|||
private readonly _value: any = null;
|
||||
private readonly _advanced: boolean = false;
|
||||
|
||||
get type() { return this._type; }
|
||||
get type() {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
get helpString() { return this._docs; }
|
||||
get helpString() {
|
||||
return this._docs;
|
||||
}
|
||||
|
||||
get key() { return this._key; }
|
||||
get key() {
|
||||
return this._key;
|
||||
}
|
||||
|
||||
get value() { return this._value; }
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
as<T>(): T { return this.value as T; }
|
||||
as<T>(): T {
|
||||
return this.value as T;
|
||||
}
|
||||
|
||||
get advanced() { return this._advanced; }
|
||||
get advanced() {
|
||||
return this._advanced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Cache Entry instance. Doesn't modify any files. You probably
|
||||
|
@ -91,7 +102,9 @@ export class CMakeCache {
|
|||
}
|
||||
|
||||
/** Get a list of all cache entries */
|
||||
get allEntries(): Entry[] { return Array.from(this._entries.values()); }
|
||||
get allEntries(): Entry[] {
|
||||
return Array.from(this._entries.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance. This is **private**. You may only create an instance
|
||||
|
@ -108,12 +121,16 @@ export class CMakeCache {
|
|||
* `true` if the file exists when this instance was created.
|
||||
* `false` otherwise.
|
||||
*/
|
||||
get exists() { return this._exists; }
|
||||
get exists() {
|
||||
return this._exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* The path to the cache file, which may not exist
|
||||
*/
|
||||
get path() { return this._path; }
|
||||
get path() {
|
||||
return this._path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the cache file and return a new instance. This will not modify this
|
||||
|
@ -147,8 +164,9 @@ export class CMakeCache {
|
|||
}
|
||||
const [, , quoted_name, unquoted_name, typename, valuestr] = match;
|
||||
const name = quoted_name || unquoted_name;
|
||||
if (!name || !typename)
|
||||
if (!name || !typename) {
|
||||
continue;
|
||||
}
|
||||
log.trace(localize('read.line.in.cache', 'Read line in cache with {0}={1}, {2}={3}, {4}={5}', 'name', name, 'typename', typename, 'valuestr', valuestr));
|
||||
if (name.endsWith('-ADVANCED') && valuestr === '1') {
|
||||
log.trace(localize('skipping.variable', 'Skipping {0} variable', '*-ADVANCED'));
|
||||
|
@ -162,7 +180,7 @@ export class CMakeCache {
|
|||
FILEPATH: api.CacheEntryType.FilePath,
|
||||
INTERNAL: api.CacheEntryType.Internal,
|
||||
UNINITIALIZED: api.CacheEntryType.Uninitialized,
|
||||
STATIC: api.CacheEntryType.Static,
|
||||
STATIC: api.CacheEntryType.Static
|
||||
} as {[type: string]: api.CacheEntryType | undefined};
|
||||
const type = typemap[typename];
|
||||
const docs = docs_acc.trim();
|
||||
|
@ -216,7 +234,7 @@ export class CMakeCache {
|
|||
return '';
|
||||
}
|
||||
|
||||
async replaceOptions(options: Array<{key: string, value: string}>): Promise<string> {
|
||||
async replaceOptions(options: {key: string; value: string}[]): Promise<string> {
|
||||
const exists = await fs.exists(this.path);
|
||||
if (exists) {
|
||||
let content = (await fs.readFile(this.path)).toString();
|
||||
|
@ -237,7 +255,7 @@ export class CMakeCache {
|
|||
}
|
||||
}
|
||||
|
||||
async saveAll(options: Array<{key: string, value: string}>): Promise<void> {
|
||||
async saveAll(options: {key: string; value: string}[]): Promise<void> {
|
||||
const content = await this.replaceOptions(options);
|
||||
if (content) {
|
||||
if (await fs.exists(this.path)) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import {CMakeCache} from '@cmt/cache';
|
|||
import {CMakeExecutable, getCMakeExecutableInformation} from '@cmt/cmake/cmake-executable';
|
||||
import {CompilationDatabase} from '@cmt/compdb';
|
||||
import * as debugger_mod from '@cmt/debugger';
|
||||
import diagCollections from '@cmt/diagnostics/collections';
|
||||
import collections from '@cmt/diagnostics/collections';
|
||||
import * as shlex from '@cmt/shlex';
|
||||
import {StateManager} from '@cmt/state';
|
||||
import {Strand} from '@cmt/strand';
|
||||
|
@ -149,7 +149,6 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
set minCMakeVersion(version: Version | undefined) { this._minCMakeVersion = version; }
|
||||
private _minCMakeVersion?: Version;
|
||||
|
||||
|
||||
/**
|
||||
* Currently selected configure preset
|
||||
*/
|
||||
|
@ -428,7 +427,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
* Dispose of the extension asynchronously.
|
||||
*/
|
||||
async asyncDispose() {
|
||||
diagCollections.reset();
|
||||
collections.reset();
|
||||
if (this._cmakeDriver) {
|
||||
const drv = await this._cmakeDriver;
|
||||
if (drv) {
|
||||
|
@ -442,7 +441,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
this._testResults,
|
||||
this._isBusy,
|
||||
this._variantManager,
|
||||
this._ctestController,
|
||||
this._ctestController
|
||||
]) {
|
||||
disp.dispose();
|
||||
}
|
||||
|
@ -456,7 +455,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
return [{
|
||||
name: user_generator,
|
||||
platform: this.workspaceContext.config.platform || undefined,
|
||||
toolset: this.workspaceContext.config.toolset || undefined,
|
||||
toolset: this.workspaceContext.config.toolset || undefined
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -501,7 +500,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(this.folder.uri.fsPath),
|
||||
filters: {"CMake files": ["txt"], "All files": ["*"]},
|
||||
openLabel: "Load",
|
||||
openLabel: "Load"
|
||||
};
|
||||
const cmakeListsFile = await vscode.window.showOpenDialog(openOpts);
|
||||
if (cmakeListsFile) {
|
||||
|
@ -789,7 +788,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
}));
|
||||
}
|
||||
|
||||
async isNinjaInstalled() : Promise<boolean> {
|
||||
async isNinjaInstalled(): Promise<boolean> {
|
||||
const drv = await this._cmakeDriver;
|
||||
|
||||
if (drv) {
|
||||
|
@ -826,8 +825,9 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
async getCMakeExecutable() {
|
||||
const overWriteCMakePathSetting = this.useCMakePresets ? this.configurePreset?.cmakeExecutable : undefined;
|
||||
let cmakePath = await this.workspaceContext.getCMakePath(overWriteCMakePathSetting);
|
||||
if (!cmakePath)
|
||||
if (!cmakePath) {
|
||||
cmakePath = '';
|
||||
}
|
||||
const cmakeExe = await getCMakeExecutableInformation(cmakePath);
|
||||
if (cmakeExe.version && this.minCMakeVersion && versionLess(cmakeExe.version, this.minCMakeVersion)) {
|
||||
rollbar.error(localize('cmake.version.not.supported',
|
||||
|
@ -873,7 +873,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
.showErrorMessage(localize('source.directory.does.not.match',
|
||||
'The source directory "{0}" does not match the source directory in the CMake cache: {1}. You will need to run a clean-configure to configure this project.', e.expecting, e.cached),
|
||||
{},
|
||||
{title: localize('clean.configure.title', 'Clean Configure')},
|
||||
{title: localize('clean.configure.title', 'Clean Configure')}
|
||||
)
|
||||
.then(chosen => {
|
||||
if (chosen) {
|
||||
|
@ -994,7 +994,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
return vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('configuring.project', 'Configuring project'),
|
||||
title: localize('configuring.project', 'Configuring project')
|
||||
},
|
||||
async progress => {
|
||||
progress.report({message: localize('preparing.to.configure', 'Preparing to configure')});
|
||||
|
@ -1017,7 +1017,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
progress.report({message: localize('configuring.project', 'Configuring project')});
|
||||
let retc: number;
|
||||
await setContextValue(IS_CONFIGURING_KEY, true);
|
||||
if (type == ConfigureType.Cache) {
|
||||
if (type === ConfigureType.Cache) {
|
||||
retc = await drv.configure(trigger, [], consumer, true);
|
||||
} else {
|
||||
switch (type) {
|
||||
|
@ -1051,7 +1051,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
return -1;
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1081,11 +1081,11 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
vscode.MessageItem>(localize('not.saved.continue.anyway', 'Not all open documents were saved. Would you like to continue anyway?'),
|
||||
{
|
||||
title: yesButtonTitle,
|
||||
isCloseAffordance: false,
|
||||
isCloseAffordance: false
|
||||
},
|
||||
{
|
||||
title: localize('no.button', 'No'),
|
||||
isCloseAffordance: true,
|
||||
isCloseAffordance: true
|
||||
});
|
||||
return chosen !== undefined && (chosen.title === yesButtonTitle);
|
||||
}
|
||||
|
@ -1115,13 +1115,13 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
} else if (!this.configurePreset){
|
||||
} else if (!this.configurePreset) {
|
||||
throw new Error(localize('cannot.configure.no.config.preset', 'Cannot configure: No configure preset is active for this CMake Tools'));
|
||||
}
|
||||
log.showChannel();
|
||||
const consumer = new CMakeOutputConsumer(await this.sourceDir, CMAKE_LOGGER);
|
||||
const retc = await cb(consumer);
|
||||
populateCollection(diagCollections.cmake, consumer.diagnostics);
|
||||
populateCollection(collections.cmake, consumer.diagnostics);
|
||||
return retc;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1232,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('building.target', 'Building: {0}', targetName),
|
||||
cancellable: true,
|
||||
cancellable: true
|
||||
},
|
||||
async (progress, cancel) => {
|
||||
let old_progress = 0;
|
||||
|
@ -1255,9 +1255,9 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
BUILD_LOGGER.info(localize('build.finished.with.code', 'Build finished with exit code {0}', rc));
|
||||
}
|
||||
const file_diags = consumer.compileConsumer.resolveDiagnostics(drv.binaryDir);
|
||||
populateCollection(diagCollections.build, file_diags);
|
||||
populateCollection(collections.build, file_diags);
|
||||
return rc === null ? -1 : rc;
|
||||
},
|
||||
}
|
||||
);
|
||||
} finally {
|
||||
await setContextValue(IS_BUILDING_KEY, false);
|
||||
|
@ -1312,8 +1312,9 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
localize('project.not.yet.configured', 'This project has not yet been configured'),
|
||||
localize('configure.now.button', 'Configure Now')));
|
||||
if (do_conf) {
|
||||
if (await this.configureInternal() !== 0)
|
||||
if (await this.configureInternal() !== 0) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -1351,8 +1352,9 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
|
||||
async buildWithTarget(): Promise<number> {
|
||||
const target = await this.showTargetSelector();
|
||||
if (target === null)
|
||||
if (target === null) {
|
||||
return -1;
|
||||
}
|
||||
return this.build(target);
|
||||
}
|
||||
|
||||
|
@ -1371,7 +1373,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
case 'named': {
|
||||
return {
|
||||
label: t.name,
|
||||
description: localize('target.to.build.description', 'Target to build'),
|
||||
description: localize('target.to.build.description', 'Target to build')
|
||||
};
|
||||
}
|
||||
case 'rich': {
|
||||
|
@ -1387,15 +1389,18 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
/**
|
||||
* Implementaiton of `cmake.clean`
|
||||
*/
|
||||
async clean(): Promise<number> { return this.build('clean'); }
|
||||
async clean(): Promise<number> {
|
||||
return this.build('clean');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of `cmake.cleanRebuild`
|
||||
*/
|
||||
async cleanRebuild(): Promise<number> {
|
||||
const clean_res = await this.clean();
|
||||
if (clean_res !== 0)
|
||||
if (clean_res !== 0) {
|
||||
return clean_res;
|
||||
}
|
||||
return this.build();
|
||||
}
|
||||
|
||||
|
@ -1517,13 +1522,13 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
const choices = executableTargets.map(e => ({
|
||||
label: e.name,
|
||||
description: '',
|
||||
detail: e.path,
|
||||
detail: e.path
|
||||
}));
|
||||
let chosen: {label: string, detail: string}|undefined = undefined;
|
||||
let chosen: {label: string; detail: string}|undefined;
|
||||
if (!name) {
|
||||
chosen = await vscode.window.showQuickPick(choices, {placeHolder: localize('select.a.launch.target', 'Select a launch target for {0}', this.folder.name)});
|
||||
} else {
|
||||
chosen = choices.find(choice => choice.label == name);
|
||||
chosen = choices.find(choice => choice.label === name);
|
||||
}
|
||||
if (!chosen) {
|
||||
return null;
|
||||
|
@ -1535,7 +1540,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
|
||||
async getCurrentLaunchTarget(): Promise<api.ExecutableTarget|null> {
|
||||
const target_name = this.workspaceContext.state.launchTargetName;
|
||||
const target = (await this.executableTargets).find(e => e.name == target_name);
|
||||
const target = (await this.executableTargets).find(e => e.name === target_name);
|
||||
|
||||
if (!target) {
|
||||
return null;
|
||||
|
@ -1721,7 +1726,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
vscode.window
|
||||
.showWarningMessage(localize('target.debugging.unsupported', 'Target debugging is no longer supported with the legacy driver'), {
|
||||
title: localize('learn.more.button', 'Learn more'),
|
||||
isLearnMore: true,
|
||||
isLearnMore: true
|
||||
})
|
||||
.then(item => {
|
||||
if (item && item.isLearnMore) {
|
||||
|
@ -1748,7 +1753,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
vscode.window
|
||||
.showErrorMessage(error.message, {
|
||||
title: localize('debugging.documentation.button', 'Debugging documentation'),
|
||||
isLearnMore: true,
|
||||
isLearnMore: true
|
||||
})
|
||||
.then(item => {
|
||||
if (item && item.isLearnMore) {
|
||||
|
@ -1770,7 +1775,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
Object.assign(debug_config, user_config);
|
||||
log.debug(localize('starting.debugger.with', 'Starting debugger with following configuration.'), JSON.stringify({
|
||||
workspace: this.folder.uri.toString(),
|
||||
config: debug_config,
|
||||
config: debug_config
|
||||
}));
|
||||
|
||||
const cfg = vscode.workspace.getConfiguration('cmake', this.folder.uri).inspect<object>('debugConfig');
|
||||
|
@ -1811,14 +1816,15 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
const user_config = this.workspaceContext.config.debugConfig;
|
||||
const termOptions: vscode.TerminalOptions = {
|
||||
name: 'CMake/Launch',
|
||||
cwd: (user_config && user_config.cwd) || path.dirname(executable.path),
|
||||
cwd: (user_config && user_config.cwd) || path.dirname(executable.path)
|
||||
};
|
||||
if (process.platform == 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
// Use cmd.exe on Windows
|
||||
termOptions.shellPath = paths.windows.ComSpec;
|
||||
}
|
||||
if (!this._launchTerminal)
|
||||
if (!this._launchTerminal) {
|
||||
this._launchTerminal = vscode.window.createTerminal(termOptions);
|
||||
}
|
||||
const quoted = shlex.quote(executable.path);
|
||||
|
||||
let launchArgs = '';
|
||||
|
@ -1851,24 +1857,27 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
const project_name = await vscode.window.showInputBox({
|
||||
prompt: localize('new.project.name', 'Enter a name for the new project'),
|
||||
validateInput: (value: string): string => {
|
||||
if (!value.length)
|
||||
if (!value.length) {
|
||||
return localize('project.name.required', 'A project name is required');
|
||||
}
|
||||
return '';
|
||||
},
|
||||
}
|
||||
});
|
||||
if (!project_name)
|
||||
if (!project_name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const target_type = (await vscode.window.showQuickPick([
|
||||
{
|
||||
label: 'Library',
|
||||
description: localize('create.library', 'Create a library'),
|
||||
description: localize('create.library', 'Create a library')
|
||||
},
|
||||
{label: 'Executable', description: localize('create.executable', 'Create an executable')}
|
||||
]));
|
||||
|
||||
if (!target_type)
|
||||
if (!target_type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const type = target_type.label;
|
||||
|
||||
|
@ -1879,13 +1888,13 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
'include(CTest)',
|
||||
'enable_testing()',
|
||||
'',
|
||||
type == 'Library' ? `add_library(${project_name} ${project_name}.cpp)`
|
||||
type === 'Library' ? `add_library(${project_name} ${project_name}.cpp)`
|
||||
: `add_executable(${project_name} main.cpp)`,
|
||||
'',
|
||||
'set(CPACK_PROJECT_NAME ${PROJECT_NAME})',
|
||||
'set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})',
|
||||
'include(CPack)',
|
||||
'',
|
||||
''
|
||||
].join('\n');
|
||||
|
||||
if (type === 'Library') {
|
||||
|
@ -1896,7 +1905,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
'void say_hello(){',
|
||||
` std::cout << "Hello, from ${project_name}!\\n";`,
|
||||
'}',
|
||||
'',
|
||||
''
|
||||
].join('\n'));
|
||||
}
|
||||
} else {
|
||||
|
@ -1907,7 +1916,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
'int main(int, char**) {',
|
||||
' std::cout << "Hello, world!\\n";',
|
||||
'}',
|
||||
'',
|
||||
''
|
||||
].join('\n'));
|
||||
}
|
||||
}
|
||||
|
@ -1919,7 +1928,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
|
|||
// Regardless of the following configure return code,
|
||||
// we want full feature set view for the whole workspace.
|
||||
enableFullFeatureSet(true);
|
||||
return this.configureInternal(ConfigureTrigger.quickStart, [], ConfigureType.Normal,);
|
||||
return this.configureInternal(ConfigureTrigger.quickStart, [], ConfigureType.Normal);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,12 +16,12 @@ export async function getCMakeExecutableInformation(path: string): Promise<CMake
|
|||
path,
|
||||
isPresent: false,
|
||||
minimalServerModeVersion: util.parseVersion('3.7.1'),
|
||||
minimalFileApiModeVersion: util.parseVersion('3.14.0'),
|
||||
minimalFileApiModeVersion: util.parseVersion('3.14.0')
|
||||
};
|
||||
|
||||
// The check for 'path' seems unnecessary, but crash logs tell us otherwise. It is not clear
|
||||
// what causes 'path' to be undefined here.
|
||||
if (path && path.length != 0) {
|
||||
if (path && path.length !== 0) {
|
||||
try {
|
||||
const version_ex = await proc.execute(path, ['--version']).result;
|
||||
if (version_ex.retc === 0 && version_ex.stdout) {
|
||||
|
|
|
@ -163,14 +163,14 @@ export function getCodePageTable(): CodePageTable {
|
|||
[57010]: 'x-iscii-gu',
|
||||
[57011]: 'x-iscii-pa',
|
||||
[65000]: 'utf-7',
|
||||
[65001]: 'utf-8',
|
||||
[65001]: 'utf-8'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A promise for idempotent codepage aquisition. @see getWindowsCodepage
|
||||
*/
|
||||
let _CODEPAGE: Promise<string>|undefined = undefined;
|
||||
let _CODEPAGE: Promise<string>|undefined;
|
||||
|
||||
/**
|
||||
* Return the currently active Windows codepage (done by calling chcp in a subprocess');
|
||||
|
|
|
@ -30,9 +30,9 @@ export class CompilationDatabase {
|
|||
file: cur.file,
|
||||
output: cur.output,
|
||||
command: cur.command,
|
||||
arguments: cur.arguments ? cur.arguments : [...shlex.split(cur.command)],
|
||||
arguments: cur.arguments ? cur.arguments : [...shlex.split(cur.command)]
|
||||
}),
|
||||
new Map<string, ArgsCompileCommand>(),
|
||||
new Map<string, ArgsCompileCommand>()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ export interface ExtensionConfigurationSettings {
|
|||
buildToolArgs: string[];
|
||||
parallelJobs: number;
|
||||
ctestPath: string;
|
||||
ctest: {parallelJobs: number;};
|
||||
ctest: {parallelJobs: number};
|
||||
parseBuildDiagnostics: boolean;
|
||||
enabledOutputParsers: string[];
|
||||
debugConfig: object;
|
||||
|
@ -193,7 +193,7 @@ export class ConfigurationReader implements vscode.Disposable {
|
|||
const platmap = {
|
||||
win32: 'windows',
|
||||
darwin: 'osx',
|
||||
linux: 'linux',
|
||||
linux: 'linux'
|
||||
} as {[k: string]: string};
|
||||
const platform = platmap[process.platform];
|
||||
const for_platform = (data as any)[platform] as ExtensionConfigurationSettings | undefined;
|
||||
|
@ -271,7 +271,7 @@ export class ConfigurationReader implements vscode.Disposable {
|
|||
|
||||
get cmakeCommunicationMode(): CMakeCommunicationMode {
|
||||
let communicationMode = this.configData.cmakeCommunicationMode;
|
||||
if (communicationMode == "automatic" && this.useCMakeServer) {
|
||||
if (communicationMode === "automatic" && this.useCMakeServer) {
|
||||
log.warning(localize(
|
||||
'please.upgrade.configuration',
|
||||
'The setting \'useCMakeServer\' is replaced by \'cmakeCommunicationMode\'. Please upgrade your configuration.'));
|
||||
|
@ -335,7 +335,7 @@ export class ConfigurationReader implements vscode.Disposable {
|
|||
buildToolArgs: new vscode.EventEmitter<string[]>(),
|
||||
parallelJobs: new vscode.EventEmitter<number>(),
|
||||
ctestPath: new vscode.EventEmitter<string>(),
|
||||
ctest: new vscode.EventEmitter<{parallelJobs: number;}>(),
|
||||
ctest: new vscode.EventEmitter<{parallelJobs: number}>(),
|
||||
parseBuildDiagnostics: new vscode.EventEmitter<boolean>(),
|
||||
enabledOutputParsers: new vscode.EventEmitter<string[]>(),
|
||||
debugConfig: new vscode.EventEmitter<object>(),
|
||||
|
|
|
@ -84,7 +84,7 @@ function parseTargetArch(target: string): Architecture {
|
|||
// Value of target param is lowercased.
|
||||
const is_arm_32: (value: string) => boolean = value => {
|
||||
// ARM verions from https://en.wikipedia.org/wiki/ARM_architecture#Cores
|
||||
if (value.indexOf('armv8-r') >=0 || value.indexOf('armv8-m') >=0) {
|
||||
if (value.indexOf('armv8-r') >= 0 || value.indexOf('armv8-m') >= 0) {
|
||||
return true;
|
||||
} else {
|
||||
// Check if ARM version is 7 or earlier.
|
||||
|
@ -93,7 +93,7 @@ function parseTargetArch(target: string): Architecture {
|
|||
return verNum <= 7;
|
||||
}
|
||||
};
|
||||
switch(target) {
|
||||
switch (target) {
|
||||
case '-m32':
|
||||
case 'i686':
|
||||
return 'x86';
|
||||
|
@ -123,8 +123,8 @@ export function parseCompileFlags(cptVersion: cpt.Version, args: string[], lang?
|
|||
const can_use_gnu_std = (cptVersion >= cpt.Version.v4);
|
||||
const iter = args[Symbol.iterator]();
|
||||
const extraDefinitions: string[] = [];
|
||||
let standard: StandardVersion = undefined;
|
||||
let targetArch: Architecture = undefined;
|
||||
let standard: StandardVersion;
|
||||
let targetArch: Architecture;
|
||||
while (1) {
|
||||
const {done, value} = iter.next();
|
||||
if (done) {
|
||||
|
@ -171,14 +171,14 @@ export function parseCompileFlags(cptVersion: cpt.Version, args: string[], lang?
|
|||
extraDefinitions.push(def);
|
||||
} else if (value.startsWith('-std=') || lower.startsWith('-std:') || lower.startsWith('/std:')) {
|
||||
const std = value.substring(5);
|
||||
if (lang === 'CXX' || lang === 'OBJCXX' || lang === 'CUDA' ) {
|
||||
if (lang === 'CXX' || lang === 'OBJCXX' || lang === 'CUDA') {
|
||||
const s = parseCppStandard(std, can_use_gnu_std);
|
||||
if (!s) {
|
||||
log.warning(localize('unknown.control.gflag.cpp', 'Unknown C++ standard control flag: {0}', value));
|
||||
} else {
|
||||
standard = s;
|
||||
}
|
||||
} else if (lang === 'C' || lang === 'OBJC' ) {
|
||||
} else if (lang === 'C' || lang === 'OBJC') {
|
||||
const s = parseCStandard(std, can_use_gnu_std);
|
||||
if (!s) {
|
||||
log.warning(localize('unknown.control.gflag.c', 'Unknown C standard control flag: {0}', value));
|
||||
|
@ -486,7 +486,7 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
|
|||
const data = new Map<string, cpt.SourceFileConfigurationItem>();
|
||||
data.set(target.name, {
|
||||
uri: vscode.Uri.file(abs).toString(),
|
||||
configuration,
|
||||
configuration
|
||||
});
|
||||
this._fileIndex.set(abs_norm, data);
|
||||
}
|
||||
|
@ -522,10 +522,10 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
|
|||
for (const config of opts.codeModel.configurations) {
|
||||
for (const project of config.projects) {
|
||||
for (const target of project.targets) {
|
||||
/// Now some shenanigans since header files don't have config data:
|
||||
/// 1. Accumulate some "defaults" based on the set of all options for each file group
|
||||
/// 2. Pass these "defaults" down when rebuilding the config data
|
||||
/// 3. Any `fileGroup` that does not have the associated attribute will receive the `default`
|
||||
// Now some shenanigans since header files don't have config data:
|
||||
// 1. Accumulate some "defaults" based on the set of all options for each file group
|
||||
// 2. Pass these "defaults" down when rebuilding the config data
|
||||
// 3. Any `fileGroup` that does not have the associated attribute will receive the `default`
|
||||
const grps = target.fileGroups || [];
|
||||
const includePath = [...new Set(util.flatMap(grps, grp => grp.includePath || []))].map(item => item.path);
|
||||
const compileFlags = [...util.flatMap(grps, grp => shlex.split(grp.compileFlags || ''))];
|
||||
|
@ -541,7 +541,7 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
|
|||
name: target.name,
|
||||
compileFlags,
|
||||
includePath,
|
||||
defines,
|
||||
defines
|
||||
},
|
||||
sysroot
|
||||
);
|
||||
|
|
23
src/ctest.ts
23
src/ctest.ts
|
@ -60,30 +60,30 @@ export interface SiteData {
|
|||
Testing: TestingData;
|
||||
}
|
||||
|
||||
export interface CTestResults { Site: SiteData; }
|
||||
export interface CTestResults { Site: SiteData }
|
||||
|
||||
interface EncodedMeasurementValue {
|
||||
$: {encoding?: BufferEncoding; compression?: string;};
|
||||
$: {encoding?: BufferEncoding; compression?: string};
|
||||
_: string;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
interface MessyResults {
|
||||
Site: {
|
||||
$: {},
|
||||
$: {};
|
||||
Testing: {
|
||||
TestList: {Test: string[]}[]; EndDateTime: string[];
|
||||
EndTestTime: string[];
|
||||
ElapsedMinutes: string[];
|
||||
Test: {
|
||||
$: {Status: TestStatus},
|
||||
$: {Status: TestStatus};
|
||||
FullCommandLine: string[];
|
||||
FullName: string[];
|
||||
Name: string[];
|
||||
Path: string[];
|
||||
Results: {
|
||||
NamedMeasurement:
|
||||
{$: {type: string; name: string;}, Value: string[];}[]
|
||||
{$: {type: string; name: string}; Value: string[]}[];
|
||||
Measurement: { Value: [EncodedMeasurementValue|string] }[];
|
||||
}[];
|
||||
}[];
|
||||
|
@ -125,7 +125,7 @@ function cleanupResultsXML(messy: MessyResults): CTestResults {
|
|||
$: messy.Site.$,
|
||||
Testing: {
|
||||
TestList: [],
|
||||
Test: [],
|
||||
Test: []
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -142,7 +142,7 @@ function cleanupResultsXML(messy: MessyResults): CTestResults {
|
|||
Path: test.Path[0],
|
||||
Status: test.$.Status,
|
||||
Measurements: new Map<string, TestMeasurement>(),
|
||||
Output: decodeOutputMeasurement(test.Results[0].Measurement[0].Value[0]),
|
||||
Output: decodeOutputMeasurement(test.Results[0].Measurement[0].Value[0])
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ export async function readTestResultsFile(test_xml: string) {
|
|||
return clean;
|
||||
}
|
||||
|
||||
|
||||
export function parseCatchTestOutput(output: string): FailingTestDecoration[] {
|
||||
const lines_with_ws = output.split('\n');
|
||||
const lines = lines_with_ws.map(l => l.trim());
|
||||
|
@ -182,7 +181,7 @@ export function parseCatchTestOutput(output: string): FailingTestDecoration[] {
|
|||
decorations.push({
|
||||
fileName: file,
|
||||
lineNumber: lineno,
|
||||
hoverMessage: `${message}\n~~~`,
|
||||
hoverMessage: `${message}\n~~~`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -214,8 +213,8 @@ export class DecorationManager {
|
|||
after: {
|
||||
contentText: 'Failed',
|
||||
backgroundColor: 'darkred',
|
||||
margin: '10px',
|
||||
},
|
||||
margin: '10px'
|
||||
}
|
||||
});
|
||||
|
||||
private _binaryDir: string = '';
|
||||
|
@ -262,7 +261,7 @@ export class DecorationManager {
|
|||
file_line.range.end.character);
|
||||
fails_acc.push({
|
||||
hoverMessage: decor.hoverMessage,
|
||||
range,
|
||||
range
|
||||
});
|
||||
}
|
||||
editor.setDecorations(this._failingTestDecorationType, fails_acc);
|
||||
|
|
|
@ -12,7 +12,6 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|||
|
||||
const log = createLogger('debugger');
|
||||
|
||||
|
||||
export enum DebuggerType {
|
||||
VisualStudio = 'Visual Studio',
|
||||
LLDB = 'LLDB',
|
||||
|
@ -40,7 +39,6 @@ export interface DebuggerConfiguration {
|
|||
// launchConfiguration?: string; // Future
|
||||
}
|
||||
|
||||
|
||||
export interface Configuration {
|
||||
type: string;
|
||||
name: string;
|
||||
|
@ -68,8 +66,8 @@ async function createGDBDebugConfiguration(debuggerPath: string, target: Executa
|
|||
{
|
||||
description: localize('enable.pretty.printing', 'Enable pretty-printing for gdb'),
|
||||
text: '-enable-pretty-printing',
|
||||
ignoreFailures: true,
|
||||
},
|
||||
ignoreFailures: true
|
||||
}
|
||||
],
|
||||
program: target.path
|
||||
};
|
||||
|
@ -107,20 +105,20 @@ type DebuggerMIMode = 'gdb'|'lldb';
|
|||
|
||||
type DebuggerGenerators = {
|
||||
[MIMode in DebuggerMIMode]: {
|
||||
miMode: MIMode,
|
||||
createConfig(debuggerPath: string, target: ExecutableTarget): Promise<Configuration>,
|
||||
miMode: MIMode;
|
||||
createConfig(debuggerPath: string, target: ExecutableTarget): Promise<Configuration>;
|
||||
};
|
||||
};
|
||||
|
||||
const DEBUG_GEN: DebuggerGenerators = {
|
||||
gdb: {
|
||||
miMode: 'gdb',
|
||||
createConfig: createGDBDebugConfiguration,
|
||||
createConfig: createGDBDebugConfiguration
|
||||
},
|
||||
lldb: {
|
||||
miMode: 'lldb',
|
||||
createConfig: createLLDBDebugConfiguration,
|
||||
},
|
||||
createConfig: createLLDBDebugConfiguration
|
||||
}
|
||||
};
|
||||
|
||||
function searchForCompilerPathInCache(cache: CMakeCache): string|null {
|
||||
|
@ -161,7 +159,7 @@ export async function getDebugConfigurationFromCache(cache: CMakeCache, target:
|
|||
// 1. LLDB-MI
|
||||
const clang_compiler_regex = /(clang[\+]{0,2})+(?!-cl)/gi;
|
||||
let mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb-mi');
|
||||
if (modeOverride !== "gdb" && (mi_debugger_path.search(new RegExp('lldb-mi')) != -1)) {
|
||||
if (modeOverride !== "gdb" && (mi_debugger_path.search(new RegExp('lldb-mi')) !== -1)) {
|
||||
const cpptoolsExtension = vscode.extensions.getExtension('ms-vscode.cpptools');
|
||||
const cpptoolsDebuggerPath = cpptoolsExtension ? path.join(cpptoolsExtension.extensionPath, "debugAdapters", "lldb-mi", "bin", "lldb-mi") : undefined;
|
||||
// 1a. lldb-mi in the compiler path
|
||||
|
@ -177,18 +175,18 @@ export async function getDebugConfigurationFromCache(cache: CMakeCache, target:
|
|||
|
||||
// 2. gdb in the compiler path
|
||||
mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'gdb');
|
||||
if (modeOverride !== "lldb" && (mi_debugger_path.search(new RegExp('gdb')) != -1) && await checkDebugger(mi_debugger_path)) {
|
||||
if (modeOverride !== "lldb" && (mi_debugger_path.search(new RegExp('gdb')) !== -1) && await checkDebugger(mi_debugger_path)) {
|
||||
return createGDBDebugConfiguration(mi_debugger_path, target);
|
||||
}
|
||||
|
||||
// 3. lldb in the compiler path
|
||||
mi_debugger_path = compiler_path.replace(clang_compiler_regex, 'lldb');
|
||||
if (modeOverride !== "gdb" && (mi_debugger_path.search(new RegExp('lldb')) != -1) && await checkDebugger(mi_debugger_path)) {
|
||||
if (modeOverride !== "gdb" && (mi_debugger_path.search(new RegExp('lldb')) !== -1) && await checkDebugger(mi_debugger_path)) {
|
||||
return createLLDBDebugConfiguration(mi_debugger_path, target);
|
||||
}
|
||||
}
|
||||
|
||||
const debugger_name = modeOverride || (platform == 'darwin' ? 'lldb' : 'gdb');
|
||||
const debugger_name = modeOverride || (platform === 'darwin' ? 'lldb' : 'gdb');
|
||||
const description = DEBUG_GEN[debugger_name];
|
||||
const gcc_compiler_regex = /([cg]\+\+|g?cc)(?=[^\/\\]*$)/gi;
|
||||
let gdb_debugger_path = debuggerPathOverride || compiler_path.replace(gcc_compiler_regex, description.miMode);
|
||||
|
@ -198,7 +196,7 @@ export async function getDebugConfigurationFromCache(cache: CMakeCache, target:
|
|||
gdb_debugger_path = gdb_debugger_path + '.exe';
|
||||
}
|
||||
}
|
||||
if (gdb_debugger_path.search(new RegExp(description.miMode)) != -1) {
|
||||
if (gdb_debugger_path.search(new RegExp(description.miMode)) !== -1) {
|
||||
return description.createConfig(gdb_debugger_path, target);
|
||||
}
|
||||
|
||||
|
@ -214,5 +212,5 @@ export async function getDebugConfigurationFromCache(cache: CMakeCache, target:
|
|||
|
||||
export async function checkDebugger(debuggerPath: string): Promise<boolean> {
|
||||
const res = await proc.execute(debuggerPath, ['--version'], null, {shell: true}).result;
|
||||
return res.retc == 0;
|
||||
}
|
||||
return res.retc === 0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Module for handling build diagnostics (from the compiler/linker)
|
||||
*/ /** */
|
||||
|
||||
|
||||
import {Logger} from '@cmt/logging';
|
||||
import * as proc from '@cmt/proc';
|
||||
import {OutputConsumer} from '@cmt/proc';
|
||||
|
@ -64,10 +63,9 @@ export class CompileOutputConsumer implements OutputConsumer {
|
|||
MSVC: this.compilers.msvc.diagnostics,
|
||||
GHS: this.compilers.ghs.diagnostics,
|
||||
DIAB: this.compilers.diab.diagnostics,
|
||||
link: this.compilers.gnuLD.diagnostics,
|
||||
link: this.compilers.gnuLD.diagnostics
|
||||
};
|
||||
const arrs = util.objectPairs(by_source).map(([source, diags]) => {
|
||||
return diags.map(raw_diag => {
|
||||
const arrs = util.objectPairs(by_source).map(([source, diags]) => diags.map(raw_diag => {
|
||||
const filepath = util.resolvePath(raw_diag.file, basePath);
|
||||
const diag = new vscode.Diagnostic(raw_diag.location, raw_diag.message, severity_of(raw_diag.severity));
|
||||
diag.source = source;
|
||||
|
@ -86,10 +84,9 @@ export class CompileOutputConsumer implements OutputConsumer {
|
|||
diags_by_file.get(filepath)!.push(diag);
|
||||
return {
|
||||
filepath,
|
||||
diag,
|
||||
diag
|
||||
};
|
||||
});
|
||||
});
|
||||
}));
|
||||
return ([] as FileDiagnostic[]).concat(...arrs);
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +129,7 @@ export class CMakeBuildConsumer implements OutputConsumer, vscode.Disposable {
|
|||
this._onProgressEmitter.fire({
|
||||
minimum: 0,
|
||||
maximum: 100,
|
||||
value: Number.parseInt(percent),
|
||||
value: Number.parseInt(percent)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,23 +45,23 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
* of active parsing. `stack` is parsing the CMake call stack from an error
|
||||
* or warning.
|
||||
*/
|
||||
state: ('init'|'diag'|'stack'),
|
||||
state: ('init'|'diag'|'stack');
|
||||
|
||||
/**
|
||||
* The diagnostic that is currently being accumulated into
|
||||
*/
|
||||
diag: FileDiagnostic|null,
|
||||
diag: FileDiagnostic|null;
|
||||
|
||||
/**
|
||||
* The number of blank lines encountered thus far. CMake signals the end of
|
||||
* a warning or error with blank lines
|
||||
*/
|
||||
blankLines: number,
|
||||
blankLines: number;
|
||||
}
|
||||
= {
|
||||
state: 'init',
|
||||
diag: null,
|
||||
blankLines: 0,
|
||||
blankLines: 0
|
||||
};
|
||||
/**
|
||||
* Consume a line of stderr.
|
||||
|
@ -90,7 +90,7 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
const lineno = oneLess(linestr);
|
||||
const diagmap: {[k: string]: vscode.DiagnosticSeverity} = {
|
||||
Warning: vscode.DiagnosticSeverity.Warning,
|
||||
Error: vscode.DiagnosticSeverity.Error,
|
||||
Error: vscode.DiagnosticSeverity.Error
|
||||
};
|
||||
const vsdiag = new vscode.Diagnostic(new vscode.Range(lineno, 0, lineno, 9999), full, diagmap[level]);
|
||||
vsdiag.source = `CMake (${command})`;
|
||||
|
@ -98,7 +98,7 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
const filepath = util.resolvePath(filename, this.sourceDir);
|
||||
this._errorState.diag = {
|
||||
filepath,
|
||||
diag: vsdiag,
|
||||
diag: vsdiag
|
||||
};
|
||||
this._errorState.state = 'diag';
|
||||
this._errorState.blankLines = 0;
|
||||
|
@ -114,9 +114,9 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
this._errorState.blankLines = 0;
|
||||
break;
|
||||
}
|
||||
if (line == '') {
|
||||
if (line === '') {
|
||||
// A blank line!
|
||||
if (this._errorState.blankLines == 0) {
|
||||
if (this._errorState.blankLines === 0) {
|
||||
// First blank. Okay
|
||||
this._errorState.blankLines++;
|
||||
this._errorState.diag!.diag.message += '\n';
|
||||
|
@ -138,8 +138,8 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
case 'stack': {
|
||||
// Meh... vscode doesn't really let us provide call stacks to diagnostics.
|
||||
// We can't really do anything...
|
||||
if (line.trim() == '') {
|
||||
if (this._errorState.blankLines == 1) {
|
||||
if (line.trim() === '') {
|
||||
if (this._errorState.blankLines === 1) {
|
||||
this._commitDiag();
|
||||
} else {
|
||||
this._errorState.blankLines++;
|
||||
|
@ -155,7 +155,7 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
const lineNo = parseInt(lineNoStr) - 1;
|
||||
const related = new vscode.DiagnosticRelatedInformation(
|
||||
new vscode.Location(fileUri, new vscode.Range(lineNo, 0, lineNo, 999)),
|
||||
`In call to '${command}' here`,
|
||||
`In call to '${command}' here`
|
||||
);
|
||||
console.assert(this._errorState.diag);
|
||||
this._errorState.diag!.diag.relatedInformation!.push(related);
|
||||
|
@ -178,4 +178,4 @@ export class CMakeOutputConsumer implements OutputConsumer {
|
|||
this._errorState.blankLines = 0;
|
||||
this._errorState.state = 'init';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Module for parsing Wind River Diab diagnostics
|
||||
*/ /** */
|
||||
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import {oneLess, RawDiagnosticParser, FeedLineResult} from './util';
|
||||
|
@ -28,7 +27,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
severity,
|
||||
code,
|
||||
message,
|
||||
related: [],
|
||||
related: []
|
||||
};
|
||||
}
|
||||
return FeedLineResult.NotMine;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* Module for handling GCC diagnostics
|
||||
*/ /** */
|
||||
|
@ -7,7 +6,6 @@ import * as vscode from 'vscode';
|
|||
|
||||
import {oneLess, RawDiagnostic, RawDiagnosticParser, RawRelated, FeedLineResult} from './util';
|
||||
|
||||
|
||||
export const REGEX = /^(.*):(\d+):(\d+):\s+(?:fatal )?(\w*)(?:\sfatale)?\s?:\s+(.*)/;
|
||||
|
||||
interface PendingTemplateBacktrace {
|
||||
|
@ -26,7 +24,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
const [, , message] = mat;
|
||||
this._pendingTemplateError = {
|
||||
rootInstantiation: message,
|
||||
requiredFrom: [],
|
||||
requiredFrom: []
|
||||
};
|
||||
return FeedLineResult.Ok;
|
||||
}
|
||||
|
@ -39,7 +37,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
this._pendingTemplateError.requiredFrom.push({
|
||||
file,
|
||||
location: new vscode.Range(lineNo, parseInt(column), lineNo, 999),
|
||||
message,
|
||||
message
|
||||
});
|
||||
return FeedLineResult.Ok;
|
||||
}
|
||||
|
@ -52,7 +50,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
this._prevDiag.related.push({
|
||||
file: prevRelated.file,
|
||||
location: prevRelated.location,
|
||||
message: mat[1],
|
||||
message: mat[1]
|
||||
});
|
||||
return FeedLineResult.Ok;
|
||||
}
|
||||
|
@ -71,7 +69,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
this._prevDiag.related.push({
|
||||
file,
|
||||
location: new vscode.Range(lineno, column, lineno, 999),
|
||||
message,
|
||||
message
|
||||
});
|
||||
return FeedLineResult.Ok;
|
||||
} else {
|
||||
|
@ -81,7 +79,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
related.push({
|
||||
location,
|
||||
file,
|
||||
message: this._pendingTemplateError.rootInstantiation,
|
||||
message: this._pendingTemplateError.rootInstantiation
|
||||
});
|
||||
related.push(...this._pendingTemplateError.requiredFrom);
|
||||
this._pendingTemplateError = undefined;
|
||||
|
@ -93,7 +91,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
location,
|
||||
severity,
|
||||
message,
|
||||
related,
|
||||
related
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Module for parsing GHS diagnostics
|
||||
*/ /** */
|
||||
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import {oneLess, RawDiagnosticParser, FeedLineResult} from './util';
|
||||
|
@ -10,7 +9,6 @@ import {oneLess, RawDiagnosticParser, FeedLineResult} from './util';
|
|||
export const REGEX
|
||||
= /^\"(.*)\",\s+(?:(?:line\s+(\d+)\s+\(col\.\s+(\d+)\))|(?:At end of source)):\s+(?:fatal )?(remark|warning|error)\s+(.*)/;
|
||||
|
||||
|
||||
export class Parser extends RawDiagnosticParser {
|
||||
doHandleLine(line: string) {
|
||||
const mat = REGEX.exec(line);
|
||||
|
@ -27,7 +25,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
location: new vscode.Range(oneLess(lineno), oneLess(column), oneLess(lineno), 999),
|
||||
severity,
|
||||
message,
|
||||
related: [],
|
||||
related: []
|
||||
};
|
||||
}
|
||||
return FeedLineResult.NotMine;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* Module for handling GNU linker diagnostics
|
||||
*/ /** */
|
||||
|
@ -29,7 +28,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
location: new vscode.Range(lineno, 0, lineno, 999),
|
||||
severity: 'error',
|
||||
message,
|
||||
related: [],
|
||||
related: []
|
||||
};
|
||||
}
|
||||
return FeedLineResult.NotMine;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* Module for handling MSVC diagnostics
|
||||
*/ /** */
|
||||
|
@ -16,12 +15,13 @@ export class Parser extends RawDiagnosticParser {
|
|||
if (!res) {
|
||||
return FeedLineResult.NotMine;
|
||||
}
|
||||
const [full, /*proc*/, file, location, severity, code, message] = res;
|
||||
const [full, /* proc*/, file, location, severity, code, message] = res;
|
||||
const range = (() => {
|
||||
const parts = location.split(',');
|
||||
const n0 = oneLess(parts[0]);
|
||||
if (parts.length === 1)
|
||||
if (parts.length === 1) {
|
||||
return new vscode.Range(n0, 0, n0, 999);
|
||||
}
|
||||
if (parts.length === 2) {
|
||||
const n1 = oneLess(parts[1]);
|
||||
return new vscode.Range(n0, n1, n0, n1);
|
||||
|
@ -41,7 +41,7 @@ export class Parser extends RawDiagnosticParser {
|
|||
severity,
|
||||
message,
|
||||
code,
|
||||
related: [],
|
||||
related: []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export abstract class RawDiagnosticParser {
|
|||
/**
|
||||
* Get the diagnostics which have been parsed by this object
|
||||
*/
|
||||
get diagnostics(): ReadonlyArray<RawDiagnostic> { return this._diagnostics; }
|
||||
get diagnostics(): readonly RawDiagnostic[] { return this._diagnostics; }
|
||||
private readonly _diagnostics: RawDiagnostic[] = [];
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,4 +61,4 @@ export class InputFileSet {
|
|||
static createEmpty(): InputFileSet {
|
||||
return new InputFileSet([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ export async function loadIndexFile(reply_path: string): Promise<index_api.Index
|
|||
log.debug(`Found index files: ${JSON.stringify(files)}`);
|
||||
|
||||
const index_files = files.filter(filename => filename.startsWith('index-')).sort();
|
||||
if (index_files.length == 0) {
|
||||
if (index_files.length === 0) {
|
||||
throw Error('No index file found.');
|
||||
}
|
||||
const index_file_path = path.join(reply_path, index_files[index_files.length - 1]);
|
||||
|
@ -59,7 +59,7 @@ export async function loadCacheContent(filename: string): Promise<Map<string, ap
|
|||
|
||||
const expected_version = {major: 2, minor: 0};
|
||||
const detected_version = cache_from_cmake.version;
|
||||
if (detected_version.major != expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
if (detected_version.major !== expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
log.warning(localize(
|
||||
'cache.object.version',
|
||||
'Cache object version ({0}.{1}) of cmake-file-api is unexpected. Expecting ({2}.{3}). IntelliSense configuration may be incorrect.',
|
||||
|
@ -73,21 +73,21 @@ export async function loadCacheContent(filename: string): Promise<Map<string, ap
|
|||
}
|
||||
|
||||
function findPropertyValue(cacheElement: index_api.Cache.CMakeCacheEntry, name: string): string {
|
||||
const property_element = cacheElement.properties.find(prop => prop.name == name);
|
||||
const property_element = cacheElement.properties.find(prop => prop.name === name);
|
||||
return property_element ? property_element.value : '';
|
||||
}
|
||||
|
||||
function convertFileApiCacheToExtensionCache(cache_from_cmake: index_api.Cache.CacheContent):
|
||||
Map<string, api.CacheEntry> {
|
||||
return cache_from_cmake.entries.reduce((acc, el) => {
|
||||
const entry_type_translation_map: {[key: string]: api.CacheEntryType|undefined;} = {
|
||||
const entry_type_translation_map: {[key: string]: api.CacheEntryType|undefined} = {
|
||||
BOOL: api.CacheEntryType.Bool,
|
||||
STRING: api.CacheEntryType.String,
|
||||
PATH: api.CacheEntryType.Path,
|
||||
FILEPATH: api.CacheEntryType.FilePath,
|
||||
INTERNAL: api.CacheEntryType.Internal,
|
||||
UNINITIALIZED: api.CacheEntryType.Uninitialized,
|
||||
STATIC: api.CacheEntryType.Static,
|
||||
STATIC: api.CacheEntryType.Static
|
||||
};
|
||||
const type = entry_type_translation_map[el.type];
|
||||
if (type === undefined) {
|
||||
|
@ -107,7 +107,7 @@ export async function loadCodeModelContent(filename: string): Promise<index_api.
|
|||
const expected_version = {major: 2, minor: 0};
|
||||
const detected_version = codemodel.version;
|
||||
|
||||
if (detected_version.major != expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
if (detected_version.major !== expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
log.warning(localize(
|
||||
'code.model.version',
|
||||
'Code model version ({0}.{1}) of cmake-file-api is unexpected. Expecting ({2}.{3}). IntelliSense configuration may be incorrect.',
|
||||
|
@ -128,7 +128,7 @@ export async function loadTargetObject(filename: string): Promise<index_api.Code
|
|||
async function convertTargetObjectFileToExtensionTarget(build_dir: string, file_path: string): Promise<api.Target> {
|
||||
const targetObject = await loadTargetObject(file_path);
|
||||
|
||||
let executable_path = undefined;
|
||||
let executable_path;
|
||||
if (targetObject.artifacts) {
|
||||
executable_path = targetObject.artifacts.find(artifact => artifact.path.endsWith(targetObject.nameOnDisk));
|
||||
if (executable_path) {
|
||||
|
@ -147,7 +147,7 @@ async function convertTargetObjectFileToExtensionTarget(build_dir: string, file_
|
|||
export async function loadAllTargetsForBuildTypeConfiguration(reply_path: string,
|
||||
builddir: string,
|
||||
configuration: index_api.CodeModelKind.Configuration):
|
||||
Promise<{name: string, targets: api.Target[]}> {
|
||||
Promise<{name: string; targets: api.Target[]}> {
|
||||
const metaTargets = [];
|
||||
if (configuration.directories[0].hasInstallRule) {
|
||||
metaTargets.push({
|
||||
|
@ -226,7 +226,7 @@ async function loadCodeModelTarget(root_paths: index_api.CodeModelKind.PathInfo,
|
|||
if (targetObject.compileGroups) {
|
||||
const all_sysroots
|
||||
= targetObject.compileGroups.map(x => !!x.sysroot ? x.sysroot.path : undefined).filter(x => x !== undefined);
|
||||
sysroot = all_sysroots.length != 0 ? all_sysroots[0] : undefined;
|
||||
sysroot = all_sysroots.length !== 0 ? all_sysroots[0] : undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -253,11 +253,9 @@ export async function loadProject(root_paths: index_api.CodeModelKind.PathInfo,
|
|||
: root_paths.build,
|
||||
source: project.directoryIndexes
|
||||
? path.join(root_paths.source, configuration.directories[project.directoryIndexes[0]].source)
|
||||
: root_paths.source,
|
||||
: root_paths.source
|
||||
};
|
||||
const targets = await Promise.all((project.targetIndexes || []).map(targetIndex => {
|
||||
return loadCodeModelTarget(root_paths, path.join(reply_path, configuration.targets[targetIndex].jsonFile));
|
||||
}));
|
||||
const targets = await Promise.all((project.targetIndexes || []).map(targetIndex => loadCodeModelTarget(root_paths, path.join(reply_path, configuration.targets[targetIndex].jsonFile))));
|
||||
|
||||
return {name: project.name, targets, sourceDirectory: project_paths.source} as CodeModelProject;
|
||||
}
|
||||
|
@ -285,7 +283,7 @@ export async function loadToolchains(filename: string): Promise<Map<string, Code
|
|||
|
||||
const expected_version = {major: 1, minor: 0};
|
||||
const detected_version = toolchains.version;
|
||||
if (detected_version.major != expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
if (detected_version.major !== expected_version.major || detected_version.minor < expected_version.minor) {
|
||||
log.warning(localize(
|
||||
'toolchains.object.version',
|
||||
'Toolchains object version ({0}.{1}) of cmake-file-api is unexpected. Expecting ({2}.{3}). IntelliSense configuration may be incorrect.',
|
||||
|
@ -301,4 +299,4 @@ export async function loadToolchains(filename: string): Promise<Map<string, Code
|
|||
}
|
||||
return acc;
|
||||
}, new Map<string, CodeModelToolchain>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,9 @@ export class CMakeFileApiDriver extends codemodel.CodeModelDriver {
|
|||
this._cacheWatcher.dispose();
|
||||
}
|
||||
|
||||
protected async doPreCleanConfigure(): Promise<void> { await this._cleanPriorConfiguration(); }
|
||||
protected async doPreCleanConfigure(): Promise<void> {
|
||||
await this._cleanPriorConfiguration();
|
||||
}
|
||||
|
||||
async doConfigure(args_: string[], outputConsumer?: proc.OutputConsumer): Promise<number> {
|
||||
const api_path = this.getCMakeFileApiPath();
|
||||
|
@ -225,13 +227,13 @@ export class CMakeFileApiDriver extends codemodel.CodeModelDriver {
|
|||
}
|
||||
}
|
||||
const cmake = this.cmake.path;
|
||||
log.debug(`Configuring using ${this.useCMakePresets ? 'preset': 'kit'}`);
|
||||
log.debug(`Configuring using ${this.useCMakePresets ? 'preset' : 'kit'}`);
|
||||
log.debug('Invoking CMake', cmake, 'with arguments', JSON.stringify(args));
|
||||
const env = await this.getConfigureEnvironment();
|
||||
const res = await this.executeCommand(cmake, args, outputConsumer, {environment: env}).result;
|
||||
log.trace(res.stderr);
|
||||
log.trace(res.stdout);
|
||||
if (res.retc == 0) {
|
||||
if (res.retc === 0) {
|
||||
this._needsReconfigure = false;
|
||||
await this.updateCodeModel();
|
||||
}
|
||||
|
@ -323,7 +325,7 @@ export class CMakeFileApiDriver extends codemodel.CodeModelDriver {
|
|||
return this.uniqueTargets.filter(t => t.type === 'rich' && (t as api.RichTarget).targetType === 'EXECUTABLE')
|
||||
.map(t => ({
|
||||
name: t.name,
|
||||
path: (t as api.RichTarget).filepath,
|
||||
path: (t as api.RichTarget).filepath
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -347,12 +349,12 @@ function targetReducer(set: api.Target[], t: api.Target): api.Target[] {
|
|||
function compareTargets(a: api.Target, b: api.Target): boolean {
|
||||
let same = false;
|
||||
if (a.type === b.type) {
|
||||
same = a.name == b.name;
|
||||
same = a.name === b.name;
|
||||
if (a.type === 'rich' && b.type === 'rich') {
|
||||
same = same && (a.filepath == b.filepath);
|
||||
same = same && (a.targetType == b.targetType);
|
||||
same = same && (a.filepath === b.filepath);
|
||||
same = same && (a.targetType === b.targetType);
|
||||
}
|
||||
}
|
||||
|
||||
return same;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,18 +58,18 @@ export interface ProtocolVersion {
|
|||
/**
|
||||
* The base of all messages. Each message has a `type` property.
|
||||
*/
|
||||
export interface MessageBase { type: string; }
|
||||
export interface MessageBase { type: string }
|
||||
|
||||
/**
|
||||
* Cookied messages represent some on-going conversation.
|
||||
*/
|
||||
export interface CookiedMessage extends MessageBase { cookie: string; }
|
||||
export interface CookiedMessage extends MessageBase { cookie: string }
|
||||
|
||||
/**
|
||||
* Reply messages are solicited by some previous request, which comes with a
|
||||
* cookie to identify the initiating request.
|
||||
*/
|
||||
export interface ReplyMessage extends CookiedMessage { inReplyTo: string; }
|
||||
export interface ReplyMessage extends CookiedMessage { inReplyTo: string }
|
||||
|
||||
/**
|
||||
* Progress messages are sent regarding some long-running request process before
|
||||
|
@ -88,7 +88,7 @@ export interface SignalMessage extends MessageBase {
|
|||
name: string;
|
||||
}
|
||||
|
||||
export interface DirtyMessage extends SignalMessage { name: 'dirty'; }
|
||||
export interface DirtyMessage extends SignalMessage { name: 'dirty' }
|
||||
|
||||
export interface FileChangeMessage {
|
||||
name: 'fileChange';
|
||||
|
@ -129,28 +129,28 @@ export interface HandshakeParams {
|
|||
extraGenerator?: string;
|
||||
platform?: string;
|
||||
toolset?: string;
|
||||
protocolVersion: {major: number; minor: number;};
|
||||
protocolVersion: {major: number; minor: number};
|
||||
}
|
||||
|
||||
export interface HandshakeRequest extends CookiedMessage, HandshakeParams { type: 'handshake'; }
|
||||
export interface HandshakeRequest extends CookiedMessage, HandshakeParams { type: 'handshake' }
|
||||
|
||||
export interface HandshakeContent {}
|
||||
|
||||
export interface HandshakeReply extends ReplyMessage, HandshakeContent { inReplyTo: 'handshake'; }
|
||||
export interface HandshakeReply extends ReplyMessage, HandshakeContent { inReplyTo: 'handshake' }
|
||||
|
||||
/**
|
||||
* GlobalSettings request gets some static information about the project setup.
|
||||
*/
|
||||
export interface GlobalSettingsParams {}
|
||||
|
||||
export interface GlobalSettingsRequest extends CookiedMessage, GlobalSettingsParams { type: 'globalSettings'; }
|
||||
export interface GlobalSettingsRequest extends CookiedMessage, GlobalSettingsParams { type: 'globalSettings' }
|
||||
|
||||
export interface GlobalSettingsContent {
|
||||
buildDirectory: string;
|
||||
capabilities: {
|
||||
generators: {extraGenerators: string[]; name: string; platformSupport: boolean; toolsetSupport: boolean;}[];
|
||||
generators: {extraGenerators: string[]; name: string; platformSupport: boolean; toolsetSupport: boolean}[];
|
||||
serverMode: boolean;
|
||||
version: {isDirty: boolean; major: number; minor: number; patch: number; string: string; suffix: string;};
|
||||
version: {isDirty: boolean; major: number; minor: number; patch: number; string: string; suffix: string};
|
||||
};
|
||||
checkSystemVars: boolean;
|
||||
extraGenerator: string;
|
||||
|
@ -164,7 +164,7 @@ export interface GlobalSettingsContent {
|
|||
warnUnusedCli: boolean;
|
||||
}
|
||||
|
||||
export interface GlobalSettingsReply extends ReplyMessage, GlobalSettingsContent { inReplyTo: 'globalSettings'; }
|
||||
export interface GlobalSettingsReply extends ReplyMessage, GlobalSettingsContent { inReplyTo: 'globalSettings' }
|
||||
|
||||
/**
|
||||
* setGlobalSettings changes information about the project setup.
|
||||
|
@ -179,7 +179,7 @@ export interface SetGlobalSettingsParams {
|
|||
warnUnusedCli?: boolean;
|
||||
}
|
||||
|
||||
export interface SetGlobalSettingsRequest extends CookiedMessage, SetGlobalSettingsParams { type: 'setGlobalSettings'; }
|
||||
export interface SetGlobalSettingsRequest extends CookiedMessage, SetGlobalSettingsParams { type: 'setGlobalSettings' }
|
||||
|
||||
export interface SetGlobalSettingsContent {}
|
||||
|
||||
|
@ -191,23 +191,23 @@ export interface SetGlobalSettingsReply extends ReplyMessage, SetGlobalSettingsC
|
|||
* configure will actually do the configuration for the project. Note that
|
||||
* this should be followed shortly with a 'compute' request.
|
||||
*/
|
||||
export interface ConfigureParams { cacheArguments: string[]; }
|
||||
export interface ConfigureParams { cacheArguments: string[] }
|
||||
|
||||
export interface ConfigureRequest extends CookiedMessage, ConfigureParams { type: 'configure'; }
|
||||
export interface ConfigureRequest extends CookiedMessage, ConfigureParams { type: 'configure' }
|
||||
|
||||
export interface ConfigureContent {}
|
||||
export interface ConfigureReply extends ReplyMessage, ConfigureContent { inReplyTo: 'configure'; }
|
||||
export interface ConfigureReply extends ReplyMessage, ConfigureContent { inReplyTo: 'configure' }
|
||||
|
||||
/**
|
||||
* Compute actually generates the build files from the configure step.
|
||||
*/
|
||||
export interface ComputeParams {}
|
||||
|
||||
export interface ComputeRequest extends CookiedMessage, ComputeParams { type: 'compute'; }
|
||||
export interface ComputeRequest extends CookiedMessage, ComputeParams { type: 'compute' }
|
||||
|
||||
export interface ComputeContent {}
|
||||
|
||||
export interface ComputeReply extends ReplyMessage, ComputeContent { inReplyTo: 'compute'; }
|
||||
export interface ComputeReply extends ReplyMessage, ComputeContent { inReplyTo: 'compute' }
|
||||
|
||||
/**
|
||||
* codemodel gets information about the project, such as targets, files,
|
||||
|
@ -216,12 +216,12 @@ export interface ComputeReply extends ReplyMessage, ComputeContent { inReplyTo:
|
|||
*/
|
||||
export interface CodeModelParams {}
|
||||
|
||||
export interface CodeModelRequest extends CookiedMessage, CodeModelParams { type: 'codemodel'; }
|
||||
export interface CodeModelRequest extends CookiedMessage, CodeModelParams { type: 'codemodel' }
|
||||
|
||||
export interface CodeModelFileGroup {
|
||||
language?: string;
|
||||
compileFlags?: string;
|
||||
includePath?: {path: string; isSystem?: boolean;}[];
|
||||
includePath?: {path: string; isSystem?: boolean}[];
|
||||
defines?: string[];
|
||||
sources: string[];
|
||||
isGenerated: boolean;
|
||||
|
@ -259,9 +259,9 @@ export interface CodeModelConfiguration {
|
|||
projects: CodeModelProject[];
|
||||
}
|
||||
|
||||
export interface CodeModelContent { configurations: CodeModelConfiguration[]; }
|
||||
export interface CodeModelContent { configurations: CodeModelConfiguration[] }
|
||||
|
||||
export interface CodeModelReply extends ReplyMessage, CodeModelContent { inReplyTo: 'codemodel'; }
|
||||
export interface CodeModelReply extends ReplyMessage, CodeModelContent { inReplyTo: 'codemodel' }
|
||||
|
||||
/**
|
||||
* cmakeInputs will respond with a list of file paths that can alter a
|
||||
|
@ -270,24 +270,24 @@ export interface CodeModelReply extends ReplyMessage, CodeModelContent { inReply
|
|||
*/
|
||||
export interface CMakeInputsParams {}
|
||||
|
||||
export interface CMakeInputsRequest extends CookiedMessage, CMakeInputsParams { type: 'cmakeInputs'; }
|
||||
export interface CMakeInputsRequest extends CookiedMessage, CMakeInputsParams { type: 'cmakeInputs' }
|
||||
|
||||
export interface CMakeInputsContent {
|
||||
buildFiles: {isCMake: boolean; isTemporary: boolean; sources: string[];}[];
|
||||
buildFiles: {isCMake: boolean; isTemporary: boolean; sources: string[]}[];
|
||||
cmakeRootDirectory: string;
|
||||
sourceDirectory: string;
|
||||
}
|
||||
|
||||
export interface CMakeInputsReply extends ReplyMessage, CMakeInputsContent { inReplyTo: 'cmakeInputs'; }
|
||||
export interface CMakeInputsReply extends ReplyMessage, CMakeInputsContent { inReplyTo: 'cmakeInputs' }
|
||||
|
||||
/**
|
||||
* The cache request will respond with the contents of the CMake cache.
|
||||
*/
|
||||
export interface CacheParams {}
|
||||
|
||||
export interface CacheRequest extends CookiedMessage, CacheParams { type: 'cache'; }
|
||||
export interface CacheRequest extends CookiedMessage, CacheParams { type: 'cache' }
|
||||
|
||||
export interface CacheContent { cache: CMakeCacheEntry[]; }
|
||||
export interface CacheContent { cache: CMakeCacheEntry[] }
|
||||
|
||||
export interface CMakeCacheEntry {
|
||||
key: string;
|
||||
|
@ -296,7 +296,7 @@ export interface CMakeCacheEntry {
|
|||
value: string;
|
||||
}
|
||||
|
||||
export interface CacheReply extends ReplyMessage, CacheContent { inReplyTo: 'cache'; }
|
||||
export interface CacheReply extends ReplyMessage, CacheContent { inReplyTo: 'cache' }
|
||||
|
||||
// Union type that represents any of the request types.
|
||||
export type SomeRequestMessage
|
||||
|
@ -317,10 +317,10 @@ export type SomeMessage
|
|||
*/
|
||||
export interface ClientInit {
|
||||
cmakePath: string;
|
||||
onMessage: (m: MessageMessage) => Promise<void>;
|
||||
onMessage(m: MessageMessage): Promise<void>;
|
||||
onOtherOutput(m: string): Promise<void>;
|
||||
onProgress: (m: ProgressMessage) => Promise<void>;
|
||||
onDirty: () => Promise<void>;
|
||||
onProgress(m: ProgressMessage): Promise<void>;
|
||||
onDirty(): Promise<void>;
|
||||
environment: NodeJS.ProcessEnv;
|
||||
sourceDir: string;
|
||||
binaryDir: string;
|
||||
|
@ -329,8 +329,8 @@ export interface ClientInit {
|
|||
}
|
||||
|
||||
interface ClientInitPrivate extends ClientInit {
|
||||
onHello: (m: HelloMessage) => Promise<void>;
|
||||
onCrash: (retc: number, signal: string) => Promise<void>;
|
||||
onHello(m: HelloMessage): Promise<void>;
|
||||
onCrash(retc: number, signal: string): Promise<void>;
|
||||
onPipeError(e: Error): Promise<void>;
|
||||
}
|
||||
|
||||
|
@ -359,14 +359,13 @@ export class BadHomeDirectoryError extends Error {
|
|||
}
|
||||
|
||||
interface MessageResolutionCallbacks {
|
||||
resolve: (a: SomeReplyMessage) => void;
|
||||
reject: (b: ServerError) => void;
|
||||
resolve(a: SomeReplyMessage): void;
|
||||
reject(b: ServerError): void;
|
||||
}
|
||||
|
||||
|
||||
export class CMakeServerClient {
|
||||
private _accInput: string = '';
|
||||
private readonly _promisesResolvers: Map<string, MessageResolutionCallbacks> = new Map;
|
||||
private readonly _promisesResolvers: Map<string, MessageResolutionCallbacks> = new Map();
|
||||
private readonly _params: ClientInitPrivate;
|
||||
// TODO: Refactor init so these init-assertions are not necessary
|
||||
private _endPromise!: Promise<void>;
|
||||
|
@ -667,7 +666,7 @@ export class CMakeServerClient {
|
|||
resolved = true;
|
||||
reject(e);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -55,13 +55,17 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
|
||||
// TODO: Refactor to make this assertion unecessary
|
||||
private _codeModel!: null|cms.CodeModelContent;
|
||||
get codeModel(): null|cms.CodeModelContent { return this._codeModel; }
|
||||
get codeModel(): null|cms.CodeModelContent {
|
||||
return this._codeModel;
|
||||
}
|
||||
set codeModel(v: null|cms.CodeModelContent) {
|
||||
this._codeModel = v;
|
||||
}
|
||||
|
||||
private readonly _codeModelChanged = new vscode.EventEmitter<null|codemodel.CodeModelContent>();
|
||||
get onCodeModelChanged() { return this._codeModelChanged.event; }
|
||||
get onCodeModelChanged() {
|
||||
return this._codeModelChanged.event;
|
||||
}
|
||||
|
||||
async asyncDispose() {
|
||||
this._codeModelChanged.dispose();
|
||||
|
@ -124,12 +128,16 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
} else {
|
||||
throw e;
|
||||
}
|
||||
} finally { sub.dispose(); }
|
||||
} finally {
|
||||
sub.dispose();
|
||||
}
|
||||
await this._refreshPostConfigure();
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected async doPreBuild(): Promise<boolean> { return true; }
|
||||
protected async doPreBuild(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async doPostBuild(): Promise<boolean> {
|
||||
await this._refreshPostConfigure();
|
||||
|
@ -151,7 +159,7 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
FILEPATH: api.CacheEntryType.FilePath,
|
||||
INTERNAL: api.CacheEntryType.Internal,
|
||||
UNINITIALIZED: api.CacheEntryType.Uninitialized,
|
||||
STATIC: api.CacheEntryType.Static,
|
||||
STATIC: api.CacheEntryType.Static
|
||||
};
|
||||
const type = entry_map[el.type];
|
||||
if (type === undefined) {
|
||||
|
@ -180,7 +188,7 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
return;
|
||||
}
|
||||
const new_env = JSON.stringify(await this.getConfigureEnvironment());
|
||||
if (bindir_before !== this.binaryDir || srcdir_before != this.sourceDir || new_env != this._prevConfigureEnv) {
|
||||
if (bindir_before !== this.binaryDir || srcdir_before !== this.sourceDir || new_env !== this._prevConfigureEnv) {
|
||||
// Directories changed. We need to restart the driver
|
||||
await this._restartClient();
|
||||
}
|
||||
|
@ -191,7 +199,7 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
if (!this._codeModel) {
|
||||
return [];
|
||||
}
|
||||
const build_config = this._codeModel.configurations.find(conf => conf.name == this.currentBuildType);
|
||||
const build_config = this._codeModel.configurations.find(conf => conf.name === this.currentBuildType);
|
||||
if (!build_config) {
|
||||
log.error(localize('found.no.matching.code.model', 'Found no matching code model for the current build type. This shouldn\'t be possible'));
|
||||
return [];
|
||||
|
@ -200,15 +208,14 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
type: 'rich' as 'rich',
|
||||
name: this.allTargetName,
|
||||
filepath: localize('build.all.target', 'A special target to build all available targets'),
|
||||
targetType: 'META',
|
||||
targetType: 'META'
|
||||
}];
|
||||
if(build_config.projects.some(project => (project.hasInstallRule)? project.hasInstallRule: false))
|
||||
{
|
||||
if (build_config.projects.some(project => (project.hasInstallRule) ? project.hasInstallRule : false)) {
|
||||
metaTargets.push({
|
||||
type: 'rich' as 'rich',
|
||||
name: 'install',
|
||||
filepath: localize('install.all.target', 'A special target to install all available targets'),
|
||||
targetType: 'META',
|
||||
targetType: 'META'
|
||||
});
|
||||
}
|
||||
return build_config.projects.reduce<RichTarget[]>((acc, project) => acc.concat(project.targets.map(
|
||||
|
@ -218,7 +225,7 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
filepath: t.artifacts && t.artifacts.length
|
||||
? path.normalize(t.artifacts[0])
|
||||
: localize('utility.target', 'Utility target'),
|
||||
targetType: t.type,
|
||||
targetType: t.type
|
||||
}))),
|
||||
metaTargets);
|
||||
}
|
||||
|
@ -233,7 +240,9 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
return this.targets.reduce(targetReducer, []);
|
||||
}
|
||||
|
||||
get generatorName(): string|null { return this._globalSettings ? this._globalSettings.generator : null; }
|
||||
get generatorName(): string|null {
|
||||
return this._globalSettings ? this._globalSettings.generator : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Track if the user changes the settings of the configure via settings.json
|
||||
|
@ -254,14 +263,16 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
return this._cmakeInputFileSet.checkOutOfDate();
|
||||
}
|
||||
|
||||
get cmakeCacheEntries(): Map<string, CacheEntryProperties> { return this._cacheEntries; }
|
||||
|
||||
get cmakeCacheEntries(): Map<string, CacheEntryProperties> {
|
||||
return this._cacheEntries;
|
||||
}
|
||||
|
||||
private async _setKitAndRestart(need_clean: boolean, cb: () => Promise<void>) {
|
||||
this._cmakeInputFileSet = InputFileSet.createEmpty();
|
||||
const client = await this._cmsClient;
|
||||
if (client)
|
||||
if (client) {
|
||||
await client.shutdown();
|
||||
}
|
||||
if (need_clean) {
|
||||
await this._cleanPriorConfiguration();
|
||||
}
|
||||
|
@ -322,16 +333,20 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
// on file changes?
|
||||
},
|
||||
onOtherOutput: async msg => this._onMessageEmitter.fire(msg),
|
||||
onMessage: async msg => { this._onMessageEmitter.fire(msg.message); },
|
||||
onMessage: async msg => {
|
||||
this._onMessageEmitter.fire(msg.message);
|
||||
},
|
||||
onProgress: async prog => {
|
||||
this._progressEmitter.fire(prog);
|
||||
},
|
||||
generator: this.generator,
|
||||
generator: this.generator
|
||||
});
|
||||
}
|
||||
|
||||
private readonly _onMessageEmitter = new vscode.EventEmitter<string>();
|
||||
get onMessage() { return this._onMessageEmitter.event; }
|
||||
get onMessage() {
|
||||
return this._onMessageEmitter.event;
|
||||
}
|
||||
|
||||
async onStop(): Promise<void> {
|
||||
const client = await this._cmsClient;
|
||||
|
@ -344,7 +359,6 @@ export class CMakeServerClientDriver extends codemodel.CodeModelDriver {
|
|||
protected async doInit(): Promise<void> {
|
||||
await this._restartClient();
|
||||
|
||||
|
||||
this.config.onChange('sourceDirectory', async () => {
|
||||
// The configure process can determine correctly whether the features set activation
|
||||
// should be full or partial, so there is no need to proactively enable full here,
|
||||
|
|
|
@ -121,4 +121,4 @@ export interface CodeModelContent {
|
|||
configurations: CodeModelConfiguration[];
|
||||
|
||||
toolchains: Map<string, CodeModelToolchain>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,9 @@ interface CompilerInfo {
|
|||
|
||||
export type CMakePreconditionProblemSolver = (e: CMakePreconditionProblems, config?: ConfigurationReader) => Promise<void>;
|
||||
|
||||
function nullableValueToString(arg: any|null|undefined): string { return arg === null ? 'empty' : arg; }
|
||||
function nullableValueToString(arg: any|null|undefined): string {
|
||||
return arg === null ? 'empty' : arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for CMake drivers.
|
||||
|
@ -68,11 +70,17 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
*/
|
||||
protected abstract doConfigure(extra_args: string[], consumer?: proc.OutputConsumer): Promise<number>;
|
||||
|
||||
protected async doPreCleanConfigure(): Promise<void> { return Promise.resolve(); }
|
||||
protected async doPreCleanConfigure(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
protected doPreBuild(): Promise<boolean> { return Promise.resolve(true); }
|
||||
protected doPreBuild(): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
protected doPostBuild(): Promise<boolean> { return Promise.resolve(true); }
|
||||
protected doPostBuild(): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we need to reconfigure, such as if an important file has changed
|
||||
|
@ -147,8 +155,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
/**
|
||||
* Compute the environment variables that apply with substitutions by expansionOptions
|
||||
*/
|
||||
async computeExpandedEnvironment(in_env: proc.EnvironmentVariables, expanded_env:proc.EnvironmentVariables): Promise<proc.EnvironmentVariables>
|
||||
{
|
||||
async computeExpandedEnvironment(in_env: proc.EnvironmentVariables, expanded_env: proc.EnvironmentVariables): Promise<proc.EnvironmentVariables> {
|
||||
const env = {} as {[key: string]: string};
|
||||
const opts = this.expansionOptions;
|
||||
|
||||
|
@ -223,7 +230,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
private _useCMakePresets: boolean = true;
|
||||
|
||||
get useCMakePresets(): boolean { return this._useCMakePresets; }
|
||||
get useCMakePresets(): boolean {
|
||||
return this._useCMakePresets;
|
||||
}
|
||||
|
||||
private _configurePreset: preset.ConfigurePreset | null = null;
|
||||
|
||||
|
@ -231,7 +240,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
private _testPreset: preset.TestPreset | null = null;
|
||||
|
||||
get testPreset(): preset.TestPreset | null { return this._testPreset; }
|
||||
get testPreset(): preset.TestPreset | null {
|
||||
return this._testPreset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vscode root workspace folder.
|
||||
|
@ -239,7 +250,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
* @returns Returns the vscode root workspace folder. Returns `null` if no folder is open or the folder uri is not a
|
||||
* `file://` scheme.
|
||||
*/
|
||||
protected get workspaceFolder() { return this.__workspaceFolder; }
|
||||
protected get workspaceFolder() {
|
||||
return this.__workspaceFolder;
|
||||
}
|
||||
|
||||
protected variantKeywordSettings: Map<string, string>|null = null;
|
||||
|
||||
|
@ -271,7 +284,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
buildKitVersionMajor: majorVersionSemver(version),
|
||||
buildKitVersionMinor: minorVersionSemver(version),
|
||||
// DEPRECATED EXPANSION: Remove this in the future:
|
||||
projectName: 'ProjectName',
|
||||
projectName: 'ProjectName'
|
||||
};
|
||||
|
||||
// Update Variant replacements
|
||||
|
@ -334,7 +347,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
name: localize('file.compilation', 'File Compilation'),
|
||||
cwd: cmd.directory,
|
||||
env,
|
||||
shellPath,
|
||||
shellPath
|
||||
});
|
||||
this._compileTerms.set(key, term);
|
||||
existing = term;
|
||||
|
@ -375,7 +388,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
const newBinaryDir = configurePreset.binaryDir;
|
||||
const needs_clean = this.binaryDir === newBinaryDir && preset.configurePresetChangeNeedsClean(configurePreset, this._configurePreset);
|
||||
await this.doSetConfigurePreset(needs_clean, async () => { await this._setConfigurePreset(configurePreset); });
|
||||
await this.doSetConfigurePreset(needs_clean, async () => {
|
||||
await this._setConfigurePreset(configurePreset);
|
||||
});
|
||||
}
|
||||
|
||||
private async _setConfigurePreset(configurePreset: preset.ConfigurePreset): Promise<void> {
|
||||
|
@ -396,7 +411,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
this._generator = {
|
||||
name: configurePreset.generator,
|
||||
platform: configurePreset.architecture ? getValue(configurePreset.architecture) : undefined,
|
||||
toolset: configurePreset.toolset ? getValue(configurePreset.toolset) : undefined,
|
||||
toolset: configurePreset.toolset ? getValue(configurePreset.toolset) : undefined
|
||||
};
|
||||
} else {
|
||||
log.debug(localize('no.generator', 'No generator specified'));
|
||||
|
@ -414,7 +429,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
|
||||
log.info(localize('switching.to.build.preset', 'Switching to build preset: {0}', buildPreset.name));
|
||||
await this.doSetBuildPreset(async () => { await this._setBuildPreset(buildPreset); });
|
||||
await this.doSetBuildPreset(async () => {
|
||||
await this._setBuildPreset(buildPreset);
|
||||
});
|
||||
}
|
||||
|
||||
private async _setBuildPreset(buildPreset: preset.BuildPreset): Promise<void> {
|
||||
|
@ -433,7 +450,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
|
||||
log.info(localize('switching.to.test.preset', 'Switching to test preset: {0}', testPreset.name));
|
||||
await this.doSetTestPreset(async () => { await this._setTestPreset(testPreset); });
|
||||
await this.doSetTestPreset(async () => {
|
||||
await this._setTestPreset(testPreset);
|
||||
});
|
||||
}
|
||||
|
||||
private async _setTestPreset(testPreset: preset.TestPreset): Promise<void> {
|
||||
|
@ -458,7 +477,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const newBinaryDir = util.lightNormalizePath(await expand.expandString(this.config.buildDirectory, opts));
|
||||
|
||||
const needs_clean = this.binaryDir === newBinaryDir && kitChangeNeedsClean(kit, this._kit);
|
||||
await this.doSetKit(needs_clean, async () => { await this._setKit(kit, preferredGenerators); });
|
||||
await this.doSetKit(needs_clean, async () => {
|
||||
await this._setKit(kit, preferredGenerators);
|
||||
});
|
||||
}
|
||||
|
||||
private async _setKit(kit: Kit, preferredGenerators: CMakeGenerator[]): Promise<void> {
|
||||
|
@ -467,8 +488,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
log.debug(localize('cmakedriver.kit.set.to', 'CMakeDriver Kit set to {0}', kit.name));
|
||||
this._kitEnvironmentVariables = await effectiveKitEnvironment(kit, this.expansionOptions);
|
||||
|
||||
if (kit.preferredGenerator)
|
||||
if (kit.preferredGenerator) {
|
||||
preferredGenerators.push(kit.preferredGenerator);
|
||||
}
|
||||
|
||||
// If no preferred generator is defined by the current kit or the user settings,
|
||||
// it's time to consider the defaults.
|
||||
|
@ -483,7 +505,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
this._generator = {
|
||||
name: this.config.generator,
|
||||
platform: this.config.platform || undefined,
|
||||
toolset: this.config.toolset || undefined,
|
||||
toolset: this.config.toolset || undefined
|
||||
};
|
||||
} else {
|
||||
this._generator = await this.findBestGenerator(preferredGenerators);
|
||||
|
@ -496,7 +518,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
protected abstract doSetKit(needsClean: boolean, cb: () => Promise<void>): Promise<void>;
|
||||
|
||||
protected get generator(): CMakeGenerator|null { return this._generator; }
|
||||
protected get generator(): CMakeGenerator|null {
|
||||
return this._generator;
|
||||
}
|
||||
protected _generator: CMakeGenerator|null = null;
|
||||
/**
|
||||
* The CMAKE_BUILD_TYPE to use
|
||||
|
@ -539,10 +563,14 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
* @note This is distinct from the config values, since we do variable
|
||||
* substitution.
|
||||
*/
|
||||
get sourceDir(): string { return this._sourceDirectory; }
|
||||
get sourceDir(): string {
|
||||
return this._sourceDirectory;
|
||||
}
|
||||
private _sourceDirectory = '';
|
||||
|
||||
protected doRefreshExpansions(cb: () => Promise<void>): Promise<void> { return cb(); }
|
||||
protected doRefreshExpansions(cb: () => Promise<void>): Promise<void> {
|
||||
return cb();
|
||||
}
|
||||
|
||||
private async _refreshExpansions() {
|
||||
log.debug('Run _refreshExpansions');
|
||||
|
@ -579,19 +607,25 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
/**
|
||||
* Directory where build output is stored.
|
||||
*/
|
||||
get binaryDir(): string { return this._binaryDir; }
|
||||
get binaryDir(): string {
|
||||
return this._binaryDir;
|
||||
}
|
||||
private _binaryDir = '';
|
||||
|
||||
/**
|
||||
* Directory where the targets will be installed.
|
||||
*/
|
||||
private get installDir(): string|null { return this._installDir; }
|
||||
private get installDir(): string|null {
|
||||
return this._installDir;
|
||||
}
|
||||
private _installDir: string|null = null;
|
||||
|
||||
/**
|
||||
* Path to copy compile_commands.json to
|
||||
*/
|
||||
get copyCompileCommandsPath(): string|null { return this._copyCompileCommandsPath; }
|
||||
get copyCompileCommandsPath(): string|null {
|
||||
return this._copyCompileCommandsPath;
|
||||
}
|
||||
private _copyCompileCommandsPath: string|null = null;
|
||||
|
||||
/**
|
||||
|
@ -622,7 +656,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
get isMultiConf(): boolean { return this.generatorName ? util.isMultiConfGenerator(this.generatorName) : false; }
|
||||
get isMultiConf(): boolean {
|
||||
return this.generatorName ? util.isMultiConfGenerator(this.generatorName) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the current CMake generator, or `null` if we have not yet
|
||||
|
@ -689,11 +725,11 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
try {
|
||||
const result = await child.result;
|
||||
log.debug(localize('command.version.test.return.code', 'Command version test return code {0}', nullableValueToString(result.retc)));
|
||||
return result.retc == 0;
|
||||
return result.retc === 0;
|
||||
} catch (e) {
|
||||
const e2: NodeJS.ErrnoException = e;
|
||||
log.debug(localize('command.version.test.return.code', 'Command version test return code {0}', nullableValueToString(e2.code)));
|
||||
if (e2.code == 'ENOENT') {
|
||||
if (e2.code === 'ENOENT') {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
|
@ -710,19 +746,19 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
for (const gen of preferredGenerators) {
|
||||
const gen_name = gen.name;
|
||||
const generator_present = await (async(): Promise<boolean> => {
|
||||
if (gen_name == 'Ninja') {
|
||||
if (gen_name === 'Ninja') {
|
||||
return await this.testHaveCommand('ninja') || this.testHaveCommand('ninja-build');
|
||||
}
|
||||
if (gen_name == 'MinGW Makefiles') {
|
||||
if (gen_name === 'MinGW Makefiles') {
|
||||
return platform === 'win32' && this.testHaveCommand('mingw32-make');
|
||||
}
|
||||
if (gen_name == 'NMake Makefiles') {
|
||||
if (gen_name === 'NMake Makefiles') {
|
||||
return platform === 'win32' && this.testHaveCommand('nmake', ['/?']);
|
||||
}
|
||||
if (gen_name == 'Unix Makefiles') {
|
||||
if (gen_name === 'Unix Makefiles') {
|
||||
return this.testHaveCommand('make');
|
||||
}
|
||||
if (gen_name == 'MSYS Makefiles') {
|
||||
if (gen_name === 'MSYS Makefiles') {
|
||||
return platform === 'win32' && this.testHaveCommand('make');
|
||||
}
|
||||
return false;
|
||||
|
@ -733,7 +769,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
return {
|
||||
name: vsMatch[1],
|
||||
platform: gen.platform || vsMatch[2],
|
||||
toolset: gen.toolset,
|
||||
toolset: gen.toolset
|
||||
};
|
||||
}
|
||||
if (gen.name.toLowerCase().startsWith('xcode') && platform === 'darwin') {
|
||||
|
@ -751,7 +787,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
private buildRunning: boolean = false;
|
||||
|
||||
public configOrBuildInProgress() : boolean {
|
||||
public configOrBuildInProgress(): boolean {
|
||||
return this.configRunning || this.buildRunning;
|
||||
}
|
||||
|
||||
|
@ -764,7 +800,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
await this.preconditionHandler(CMakePreconditionProblems.ConfigureIsAlreadyRunning);
|
||||
return -1;
|
||||
}
|
||||
if(this.buildRunning) {
|
||||
if (this.buildRunning) {
|
||||
await this.preconditionHandler(CMakePreconditionProblems.BuildIsAlreadyRunning);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1004,7 +1040,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
];
|
||||
|
||||
async getCompilerVersion(compilerPath: string) : Promise<CompilerInfo> {
|
||||
async getCompilerVersion(compilerPath: string): Promise<CompilerInfo> {
|
||||
// Compiler name and path as coming from the kit.
|
||||
const compilerName = path.parse(compilerPath).name;
|
||||
const compilerDir = path.parse(compilerPath).dir;
|
||||
|
@ -1016,9 +1052,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
// The find condition must be "includes" instead of "equals"
|
||||
// (which wouldn't otherwise need the sort) to avoid implementing separate handling
|
||||
// for compiler file name prefixes and suffixes related to targeted architecture.
|
||||
const sortedCompilerAllowList = this.compilerAllowList.sort((a, b) => {
|
||||
return b.name.length - a.name.length;
|
||||
});
|
||||
const sortedCompilerAllowList = this.compilerAllowList.sort((a, b) => b.name.length - a.name.length);
|
||||
const compiler = sortedCompilerAllowList.find(comp => compilerName.includes(comp.name));
|
||||
|
||||
// Mask any unrecognized compiler as "other" to hide private information
|
||||
|
@ -1060,12 +1094,12 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
return count;
|
||||
}
|
||||
|
||||
async configure(trigger: ConfigureTrigger, extra_args: string[], consumer?: proc.OutputConsumer, withoutCmakeSettings:boolean = false): Promise<number> {
|
||||
async configure(trigger: ConfigureTrigger, extra_args: string[], consumer?: proc.OutputConsumer, withoutCmakeSettings: boolean = false): Promise<number> {
|
||||
if (this.configRunning) {
|
||||
await this.preconditionHandler(CMakePreconditionProblems.ConfigureIsAlreadyRunning);
|
||||
return -1;
|
||||
}
|
||||
if(this.buildRunning) {
|
||||
if (this.buildRunning) {
|
||||
await this.preconditionHandler(CMakePreconditionProblems.BuildIsAlreadyRunning);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1120,7 +1154,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
telemetryProperties = {
|
||||
CMakeExecutableVersion: cmakeVersion ? `${cmakeVersion.major}.${cmakeVersion.minor}.${cmakeVersion.patch}` : '',
|
||||
CMakeGenerator: this.generatorName || '',
|
||||
Preset: this.useCMakePresets? 'true' : 'false',
|
||||
Preset: this.useCMakePresets ? 'true' : 'false',
|
||||
Trigger: trigger
|
||||
};
|
||||
} else {
|
||||
|
@ -1160,7 +1194,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
}
|
||||
|
||||
const telemetryMeasures: telemetry.Measures = {
|
||||
Duration: timeEnd - timeStart,
|
||||
Duration: timeEnd - timeStart
|
||||
};
|
||||
if (this.useCMakePresets && this.workspaceFolder) {
|
||||
const configurePresets = preset.configurePresets(this.workspaceFolder);
|
||||
|
@ -1207,7 +1241,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
} catch {
|
||||
log.info(localize('configure.failed', 'Failed to configure project'));
|
||||
return -1;
|
||||
} finally { this.configRunning = false; }
|
||||
} finally {
|
||||
this.configRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
private generateInitCacheFlags(): string[] {
|
||||
|
@ -1292,7 +1328,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
async build(target?: string, consumer?: proc.OutputConsumer): Promise<number|null> {
|
||||
log.debug(localize('start.build', 'Start build'), target || '');
|
||||
if(this.configRunning) {
|
||||
if (this.configRunning) {
|
||||
await this.preconditionHandler(CMakePreconditionProblems.ConfigureIsAlreadyRunning);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1311,10 +1347,10 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const child = await this._doCMakeBuild(target, consumer);
|
||||
const timeEnd: number = new Date().getTime();
|
||||
const telemetryProperties: telemetry.Properties | undefined = this.useCMakePresets ? undefined : {
|
||||
ConfigType: this.isMultiConf ? 'MultiConf' : this.currentBuildType || '',
|
||||
ConfigType: this.isMultiConf ? 'MultiConf' : this.currentBuildType || ''
|
||||
};
|
||||
const telemetryMeasures: telemetry.Measures = {
|
||||
Duration: timeEnd - timeStart,
|
||||
Duration: timeEnd - timeStart
|
||||
};
|
||||
if (child) {
|
||||
if (consumer) {
|
||||
|
@ -1403,7 +1439,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
private _currentBuildProcess: proc.Subprocess|null = null;
|
||||
|
||||
private correctAllTargetName(targetname: string) {
|
||||
if (targetname === 'all' || targetname == 'ALL_BUILD') {
|
||||
if (targetname === 'all' || targetname === 'ALL_BUILD') {
|
||||
return this.allTargetName;
|
||||
} else {
|
||||
return targetname;
|
||||
|
@ -1477,7 +1513,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
const buildcmd = await this.getCMakeBuildCommand(target);
|
||||
if (buildcmd) {
|
||||
let outputEnc = this.config.outputLogEncoding;
|
||||
if (outputEnc == 'auto') {
|
||||
if (outputEnc === 'auto') {
|
||||
if (process.platform === 'win32') {
|
||||
outputEnc = await codepages.getWindowsCodepage();
|
||||
} else {
|
||||
|
@ -1491,8 +1527,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
await child.result;
|
||||
this._currentBuildProcess = null;
|
||||
return child;
|
||||
} else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1510,8 +1547,9 @@ export abstract class CMakeDriver implements vscode.Disposable {
|
|||
|
||||
const cur = this._currentBuildProcess;
|
||||
if (cur) {
|
||||
if (cur.child)
|
||||
if (cur.child) {
|
||||
await util.termProc(cur.child);
|
||||
}
|
||||
}
|
||||
|
||||
await this.onStop();
|
||||
|
|
|
@ -85,7 +85,7 @@ export class LegacyCMakeDriver extends CMakeDriver {
|
|||
const res = await this.executeCommand(cmake, args, outputConsumer, {environment: env}).result;
|
||||
log.trace(res.stderr);
|
||||
log.trace(res.stdout);
|
||||
if (res.retc == 0) {
|
||||
if (res.retc === 0) {
|
||||
this._needsReconfigure = false;
|
||||
}
|
||||
await this._reloadPostConfigure();
|
||||
|
|
|
@ -109,7 +109,7 @@ export async function expandString(tmpl: string, opts: ExpansionOptions) {
|
|||
i++;
|
||||
} while (i < MAX_RECURSION && opts.recursive && didReplacement);
|
||||
|
||||
if (i == MAX_RECURSION) {
|
||||
if (i === MAX_RECURSION) {
|
||||
log.error(localize('reached.max.recursion', 'Reached max string expansion recursion. Possible circular reference.'));
|
||||
}
|
||||
|
||||
|
@ -187,13 +187,15 @@ export async function expandStringHelper(tmpl: string, opts: ExpansionOptions) {
|
|||
|
||||
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) {
|
||||
const folder_re = RegExp(`\\$\\{workspaceFolder:(${varValueRegexp})\\}`, "g");
|
||||
while (mat = folder_re.exec(tmpl)) {
|
||||
mat = folder_re.exec(tmpl);
|
||||
while (mat) {
|
||||
const full = mat[0];
|
||||
const folderName = mat[1];
|
||||
const f = vscode.workspace.workspaceFolders.find(folder => folder.name.toLocaleLowerCase() === folderName.toLocaleLowerCase());
|
||||
if (f) {
|
||||
subs.set(full, f.uri.fsPath);
|
||||
}
|
||||
mat = folder_re.exec(tmpl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable no-unused-expressions */
|
||||
/**
|
||||
* Extension startup/teardown
|
||||
*/ /** */
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -19,7 +20,7 @@ import {
|
|||
Kit,
|
||||
USER_KITS_FILEPATH,
|
||||
findCLCompilerPath,
|
||||
scanForKitsIfNeeded,
|
||||
scanForKitsIfNeeded
|
||||
} from '@cmt/kit';
|
||||
import {KitsController} from '@cmt/kitsController';
|
||||
import * as logging from '@cmt/logging';
|
||||
|
@ -75,8 +76,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
await this._initActiveFolder();
|
||||
await util.setContextValue(MULTI_ROOT_MODE_KEY, true);
|
||||
// sub go text edit change event in multiroot mode
|
||||
if (this._workspaceConfig.autoSelectActiveFolder)
|
||||
{
|
||||
if (this._workspaceConfig.autoSelectActiveFolder) {
|
||||
this._onDidChangeActiveTextEditorSub.dispose();
|
||||
this._onDidChangeActiveTextEditorSub = vscode.window.onDidChangeActiveTextEditor(e => this._onDidChangeActiveTextEditor(e), this);
|
||||
}
|
||||
|
@ -122,8 +122,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
this._projectOutlineProvider.removeFolder(folder);
|
||||
});
|
||||
this._workspaceConfig.onChange('autoSelectActiveFolder', v => {
|
||||
if (this._folders.isMultiRoot)
|
||||
{
|
||||
if (this._folders.isMultiRoot) {
|
||||
telemetry.logEvent('configChanged.autoSelectActiveFolder', { autoSelectActiveFolder: `${v}` });
|
||||
this._onDidChangeActiveTextEditorSub.dispose();
|
||||
if (v) {
|
||||
|
@ -360,7 +359,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
return !!cmt.buildPreset;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
private readonly _ensureActiveTestPreset = async (cmt?: CMakeTools): Promise<boolean> => {
|
||||
if (!cmt) {
|
||||
|
@ -381,7 +380,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
return !!cmt.testPreset;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of the CMake Tools extension.
|
||||
|
@ -447,7 +446,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
buildKitTargetArch: "",
|
||||
buildKitVersionMajor: "",
|
||||
buildKitVersionMinor: "",
|
||||
workspaceHash: "",
|
||||
workspaceHash: ""
|
||||
};
|
||||
|
||||
const sourceDirectory: string = cmt.workspaceContext.config.sourceDirectory;
|
||||
|
@ -493,7 +492,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
localize('configure.this.project', 'Would you like to configure project \'{0}\'?', ws.name),
|
||||
{},
|
||||
{title: localize('yes.button', 'Yes'), doConfigure: true},
|
||||
{title: localize('not.now.button', 'Not now'), doConfigure: false},
|
||||
{title: localize('not.now.button', 'Not now'), doConfigure: false}
|
||||
);
|
||||
if (!chosen) {
|
||||
// Do nothing. User cancelled
|
||||
|
@ -516,7 +515,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
perist_message,
|
||||
{},
|
||||
{title: button_messages[0], persistMode: 'user'},
|
||||
{title: button_messages[1], persistMode: 'workspace'},
|
||||
{title: button_messages[1], persistMode: 'workspace'}
|
||||
)
|
||||
.then(async choice => {
|
||||
if (!choice) {
|
||||
|
@ -638,7 +637,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
this._isBusySub,
|
||||
this._activeConfigurePresetSub,
|
||||
this._activeBuildPresetSub,
|
||||
this._activeTestPresetSub,
|
||||
this._activeTestPresetSub
|
||||
]) {
|
||||
sub.dispose();
|
||||
}
|
||||
|
@ -652,7 +651,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
cmt.codeModel,
|
||||
{
|
||||
defaultTarget: cmt.defaultBuildTarget || undefined,
|
||||
launchTargetName: cmt.launchTargetName,
|
||||
launchTargetName: cmt.launchTargetName
|
||||
}
|
||||
);
|
||||
rollbar.invokeAsync(localize('update.code.model.for.cpptools', 'Update code model for cpptools'), {}, async () => {
|
||||
|
@ -751,7 +750,6 @@ class ExtensionManager implements vscode.Disposable {
|
|||
{ignoreInitial: true}),
|
||||
_ => rollbar.takePromise(localize('rereading.kits', 'Re-reading kits'), {}, KitsController.readUserKits(this._folders.activeFolder?.cmakeTools)));
|
||||
|
||||
|
||||
/**
|
||||
* Set the current kit for the specified workspace folder
|
||||
* @param k The kit
|
||||
|
@ -778,13 +776,13 @@ class ExtensionManager implements vscode.Disposable {
|
|||
{modal: true},
|
||||
{
|
||||
title: localize('scan.for.kits.button', 'Scan for kits'),
|
||||
action: 'scan',
|
||||
action: 'scan'
|
||||
},
|
||||
{
|
||||
title: localize('cancel.button', 'Cancel'),
|
||||
isCloseAffordance: true,
|
||||
action: 'cancel',
|
||||
},
|
||||
action: 'cancel'
|
||||
}
|
||||
);
|
||||
if (!chosen || chosen.action === 'cancel') {
|
||||
return null;
|
||||
|
@ -850,7 +848,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
buildKitTargetArch: "",
|
||||
buildKitVersionMajor: "",
|
||||
buildKitVersionMinor: "",
|
||||
projectName: "",
|
||||
projectName: ""
|
||||
};
|
||||
const result = new Set<string>();
|
||||
for (const dir of this._workspaceConfig.mingwSearchDirs) {
|
||||
|
@ -984,7 +982,7 @@ class ExtensionManager implements vscode.Disposable {
|
|||
|
||||
// The below functions are all wrappers around the backend.
|
||||
async mapCMakeTools(fn: CMakeToolsMapFn,
|
||||
cmt = this._folders.activeFolder? this._folders.activeFolder.cmakeTools : undefined,
|
||||
cmt = this._folders.activeFolder ? this._folders.activeFolder.cmakeTools : undefined,
|
||||
precheck?: (cmt: CMakeTools) => Promise<boolean>): Promise<any> {
|
||||
if (!cmt) {
|
||||
rollbar.error(localize('no.active.folder', 'No active folder.'));
|
||||
|
@ -1166,7 +1164,9 @@ class ExtensionManager implements vscode.Disposable {
|
|||
}
|
||||
|
||||
async selectWorkspace(folder?: vscode.WorkspaceFolder) {
|
||||
if (!folder) return;
|
||||
if (!folder) {
|
||||
return;
|
||||
}
|
||||
await this._setActiveFolder(folder);
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ async function setup(context: vscode.ExtensionContext, progress?: ProgressHandle
|
|||
vscode.commands.registerCommand('cmake.outline.compileFile',
|
||||
(what: SourceFileNode) => runCommand('compileFile', what.filePath)),
|
||||
vscode.commands.registerCommand('cmake.outline.selectWorkspace',
|
||||
(what: WorkspaceFolderNode) => runCommand('selectWorkspace', what.wsFolder)),
|
||||
(what: WorkspaceFolderNode) => runCommand('selectWorkspace', what.wsFolder))
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ export class CMakeToolsFolder {
|
|||
const kit_name = folder.cmakeTools.workspaceContext.state.activeKitName;
|
||||
if (kit_name) {
|
||||
// It remembers a kit. Find it in the kits avail in this dir:
|
||||
const kit = folder.kitsController.availableKits.find(k => k.name == kit_name) || null;
|
||||
const kit = folder.kitsController.availableKits.find(k => k.name === kit_name) || null;
|
||||
// Set the kit: (May do nothing if no kit was found)
|
||||
await folder.cmakeTools.setKit(kit);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ export class CMakeToolsFolderController implements vscode.Disposable {
|
|||
this._beforeAddFolderEmitter,
|
||||
this._afterAddFolderEmitter,
|
||||
this._beforeRemoveFolderEmitter,
|
||||
this._afterRemoveFolderEmitter,
|
||||
this._afterRemoveFolderEmitter
|
||||
];
|
||||
|
||||
get onBeforeAddFolder() { return this._beforeAddFolderEmitter.event; }
|
||||
|
@ -141,7 +141,7 @@ export class CMakeToolsFolderController implements vscode.Disposable {
|
|||
constructor(readonly extensionContext: vscode.ExtensionContext) {
|
||||
this._subscriptions = [
|
||||
vscode.workspace.onDidChangeWorkspaceFolders(
|
||||
e => rollbar.invokeAsync(localize('update.workspace.folders', 'Update workspace folders'), () => this._onChange(e))),
|
||||
e => rollbar.invokeAsync(localize('update.workspace.folders', 'Update workspace folders'), () => this._onChange(e)))
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ export class CMakeToolsFolderController implements vscode.Disposable {
|
|||
* Get the CMakeTools instance associated with the given workspace folder, or undefined
|
||||
* @param ws The workspace folder to search, or array of command and workspace path
|
||||
*/
|
||||
get(ws: vscode.WorkspaceFolder | Array<string> | undefined): CMakeToolsFolder | undefined {
|
||||
get(ws: vscode.WorkspaceFolder | string[] | undefined): CMakeToolsFolder | undefined {
|
||||
if (ws) {
|
||||
if (util.isArrayOfString(ws)) {
|
||||
return this._instances.get(ws[ws.length - 1]);
|
||||
|
@ -216,7 +216,7 @@ export class CMakeToolsFolderController implements vscode.Disposable {
|
|||
private async _addFolder(folder: vscode.WorkspaceFolder) {
|
||||
const existing = this.get(folder);
|
||||
if (existing) {
|
||||
rollbar.error(localize('same.folder.loaded.twice','The same workspace folder was loaded twice'), { wsUri: folder.uri.toString() });
|
||||
rollbar.error(localize('same.folder.loaded.twice', 'The same workspace folder was loaded twice'), { wsUri: folder.uri.toString() });
|
||||
return existing;
|
||||
}
|
||||
// Load for the workspace.
|
||||
|
@ -251,4 +251,4 @@ export class CMakeToolsFolderController implements vscode.Disposable {
|
|||
}
|
||||
|
||||
[Symbol.iterator]() { return this._instances.values(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,11 @@ import * as proc from '../proc';
|
|||
import {thisExtensionPath} from '../util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
||||
const log = logging.createLogger('visual-studio');
|
||||
|
||||
|
||||
export interface VSCatalog {
|
||||
productDisplayVersion: string;
|
||||
}
|
||||
|
|
61
src/kit.ts
61
src/kit.ts
|
@ -168,7 +168,7 @@ export async function getCompilerVersion(vendor: CompilerVendorEnum, binPath: st
|
|||
version_match_index = 2;
|
||||
}
|
||||
|
||||
let target: TargetTriple | undefined = undefined;
|
||||
let target: TargetTriple | undefined;
|
||||
let version: string = "";
|
||||
let fullVersion: string = "";
|
||||
const lines = exec.stderr.trim().split('\n');
|
||||
|
@ -206,7 +206,7 @@ export async function getCompilerVersion(vendor: CompilerVendorEnum, binPath: st
|
|||
version,
|
||||
target,
|
||||
threadModel,
|
||||
installedDir,
|
||||
installedDir
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ export async function getKitDetect(kit: Kit): Promise<KitDetect> {
|
|||
versionRuntime: vs.installationVersion
|
||||
};
|
||||
} else {
|
||||
let vendor: CompilerVendorEnum | undefined = undefined;
|
||||
let vendor: CompilerVendorEnum | undefined;
|
||||
if (kit.name.startsWith('GCC ')) {
|
||||
vendor = 'GCC';
|
||||
} else if (kit.name.startsWith('Clang ')) {
|
||||
|
@ -263,7 +263,7 @@ export async function getKitDetect(kit: Kit): Promise<KitDetect> {
|
|||
vendor,
|
||||
triple: computeTargetTriple(version.target),
|
||||
version: version.version,
|
||||
versionRuntime: version.version,
|
||||
versionRuntime: version.version
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -284,8 +284,9 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
|
|||
const clang_res = clang_regex.exec(fname);
|
||||
if (gcc_res) {
|
||||
log.debug(localize('testing.gcc.binary', 'Testing GCC binary: {0}', bin));
|
||||
if (pr)
|
||||
if (pr) {
|
||||
pr.report({message: localize('getting.gcc.version', 'Getting GCC version for {0}', bin)});
|
||||
}
|
||||
const version = await getCompilerVersion('GCC', bin);
|
||||
if (version === null) {
|
||||
return null;
|
||||
|
@ -323,8 +324,9 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
|
|||
log.debug(localize('bad.mingw32-make.binary', 'Bad mingw32-make binary ("-v" returns non-zero): {0}', bin));
|
||||
} else {
|
||||
let make_version_output = execMake.stdout;
|
||||
if (make_version_output.length === 0)
|
||||
if (make_version_output.length === 0) {
|
||||
make_version_output = execMake.stderr;
|
||||
}
|
||||
const output_line_sep = make_version_output.trim().split('\n');
|
||||
const isMake = output_line_sep[0].includes('Make');
|
||||
const isMingwTool = output_line_sep[1].includes('mingw32');
|
||||
|
@ -342,8 +344,9 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
|
|||
|
||||
} else if (clang_res) {
|
||||
log.debug(localize('testing.clang.binary', 'Testing Clang binary: {0}', bin));
|
||||
if (pr)
|
||||
if (pr) {
|
||||
pr.report({message: localize('getting.clang.version', 'Getting Clang version for {0}', bin)});
|
||||
}
|
||||
const version = await getCompilerVersion('Clang', bin);
|
||||
if (version === null) {
|
||||
return null;
|
||||
|
@ -366,7 +369,7 @@ export async function kitIfCompiler(bin: string, pr?: ProgressReporter): Promise
|
|||
}
|
||||
return {
|
||||
name: version.detectedName,
|
||||
compilers: clangCompilers,
|
||||
compilers: clangCompilers
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
|
@ -388,7 +391,7 @@ async function scanDirectory<Ret>(dir: string, mapper: (filePath: string) => Pro
|
|||
}
|
||||
} catch (e) {
|
||||
log.warning(localize('failed.to.scan', 'Failed to scan {0} by exception: {1}', dir, util.errorToString(e)));
|
||||
if (e.code == 'ENOENT') {
|
||||
if (e.code === 'ENOENT') {
|
||||
return [];
|
||||
}
|
||||
throw e;
|
||||
|
@ -399,7 +402,7 @@ async function scanDirectory<Ret>(dir: string, mapper: (filePath: string) => Pro
|
|||
try {
|
||||
bins = (await fs.readdir(dir)).map(f => path.join(dir, f));
|
||||
} catch (e) {
|
||||
if (e.code == 'EACCESS' || e.code == 'EPERM') {
|
||||
if (e.code === 'EACCESS' || e.code === 'EPERM') {
|
||||
return [];
|
||||
}
|
||||
throw e;
|
||||
|
@ -421,13 +424,13 @@ export async function scanDirForCompilerKits(dir: string, pr?: ProgressReporter)
|
|||
return await kitIfCompiler(bin, pr);
|
||||
} catch (e) {
|
||||
log.warning(localize('filed.to.check.binary', 'Failed to check binary {0} by exception: {1}', bin, util.errorToString(e)));
|
||||
if (e.code == 'EACCES') {
|
||||
if (e.code === 'EACCES') {
|
||||
// The binary may not be executable by this user...
|
||||
return null;
|
||||
} else if (e.code == 'ENOENT') {
|
||||
} else if (e.code === 'ENOENT') {
|
||||
// This will happen on Windows if we try to "execute" a directory
|
||||
return null;
|
||||
} else if (e.code == 'UNKNOWN' && process.platform == 'win32') {
|
||||
} else if (e.code === 'UNKNOWN' && process.platform === 'win32') {
|
||||
// This is when file is not executable (in windows)
|
||||
return null;
|
||||
}
|
||||
|
@ -599,7 +602,7 @@ async function collectDevBatVars(devbat: string, args: string[], major_version:
|
|||
`set "VS${major_version}0COMNTOOLS=${common_dir}"`,
|
||||
`set "INCLUDE="`,
|
||||
`call "${devbat}" ${args.join(' ')}`,
|
||||
`cd /d "%~dp0"`, /* Switch back to original drive */
|
||||
`cd /d "%~dp0"` /* Switch back to original drive */
|
||||
];
|
||||
for (const envvar of MSVC_ENVIRONMENT_VARIABLES) {
|
||||
bat.push(`echo ${envvar} := %${envvar}% >> ${envfname}`);
|
||||
|
@ -675,7 +678,7 @@ async function collectDevBatVars(devbat: string, args: string[], major_version:
|
|||
*/
|
||||
export async function getShellScriptEnvironment(kit: Kit, opts?: expand.ExpansionOptions): Promise<Map<string, string>|undefined> {
|
||||
console.assert(kit.environmentSetupScript);
|
||||
const filename = Math.random().toString() + (process.platform == 'win32' ? '.bat' : '.sh');
|
||||
const filename = Math.random().toString() + (process.platform === 'win32' ? '.bat' : '.sh');
|
||||
const script_filename = `vs-cmt-${filename}`;
|
||||
const environment_filename = script_filename + '.env';
|
||||
|
||||
|
@ -705,14 +708,14 @@ export async function getShellScriptEnvironment(kit: Kit, opts?: expand.Expansio
|
|||
environmentSetupScript = await expand.expandString(environmentSetupScript!, opts);
|
||||
}
|
||||
|
||||
if (process.platform == 'win32') { // windows
|
||||
if (process.platform === 'win32') { // windows
|
||||
script += `call "${environmentSetupScript}"\r\n`; // call the user batch script
|
||||
script += `set >> "${environment_path}"`; // write env vars to temp file
|
||||
// Quote the script file path before running it, in case there are spaces.
|
||||
run_command = `call "${script_path}"`;
|
||||
} else { // non-windows
|
||||
script += `source "${environmentSetupScript}"\n`; // run the user shell script
|
||||
script +=`printenv >> ${environment_path}`; // write env vars to temp file
|
||||
script += `printenv >> ${environment_path}`; // write env vars to temp file
|
||||
run_command = `/bin/bash -c "source ${script_path}"`; // run script in bash to enable bash-builtin commands like 'source'
|
||||
}
|
||||
try {
|
||||
|
@ -782,7 +785,7 @@ async function varsForVSInstallation(inst: VSInstallation, hostArch: string, tar
|
|||
console.log(`varsForVSInstallation path:'${inst.installationPath}' version:${inst.installationVersion} host arch:${hostArch} - target arch:${targetArch}`);
|
||||
const common_dir = path.join(inst.installationPath, 'Common7', 'Tools');
|
||||
let vcvarsScript: string = 'vcvarsall.bat';
|
||||
if (targetArch == "arm" || targetArch == "arm64") {
|
||||
if (targetArch === "arm" || targetArch === "arm64") {
|
||||
// The arm(64) vcvars filename for x64 hosted toolset is using the 'amd64' alias.
|
||||
vcvarsScript = `vcvars${kitHostTargetArch(hostArch, targetArch, true)}.bat`;
|
||||
}
|
||||
|
@ -811,8 +814,7 @@ async function varsForVSInstallation(inst: VSInstallation, hostArch: string, tar
|
|||
// the VS{vs_version_number}COMNTOOLS environment variable to contain
|
||||
// the path to the Common7 directory.
|
||||
const vs_version = variables.get('VISUALSTUDIOVERSION');
|
||||
if (vs_version)
|
||||
variables.set(`VS${vs_version.replace('.', '')}COMNTOOLS`, common_dir);
|
||||
if (vs_version) {variables.set(`VS${vs_version.replace('.', '')}COMNTOOLS`, common_dir); }
|
||||
|
||||
// For Ninja and Makefile generators, CMake searches for some compilers
|
||||
// before it checks for cl.exe. We can force CMake to check cl.exe first by
|
||||
|
@ -964,7 +966,7 @@ async function scanDirForClangForMSVCKits(dir: string, vsInstalls: VSInstallatio
|
|||
visualStudioArchitecture: vs_arch,
|
||||
compilers: {
|
||||
C: binPath,
|
||||
CXX: binPath,
|
||||
CXX: binPath
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -991,13 +993,13 @@ async function getVSInstallForKit(kit: Kit): Promise<VSInstallation|undefined> {
|
|||
const installs = await vsInstallations();
|
||||
const match = (inst: VSInstallation) =>
|
||||
// old Kit format
|
||||
(legacyKitVSName(inst) == kit.visualStudio) ||
|
||||
(legacyKitVSName(inst) === kit.visualStudio) ||
|
||||
// new Kit format
|
||||
(kitVSName(inst) === kit.visualStudio) ||
|
||||
// Clang for VS kit format
|
||||
(!!kit.compilers && kit.name.indexOf("Clang") >= 0 && kit.name.indexOf(vsDisplayName(inst)) >= 0);
|
||||
|
||||
return installs.find(inst => match(inst));
|
||||
return installs.find(match);
|
||||
}
|
||||
|
||||
export async function getVSKitEnvironment(kit: Kit): Promise<Map<string, string>|null> {
|
||||
|
@ -1036,8 +1038,7 @@ export async function effectiveKitEnvironment(kit: Kit, opts?: expand.ExpansionO
|
|||
}
|
||||
const env = new Map(util.chain(host_env, kit_env));
|
||||
const isWin32 = process.platform === 'win32';
|
||||
if (isWin32)
|
||||
{
|
||||
if (isWin32) {
|
||||
const path_list: string[] = [];
|
||||
const cCompiler = kit.compilers?.C;
|
||||
/* Force add the compiler executable dir to the PATH env */
|
||||
|
@ -1048,7 +1049,7 @@ export async function effectiveKitEnvironment(kit: Kit, opts?: expand.ExpansionO
|
|||
if (cmt_mingw_path) {
|
||||
path_list.push(cmt_mingw_path);
|
||||
}
|
||||
let path_key : string | undefined = undefined;
|
||||
let path_key: string | undefined;
|
||||
if (env.has("PATH")) {
|
||||
path_key = "PATH";
|
||||
} else if (env.has("Path")) {
|
||||
|
@ -1101,7 +1102,7 @@ export async function scanForKits(cmakeTools: CMakeTools | undefined, opt?: KitS
|
|||
log.debug(localize('scanning.for.kits.on.system', 'Scanning for Kits on system'));
|
||||
const prog = {
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('scanning.for.kits', 'Scanning for kits'),
|
||||
title: localize('scanning.for.kits', 'Scanning for kits')
|
||||
};
|
||||
|
||||
return vscode.window.withProgress(prog, async pr => {
|
||||
|
@ -1156,7 +1157,7 @@ export async function scanForKits(cmakeTools: CMakeTools | undefined, opt?: KitS
|
|||
bundled_clang_paths.push(vs_install.installationPath + "\\VC\\Tools\\Llvm\\bin");
|
||||
bundled_clang_paths.push(vs_install.installationPath + "\\VC\\Tools\\Llvm\\x64\\bin");
|
||||
});
|
||||
bundled_clang_paths.forEach(path_el => {clang_paths.add(path_el);});
|
||||
bundled_clang_paths.forEach(path_el => {clang_paths.add(path_el); });
|
||||
|
||||
// Scan for kits
|
||||
const vs_kits = scanForVSKits(pr);
|
||||
|
@ -1174,7 +1175,7 @@ export async function scanForKits(cmakeTools: CMakeTools | undefined, opt?: KitS
|
|||
}
|
||||
|
||||
// Rescan if the kits versions (extension context state var versus value defined for this release) don't match.
|
||||
export async function scanForKitsIfNeeded(cmt: CMakeTools) : Promise<boolean> {
|
||||
export async function scanForKitsIfNeeded(cmt: CMakeTools): Promise<boolean> {
|
||||
const kitsVersionSaved = cmt.extensionContext.globalState.get<number>('kitsVersionSaved');
|
||||
const kitsVersionCurrent = 2;
|
||||
|
||||
|
@ -1343,7 +1344,7 @@ export function kitChangeNeedsClean(newKit: Kit, oldKit: Kit|null): boolean {
|
|||
});
|
||||
const new_imp = important_params(newKit);
|
||||
const old_imp = important_params(oldKit);
|
||||
if (compare(new_imp, old_imp) != Ordering.Equivalent) {
|
||||
if (compare(new_imp, old_imp) !== Ordering.Equivalent) {
|
||||
log.debug(localize('clean.needed', 'Need clean: Kit changed'));
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,7 @@ export class KitsController {
|
|||
workspaceFolderBasename: path.basename(cmakeTools.workspaceContext.folder.uri.fsPath),
|
||||
workspaceHash: "",
|
||||
workspaceRoot: cmakeTools.workspaceContext.folder.uri.fsPath,
|
||||
workspaceRootFolderName: path.basename(cmakeTools.workspaceContext.folder.uri.fsPath),
|
||||
workspaceRootFolderName: path.basename(cmakeTools.workspaceContext.folder.uri.fsPath)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -217,9 +217,9 @@ export class KitsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: message,
|
||||
title: message
|
||||
},
|
||||
() => inst.setKit(k),
|
||||
() => inst.setKit(k)
|
||||
);
|
||||
}
|
||||
return raw_name;
|
||||
|
@ -231,7 +231,7 @@ export class KitsController {
|
|||
// We have kits. Okay.
|
||||
return true;
|
||||
}
|
||||
if (!avail.find(kit => kit.name == SpecialKits.Unspecified)) {
|
||||
if (!avail.find(kit => kit.name === SpecialKits.Unspecified)) {
|
||||
// We should _always_ have the 'UnspecifiedKit'.
|
||||
rollbar.error(localize('invalid.only.kit', 'Invalid only kit. Expected to find `{0}`', SpecialKits.Unspecified));
|
||||
return false;
|
||||
|
@ -287,8 +287,8 @@ export class KitsController {
|
|||
async (kit): Promise<KitItem> => ({
|
||||
label: getKitName(kit),
|
||||
description: await descriptionForKit(kit),
|
||||
kit,
|
||||
}),
|
||||
kit
|
||||
})
|
||||
);
|
||||
const items = await Promise.all(item_promises);
|
||||
const chosen_kit = await vscode.window.showQuickPick(items,
|
||||
|
@ -301,7 +301,7 @@ export class KitsController {
|
|||
// No selection was made
|
||||
return false;
|
||||
} else {
|
||||
if (chosen_kit.kit.name == SpecialKits.ScanForKits) {
|
||||
if (chosen_kit.kit.name === SpecialKits.ScanForKits) {
|
||||
await KitsController.scanForKits(this.cmakeTools);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -316,11 +316,10 @@ export class KitsController {
|
|||
* Set the current kit by name of the kit
|
||||
*/
|
||||
async setKitByName(kitName: string) {
|
||||
let newKit: Kit | undefined;
|
||||
if (!kitName) {
|
||||
kitName = SpecialKits.Unspecified;
|
||||
}
|
||||
newKit = this.availableKits.find(kit => kit.name === kitName);
|
||||
const newKit: Kit | undefined = this.availableKits.find(kit => kit.name === kitName);
|
||||
await this.setFolderActiveKit(newKit || null);
|
||||
// if we are showing a quickpick menu...
|
||||
this._pickKitCancellationTokenSource.cancel();
|
||||
|
@ -387,12 +386,12 @@ export class KitsController {
|
|||
{},
|
||||
{
|
||||
action: 'remove',
|
||||
title: localize('remove.it.button', 'Remove it'),
|
||||
title: localize('remove.it.button', 'Remove it')
|
||||
},
|
||||
{
|
||||
action: 'keep',
|
||||
title: localize('keep.it.button', 'Keep it'),
|
||||
},
|
||||
title: localize('keep.it.button', 'Keep it')
|
||||
}
|
||||
);
|
||||
if (chosen === undefined) {
|
||||
return;
|
||||
|
@ -443,14 +442,12 @@ export class KitsController {
|
|||
log.debug(localize('saving.kits.to', 'Saving kits to {0}', USER_KITS_FILEPATH));
|
||||
|
||||
// Remove the special kits
|
||||
const stripped_kits = kits.filter(kit => {
|
||||
return ((kit.name !== SpecialKits.ScanForKits) &&
|
||||
(kit.name !== SpecialKits.Unspecified));
|
||||
});
|
||||
const stripped_kits = kits.filter(kit => ((kit.name !== SpecialKits.ScanForKits) &&
|
||||
(kit.name !== SpecialKits.Unspecified)));
|
||||
|
||||
// Sort the kits by name so they always appear in order in the file.
|
||||
const sorted_kits = stripped_kits.sort((a, b) => {
|
||||
if (a.name == b.name) {
|
||||
if (a.name === b.name) {
|
||||
return 0;
|
||||
} else if (a.name < b.name) {
|
||||
return -1;
|
||||
|
@ -475,12 +472,12 @@ export class KitsController {
|
|||
`Failed to write kits file to disk: ${USER_KITS_FILEPATH}: ${e.toString()}`,
|
||||
{
|
||||
title: localize('retry.button', 'Retry'),
|
||||
do: 'retry',
|
||||
do: 'retry'
|
||||
},
|
||||
{
|
||||
title: localize('cancel.button', 'Cancel'),
|
||||
do: 'cancel',
|
||||
},
|
||||
do: 'cancel'
|
||||
}
|
||||
)
|
||||
.then(choice => {
|
||||
if (!choice) {
|
||||
|
@ -546,11 +543,11 @@ export class KitsController {
|
|||
localize('delete.duplicate.kits', 'Would you like to delete the duplicate Visual Studio kits from cmake-tools-kits.json?'),
|
||||
{
|
||||
title: yesButtonTitle,
|
||||
isCloseAffordance: true,
|
||||
isCloseAffordance: true
|
||||
},
|
||||
{
|
||||
title: localize('no.button', 'No'),
|
||||
isCloseAffordance: true,
|
||||
isCloseAffordance: true
|
||||
});
|
||||
|
||||
if (chosen !== undefined && (chosen.title === yesButtonTitle)) {
|
||||
|
@ -565,13 +562,13 @@ export class KitsController {
|
|||
// in the user kits file.
|
||||
const old_kits_by_name = KitsController.userKits.reduce(
|
||||
(acc, kit) => ({...acc, [kit.name]: kit}),
|
||||
{} as {[kit: string]: Kit},
|
||||
{} as {[kit: string]: Kit}
|
||||
);
|
||||
|
||||
// Update the new kits we know about.
|
||||
const new_kits_by_name = discovered_kits.reduce(
|
||||
(acc, kit) => ({...acc, [kit.name]: kit}),
|
||||
old_kits_by_name,
|
||||
old_kits_by_name
|
||||
);
|
||||
|
||||
const new_kits = Object.keys(new_kits_by_name).map(k => new_kits_by_name[k]);
|
||||
|
@ -582,4 +579,4 @@ export class KitsController {
|
|||
|
||||
return duplicateRemoved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class OutputChannelManager implements vscode.Disposable {
|
|||
dispose() { util.map(this._channels.values(), c => c.dispose()); }
|
||||
}
|
||||
|
||||
export const channelManager = new OutputChannelManager;
|
||||
export const channelManager = new OutputChannelManager();
|
||||
|
||||
export interface Stringable {
|
||||
toString(): string;
|
||||
|
@ -140,7 +140,7 @@ class SingletonLogger {
|
|||
|
||||
private _log(level: LogLevel, ...args: Stringable[]) {
|
||||
const trace = vscode.workspace.getConfiguration('cmake').get('enableTraceLogging', false);
|
||||
if (level == LogLevel.Trace && !trace) {
|
||||
if (level === LogLevel.Trace && !trace) {
|
||||
return;
|
||||
}
|
||||
const user_message = args.map(a => a.toString()).join(' ');
|
||||
|
|
17
src/paths.ts
17
src/paths.ts
|
@ -74,7 +74,7 @@ class WindowsEnvironment {
|
|||
class Paths {
|
||||
private _ninjaPath?: string;
|
||||
|
||||
readonly windows: WindowsEnvironment = new WindowsEnvironment;
|
||||
readonly windows: WindowsEnvironment = new WindowsEnvironment();
|
||||
|
||||
/**
|
||||
* The current user's home directory
|
||||
|
@ -92,7 +92,7 @@ class Paths {
|
|||
* application data should be stored.
|
||||
*/
|
||||
get userLocalDir(): string {
|
||||
if (process.platform == 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
return this.windows.LocalAppData!;
|
||||
} else {
|
||||
const xdg_dir = process.env['XDG_DATA_HOME'];
|
||||
|
@ -105,7 +105,7 @@ class Paths {
|
|||
}
|
||||
|
||||
get userRoamingDir(): string {
|
||||
if (process.platform == 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
return this.windows.AppData!;
|
||||
} else {
|
||||
const xdg_dir = process.env['XDG_CONFIG_HOME'];
|
||||
|
@ -133,7 +133,7 @@ class Paths {
|
|||
* Get the platform-specific temporary directory
|
||||
*/
|
||||
get tmpDir(): string {
|
||||
if (process.platform == 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
return this.windows.Temp!;
|
||||
} else {
|
||||
return '/tmp';
|
||||
|
@ -159,7 +159,7 @@ class Paths {
|
|||
|
||||
async getCTestPath(wsc: DirectoryContext, overWriteCMakePathSetting?: string): Promise<string|null> {
|
||||
const ctest_path = await this.expandStringPath(wsc.config.raw_ctestPath, wsc);
|
||||
if (!ctest_path || ctest_path == 'auto') {
|
||||
if (!ctest_path || ctest_path === 'auto') {
|
||||
const cmake = await this.getCMakePath(wsc, overWriteCMakePathSetting);
|
||||
if (cmake === null) {
|
||||
return null;
|
||||
|
@ -168,6 +168,7 @@ class Paths {
|
|||
// Check if CTest is a sibling executable in the same directory
|
||||
if (await fs.exists(ctest_sibling)) {
|
||||
const stat = await fs.stat(ctest_sibling);
|
||||
// eslint-disable-next-line no-bitwise
|
||||
if (stat.isFile() && stat.mode & 0b001001001) {
|
||||
return ctest_sibling;
|
||||
} else {
|
||||
|
@ -243,8 +244,8 @@ class Paths {
|
|||
workspaceRoot: wsc.folder.uri.fsPath,
|
||||
workspaceRootFolderName: path.basename(wsc.folder.uri.fsPath),
|
||||
workspaceHash: util.makeHashString(wsc.folder.uri.fsPath),
|
||||
userHome: this.userHome,
|
||||
},
|
||||
userHome: this.userHome
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,7 @@ class Paths {
|
|||
|
||||
const vs_installations = await vsInstallations();
|
||||
if (vs_installations.length > 0) {
|
||||
const bundled_tool_paths = [] as {cmake: string, ninja: string}[];
|
||||
const bundled_tool_paths = [] as {cmake: string; ninja: string}[];
|
||||
|
||||
for (const install of vs_installations) {
|
||||
const bundled_tool_path = {
|
||||
|
|
|
@ -133,4 +133,4 @@ export function rmdir(dirpath: string): Promise<void> {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-unused-expressions */
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as path from 'path';
|
||||
|
||||
|
@ -60,15 +61,15 @@ export interface DebugOptions {
|
|||
find?: boolean;
|
||||
}
|
||||
|
||||
type CacheVarType = null | boolean | string | { type: string, value: boolean | string };
|
||||
type CacheVarType = null | boolean | string | { type: string; value: boolean | string };
|
||||
|
||||
export type OsName = "Windows" | "Linux" | "macOS";
|
||||
|
||||
export type Vendor_VsSettings = {
|
||||
export type VendorVsSettings = {
|
||||
'microsoft.com/VisualStudioSettings/CMake/1.0': {
|
||||
hostOS: OsName | OsName[];
|
||||
[key: string]: any;
|
||||
}
|
||||
};
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
|
@ -83,7 +84,7 @@ export interface ConfigurePreset extends Preset {
|
|||
warnings?: WarningOptions;
|
||||
errors?: ErrorOptions;
|
||||
debug?: DebugOptions;
|
||||
vendor?: Vendor_VsSettings | VendorType;
|
||||
vendor?: VendorVsSettings | VendorType;
|
||||
}
|
||||
|
||||
export interface BuildPreset extends Preset {
|
||||
|
@ -129,13 +130,13 @@ export interface IncludeFilter {
|
|||
name?: string;
|
||||
label?: string;
|
||||
useUnion?: boolean;
|
||||
index?: string | { start?: number, end?: number, stride?: number, specificTests?: number[] };
|
||||
index?: string | { start?: number; end?: number; stride?: number; specificTests?: number[] };
|
||||
}
|
||||
|
||||
export interface ExcludeFilter {
|
||||
name?: string;
|
||||
label?: string;
|
||||
fixtures?: { any?: string, setup?: string, cleanup?: string };
|
||||
fixtures?: { any?: string; setup?: string; cleanup?: string };
|
||||
}
|
||||
|
||||
export interface TestFilter {
|
||||
|
@ -150,7 +151,7 @@ export interface ExecutionOptions {
|
|||
resourceSpecFile?: string;
|
||||
testLoad?: number;
|
||||
showOnly?: 'human' | 'json-v1';
|
||||
repeat?: { mode: 'until-fail' | 'until-pass' | 'after-timeout', count: number};
|
||||
repeat?: { mode: 'until-fail' | 'until-pass' | 'after-timeout'; count: number};
|
||||
interactiveDebugging?: boolean;
|
||||
scheduleRandom?: boolean;
|
||||
timeout?: number;
|
||||
|
@ -319,7 +320,7 @@ export function expandVendorForConfigurePresets(folder: string): void {
|
|||
}
|
||||
}
|
||||
|
||||
function getVendorForConfigurePreset(folder: string, name: string): VendorType | Vendor_VsSettings | null {
|
||||
function getVendorForConfigurePreset(folder: string, name: string): VendorType | VendorVsSettings | null {
|
||||
const refs = referencedConfigurePresets.get(folder);
|
||||
if (!refs) {
|
||||
referencedConfigurePresets.set(folder, new Set());
|
||||
|
@ -329,7 +330,7 @@ function getVendorForConfigurePreset(folder: string, name: string): VendorType |
|
|||
return getVendorForConfigurePresetImpl(folder, name);
|
||||
}
|
||||
|
||||
function getVendorForConfigurePresetImpl(folder: string, name: string, allowUserPreset: boolean = false): VendorType | Vendor_VsSettings | null {
|
||||
function getVendorForConfigurePresetImpl(folder: string, name: string, allowUserPreset: boolean = false): VendorType | VendorVsSettings | null {
|
||||
let preset = getPresetByName(configurePresets(folder), name);
|
||||
if (preset) {
|
||||
return getVendorForConfigurePresetHelper(folder, preset);
|
||||
|
@ -345,7 +346,7 @@ function getVendorForConfigurePresetImpl(folder: string, name: string, allowUser
|
|||
return null;
|
||||
}
|
||||
|
||||
function getVendorForConfigurePresetHelper(folder: string, preset: ConfigurePreset, allowUserPreset: boolean = false): VendorType | Vendor_VsSettings | null {
|
||||
function getVendorForConfigurePresetHelper(folder: string, preset: ConfigurePreset, allowUserPreset: boolean = false): VendorType | VendorVsSettings | null {
|
||||
if (preset.__expanded) {
|
||||
return preset.vendor || null;
|
||||
}
|
||||
|
@ -1196,11 +1197,10 @@ export function configureArgs(preset: ConfigurePreset): string[] {
|
|||
if (preset.warnings.deprecated !== undefined) {
|
||||
result.push(preset.warnings.deprecated ? '-Wdeprecated' : '-Wno-deprecated');
|
||||
}
|
||||
/* tslint:disable:no-unused-expression */
|
||||
|
||||
preset.warnings.uninitialized && result.push('--warn-uninitialized');
|
||||
preset.warnings.unusedCli && result.push('--no-warn-unused-cli');
|
||||
preset.warnings.systemVars && result.push('--check-system-vars');
|
||||
/* tslint:enable:no-unused-expression */
|
||||
}
|
||||
|
||||
// Errors
|
||||
|
@ -1215,11 +1215,9 @@ export function configureArgs(preset: ConfigurePreset): string[] {
|
|||
|
||||
// Debug
|
||||
if (preset.debug) {
|
||||
/* tslint:disable:no-unused-expression */
|
||||
preset.debug.output && result.push('--debug-output');
|
||||
preset.debug.tryCompile && result.push('--debug-trycompile');
|
||||
preset.debug.find && result.push('--debug-find');
|
||||
/* tslint:enable:no-unused-expression */
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1228,8 +1226,6 @@ export function configureArgs(preset: ConfigurePreset): string[] {
|
|||
export function buildArgs(preset: BuildPreset): string[] {
|
||||
const result: string[] = [];
|
||||
|
||||
/* tslint:disable:no-unused-expression */
|
||||
|
||||
preset.__binaryDir && result.push('--build', preset.__binaryDir);
|
||||
preset.jobs && result.push('--parallel', preset.jobs.toString());
|
||||
preset.configuration && result.push('--config', preset.configuration);
|
||||
|
@ -1244,16 +1240,12 @@ export function buildArgs(preset: BuildPreset): string[] {
|
|||
|
||||
preset.nativeToolOptions && result.push('--', ...preset.nativeToolOptions);
|
||||
|
||||
/* tslint:enable:no-unused-expression */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function testArgs(preset: TestPreset): string[] {
|
||||
const result: string[] = [];
|
||||
|
||||
/* tslint:disable:no-unused-expression */
|
||||
|
||||
preset.configuration && result.push('--build-config', preset.configuration);
|
||||
if (preset.overwriteConfigurationFile) {
|
||||
for (const config of preset.overwriteConfigurationFile) {
|
||||
|
@ -1309,14 +1301,12 @@ export function testArgs(preset: TestPreset): string[] {
|
|||
preset.execution.testLoad && result.push('--test-load', preset.execution.testLoad.toString());
|
||||
preset.execution.showOnly && result.push('--show-only', preset.execution.showOnly);
|
||||
preset.execution.repeat && result.push(`--repeat ${preset.execution.repeat.mode}:${preset.execution.repeat.count}`);
|
||||
result.push(`--interactive-debug-mode ${preset.execution.interactiveDebugging ? 1 : 0}` );
|
||||
result.push(`--interactive-debug-mode ${preset.execution.interactiveDebugging ? 1 : 0}`);
|
||||
preset.execution.scheduleRandom && result.push('--schedule-random');
|
||||
preset.execution.timeout && result.push('--timeout', preset.execution.timeout.toString());
|
||||
preset.execution.noTestsAction && preset.execution.noTestsAction !== 'default' && result.push('--no-tests=' + preset.execution.noTestsAction);
|
||||
}
|
||||
|
||||
/* tslint:enable:no-unused-expression */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1321,7 @@ export function configurePresetChangeNeedsClean(newPreset: ConfigurePreset, oldP
|
|||
});
|
||||
const new_imp = important_params(newPreset);
|
||||
const old_imp = important_params(oldPreset);
|
||||
if (util.compare(new_imp, old_imp) != util.Ordering.Equivalent) {
|
||||
if (util.compare(new_imp, old_imp) !== util.Ordering.Equivalent) {
|
||||
log.debug(localize('clean.needed.config.preset.changed', 'Need clean: configure preset changed'));
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -137,20 +137,20 @@ export class PresetsController {
|
|||
private readonly _setPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
preset.setPresetsFile(folder, presetsFile);
|
||||
this._presetsChangedEmitter.fire();
|
||||
}
|
||||
};
|
||||
|
||||
private readonly _setUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
preset.setUserPresetsFile(folder, presetsFile);
|
||||
this._presetsChangedEmitter.fire();
|
||||
}
|
||||
};
|
||||
|
||||
private readonly _setOriginalPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
preset.setOriginalPresetsFile(folder, presetsFile);
|
||||
}
|
||||
};
|
||||
|
||||
private readonly _setOriginalUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
preset.setOriginalUserPresetsFile(folder, presetsFile);
|
||||
}
|
||||
};
|
||||
|
||||
private async resetPresetsFile(file: string,
|
||||
setPresetsFile: SetPresetsFileFunc,
|
||||
|
@ -197,7 +197,7 @@ export class PresetsController {
|
|||
const platmap = {
|
||||
win32: 'Windows',
|
||||
darwin: 'macOS',
|
||||
linux: 'Linux',
|
||||
linux: 'Linux'
|
||||
} as {[k: string]: preset.OsName};
|
||||
return platmap[process.platform];
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ export class PresetsController {
|
|||
return false;
|
||||
} else {
|
||||
let newPreset: preset.ConfigurePreset | undefined;
|
||||
switch(chosenItem.name) {
|
||||
switch (chosenItem.name) {
|
||||
case SpecialOptions.CreateFromCompilers: {
|
||||
// Check that we have kits
|
||||
if (!await this._kitsController.checkHaveKits()) {
|
||||
|
@ -299,8 +299,8 @@ export class PresetsController {
|
|||
async (kit): Promise<KitItem> => ({
|
||||
label: getKitName(kit),
|
||||
description: await descriptionForKit(kit, true),
|
||||
kit,
|
||||
}),
|
||||
kit
|
||||
})
|
||||
);
|
||||
const quickPickItems = await Promise.all(item_promises);
|
||||
const chosen_kit = await vscode.window.showQuickPick(quickPickItems,
|
||||
|
@ -310,7 +310,7 @@ export class PresetsController {
|
|||
// No selection was made
|
||||
return false;
|
||||
} else {
|
||||
if (chosen_kit.kit.name == SpecialKits.ScanForKits) {
|
||||
if (chosen_kit.kit.name === SpecialKits.ScanForKits) {
|
||||
await KitsController.scanForKits(this._cmakeTools);
|
||||
preset.setCompilers(this._kitsController.availableKits);
|
||||
return false;
|
||||
|
@ -442,7 +442,7 @@ export class PresetsController {
|
|||
return false;
|
||||
} else {
|
||||
let newPreset: preset.BuildPreset | undefined;
|
||||
switch(chosenItem.name) {
|
||||
switch (chosenItem.name) {
|
||||
case SpecialOptions.CreateFromConfigurationPreset: {
|
||||
const placeHolder = localize('select.a.config.preset.placeholder', 'Select a configure preset');
|
||||
const configurePreset = await this.showPresetSelector(preset.configurePresets(this.folderFsPath), { placeHolder });
|
||||
|
@ -517,7 +517,7 @@ export class PresetsController {
|
|||
return false;
|
||||
} else {
|
||||
let newPreset: preset.TestPreset | undefined;
|
||||
switch(chosenItem.name) {
|
||||
switch (chosenItem.name) {
|
||||
case SpecialOptions.CreateFromConfigurationPreset: {
|
||||
const placeHolder = localize('select.a.config.preset.placeholder', 'Select a configure preset');
|
||||
const configurePreset = await this.showPresetSelector(preset.configurePresets(this.folderFsPath), { placeHolder });
|
||||
|
@ -552,7 +552,7 @@ export class PresetsController {
|
|||
}
|
||||
|
||||
// Returns the name of the preset selected
|
||||
private async showPresetSelector(presets: preset.Preset[], options: vscode.QuickPickOptions & { canPickMany: true; }): Promise<string[] | undefined>;
|
||||
private async showPresetSelector(presets: preset.Preset[], options: vscode.QuickPickOptions & { canPickMany: true }): Promise<string[] | undefined>;
|
||||
private async showPresetSelector(presets: preset.Preset[], options: vscode.QuickPickOptions): Promise<string | undefined>;
|
||||
private async showPresetSelector(presets: preset.Preset[], options: vscode.QuickPickOptions): Promise<string | string[] | undefined> {
|
||||
interface PresetItem extends vscode.QuickPickItem {
|
||||
|
@ -563,7 +563,7 @@ export class PresetsController {
|
|||
label: _preset.displayName || _preset.name,
|
||||
description: _preset.description,
|
||||
preset: _preset.name
|
||||
}),
|
||||
})
|
||||
);
|
||||
items.push({
|
||||
label: localize('add.new.preset', 'Add a New Preset...'),
|
||||
|
@ -581,7 +581,7 @@ export class PresetsController {
|
|||
|
||||
const presets = preset.configurePresets(this.folderFsPath).concat(preset.userConfigurePresets(this.folderFsPath)).filter(
|
||||
_preset => {
|
||||
const supportedHost = (_preset.vendor as preset.Vendor_VsSettings)?.['microsoft.com/VisualStudioSettings/CMake/1.0']?.hostOS;
|
||||
const supportedHost = (_preset.vendor as preset.VendorVsSettings)?.['microsoft.com/VisualStudioSettings/CMake/1.0']?.hostOS;
|
||||
const osName = this.getOsName();
|
||||
if (supportedHost) {
|
||||
if (util.isString(supportedHost)) {
|
||||
|
@ -620,14 +620,14 @@ export class PresetsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('loading.config.preset', 'Loading configure preset {0}', presetName),
|
||||
title: localize('loading.config.preset', 'Loading configure preset {0}', presetName)
|
||||
},
|
||||
() => this._cmakeTools.setConfigurePreset(presetName),
|
||||
() => this._cmakeTools.setConfigurePreset(presetName)
|
||||
);
|
||||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('reloading.build.test.preset', 'Reloading build and test presets'),
|
||||
title: localize('reloading.build.test.preset', 'Reloading build and test presets')
|
||||
},
|
||||
async () => {
|
||||
const buildPreset = this._cmakeTools.buildPreset?.name;
|
||||
|
@ -698,9 +698,9 @@ export class PresetsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('unloading.build.preset', 'Unloading build preset'),
|
||||
title: localize('unloading.build.preset', 'Unloading build preset')
|
||||
},
|
||||
() => this._cmakeTools.setBuildPreset(null),
|
||||
() => this._cmakeTools.setBuildPreset(null)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -709,9 +709,9 @@ export class PresetsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('loading.build.preset', 'Loading build preset {0}', presetName),
|
||||
title: localize('loading.build.preset', 'Loading build preset {0}', presetName)
|
||||
},
|
||||
() => this._cmakeTools.setBuildPreset(presetName),
|
||||
() => this._cmakeTools.setBuildPreset(presetName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -755,9 +755,9 @@ export class PresetsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('unloading.test.preset', 'Unloading test preset'),
|
||||
title: localize('unloading.test.preset', 'Unloading test preset')
|
||||
},
|
||||
() => this._cmakeTools.setTestPreset(null),
|
||||
() => this._cmakeTools.setTestPreset(null)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -766,9 +766,9 @@ export class PresetsController {
|
|||
await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: localize('loading.test.preset', 'Loading test preset {0}', presetName),
|
||||
title: localize('loading.test.preset', 'Loading test preset {0}', presetName)
|
||||
},
|
||||
() => this._cmakeTools.setTestPreset(presetName),
|
||||
() => this._cmakeTools.setTestPreset(presetName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -864,7 +864,7 @@ export class PresetsController {
|
|||
}
|
||||
|
||||
async updatePresetsFile(presetsFile: preset.PresetsFile, isUserPresets = false): Promise<vscode.TextEditor | undefined> {
|
||||
const presetsFilePath = isUserPresets? this.userPresetsPath : this.presetsPath;
|
||||
const presetsFilePath = isUserPresets ? this.userPresetsPath : this.presetsPath;
|
||||
const indent = this.getIndentationSettings();
|
||||
try {
|
||||
await fs.writeFile(presetsFilePath, JSON.stringify(presetsFile, null, indent.insertSpaces ? indent.tabSize : '\t'));
|
||||
|
|
28
src/proc.ts
28
src/proc.ts
|
@ -1,6 +1,8 @@
|
|||
/* eslint-disable no-unused-expressions */
|
||||
|
||||
/**
|
||||
* Wrappers and utilities around the NodeJS `child_process` module.
|
||||
*/ /** */
|
||||
*/
|
||||
|
||||
import * as proc from 'child_process';
|
||||
import * as iconv from 'iconv-lite';
|
||||
|
@ -72,7 +74,7 @@ export interface BuildCommand {
|
|||
build_env?: {[key: string]: string};
|
||||
}
|
||||
|
||||
export interface EnvironmentVariables { [key: string]: string; }
|
||||
export interface EnvironmentVariables { [key: string]: string }
|
||||
|
||||
export interface ExecutionOptions {
|
||||
environment?: EnvironmentVariables;
|
||||
|
@ -87,7 +89,9 @@ export interface ExecutionOptions {
|
|||
|
||||
export function buildCmdStr(command: string, args?: string[]): string {
|
||||
let cmdarr = [command];
|
||||
if (args) cmdarr = cmdarr.concat(args);
|
||||
if (args) {
|
||||
cmdarr = cmdarr.concat(args);
|
||||
}
|
||||
return cmdarr.map(a => /[ \n\r\f;\t]/.test(a) ? `"${a}"` : a).join(' ');
|
||||
}
|
||||
|
||||
|
@ -126,7 +130,7 @@ export function execute(command: string,
|
|||
|
||||
const spawn_opts: proc.SpawnOptions = {
|
||||
env: final_env,
|
||||
shell: !!options.shell,
|
||||
shell: !!options.shell
|
||||
};
|
||||
if (options && options.cwd) {
|
||||
spawn_opts.cwd = options.cwd;
|
||||
|
@ -134,8 +138,7 @@ export function execute(command: string,
|
|||
let child: proc.ChildProcess|undefined;
|
||||
let result: Promise<ExecutionResult>;
|
||||
const useTask = (options && options.useTask) ? options.useTask : false;
|
||||
if (useTask)
|
||||
{
|
||||
if (useTask) {
|
||||
// child = undefined;
|
||||
// const term = vscode.window.createTerminal("Cmake Build");
|
||||
// term.show(true);
|
||||
|
@ -143,20 +146,16 @@ export function execute(command: string,
|
|||
|
||||
vscode.commands.executeCommand("workbench.action.tasks.build");
|
||||
|
||||
result = new Promise<ExecutionResult>((resolve, reject) => {
|
||||
result = new Promise<ExecutionResult>((resolve) => {
|
||||
resolve({retc: 0, stdout: '', stderr: ''});
|
||||
if (false) reject();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
try {
|
||||
child = proc.spawn(command, args ?? [], spawn_opts);
|
||||
} catch {
|
||||
child = undefined;
|
||||
}
|
||||
if (child === undefined)
|
||||
{
|
||||
if (child === undefined) {
|
||||
return {
|
||||
child: undefined,
|
||||
result: Promise.resolve({
|
||||
|
@ -166,8 +165,9 @@ export function execute(command: string,
|
|||
})
|
||||
};
|
||||
}
|
||||
if (options.encoding)
|
||||
if (options.encoding) {
|
||||
child.stdout?.setEncoding(options.encoding);
|
||||
}
|
||||
|
||||
const encoding = options.outputEncoding && iconv.encodingExists(options.outputEncoding) ? options.outputEncoding : 'utf8';
|
||||
|
||||
|
|
|
@ -42,4 +42,4 @@ export class Property<T> {
|
|||
}
|
||||
|
||||
dispose() { this._emitter.dispose(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,7 @@ export function cleanStack(stack?: string): string {
|
|||
return match.replace(fileName, name);
|
||||
});
|
||||
// Some are direct references to main.js without parenthesis
|
||||
stack = stack.replace(/at( async | )([^\n]+main.js(:\d+(:\d+)?)?)$/gm, (match: string, _unused: string, fileInfo: string, lineColumn: string) => {
|
||||
return match.replace(fileInfo, `main.js${lineColumn}`);
|
||||
});
|
||||
stack = stack.replace(/at( async | )([^\n]+main.js(:\d+(:\d+)?)?)$/gm, (match: string, _unused: string, fileInfo: string, lineColumn: string) => match.replace(fileInfo, `main.js${lineColumn}`));
|
||||
// As a last resort, remove anything that looks like it could be a path.
|
||||
const strings: string[] = stack.split('\n');
|
||||
strings.forEach((value, index, array) => {
|
||||
|
@ -134,7 +132,7 @@ class RollbarController {
|
|||
takePromise<T>(what: string, additional: object, pr: Thenable<T>): void {
|
||||
pr.then(
|
||||
() => {},
|
||||
e => { this.exception(localize('unhandled.promise.rejection', 'Unhandled Promise rejection: {0}', what), e, additional); },
|
||||
e => { this.exception(localize('unhandled.promise.rejection', 'Unhandled Promise rejection: {0}', what), e, additional); }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ajv, { ValidateFunction } from 'ajv';
|
||||
import Ajv, { ValidateFunction } from 'ajv';
|
||||
import * as path from 'path';
|
||||
|
||||
import {fs} from './pr';
|
||||
|
@ -7,5 +7,5 @@ import {thisExtensionPath} from './util';
|
|||
export async function loadSchema(filepath: string): Promise<ValidateFunction> {
|
||||
const schema_path = path.isAbsolute(filepath) ? filepath : path.join(thisExtensionPath(), filepath);
|
||||
const schema_data = JSON.parse((await fs.readFile(schema_path)).toString());
|
||||
return new ajv({allErrors: true}).compile(schema_data);
|
||||
return new Ajv({allErrors: true}).compile(schema_data);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ export interface ShlexOptions {
|
|||
|
||||
export function* split(str: string, opt?: ShlexOptions): Iterable<string> {
|
||||
opt = opt || {
|
||||
mode: process.platform === 'win32' ? 'windows' : 'posix',
|
||||
mode: process.platform === 'win32' ? 'windows' : 'posix'
|
||||
};
|
||||
const quoteChars = opt.mode === 'posix' ? '\'"' : '"';
|
||||
const escapeChars = '\\';
|
||||
|
@ -72,9 +72,9 @@ export function* split(str: string, opt?: ShlexOptions): Iterable<string> {
|
|||
|
||||
export function quote(str: string, opt?: ShlexOptions): string {
|
||||
opt = opt || {
|
||||
mode: process.platform === 'win32' ? 'windows' : 'posix',
|
||||
mode: process.platform === 'win32' ? 'windows' : 'posix'
|
||||
};
|
||||
if (str == '') {
|
||||
if (str === '') {
|
||||
return '""';
|
||||
}
|
||||
if (/[^\w@%\-+=:,./|]/.test(str)) {
|
||||
|
@ -83,4 +83,4 @@ export function quote(str: string, opt?: ShlexOptions): string {
|
|||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,10 @@ import * as nls from 'vscode-nls';
|
|||
nls.config({messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone})();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
||||
//---------------------------------------------
|
||||
//-------------- Helper Functions -------------
|
||||
//---------------------------------------------
|
||||
|
||||
// Helper functions
|
||||
function hasCPPTools(): boolean { return vscode.extensions.getExtension('ms-vscode.cpptools') !== undefined; }
|
||||
//---------------------------------------------
|
||||
//---------------- Button Class ---------------
|
||||
//---------------------------------------------
|
||||
|
||||
// Button class
|
||||
abstract class Button {
|
||||
readonly settingsName: string|null = null;
|
||||
protected readonly button: vscode.StatusBarItem;
|
||||
|
@ -150,7 +145,7 @@ abstract class Button {
|
|||
if (!this._icon) {
|
||||
return text;
|
||||
}
|
||||
if (text == '') {
|
||||
if (text === '') {
|
||||
return this._icon || '';
|
||||
}
|
||||
return `${this._icon} ${text}`;
|
||||
|
@ -170,7 +165,6 @@ class WorkspaceButton extends Button {
|
|||
this.tooltip = localize('click.to.select.workspace.tooltip', 'Click to select the active folder');
|
||||
}
|
||||
|
||||
|
||||
// private _autoSelect: boolean = false;
|
||||
set autoSelect(v: boolean) {
|
||||
if (v) {}
|
||||
|
@ -181,7 +175,7 @@ class WorkspaceButton extends Button {
|
|||
protected getTooltipNormal(): string|null {
|
||||
// if (this._autoSelect) {
|
||||
// return `${this.tooltip} (${WorkspaceButton._autoSelectToolTip})`;
|
||||
//}
|
||||
// }
|
||||
return this.tooltip;
|
||||
}
|
||||
protected getTooltipShort(): string|null { return this.prependCMake(this.getTooltipNormal()); }
|
||||
|
@ -258,7 +252,7 @@ class KitSelection extends Button {
|
|||
}
|
||||
|
||||
protected getTooltipShort(): string|null {
|
||||
if (this.getTextNormal() == this.getTextShort()) {
|
||||
if (this.getTextNormal() === this.getTextShort()) {
|
||||
return this.prependCMake(this.getTooltipNormal());
|
||||
}
|
||||
return super.getTooltipShort();
|
||||
|
@ -366,7 +360,7 @@ class CTestButton extends Button {
|
|||
update(): void {
|
||||
if (this._results) {
|
||||
const {passing, total} = this._results;
|
||||
this.icon = passing == total ? 'check' : 'x';
|
||||
this.icon = passing === total ? 'check' : 'x';
|
||||
} else {
|
||||
this.icon = 'beaker';
|
||||
}
|
||||
|
@ -386,7 +380,7 @@ class CTestButton extends Button {
|
|||
return localize('run.ctest', 'Run CTest');
|
||||
}
|
||||
const {passing, total} = this._results;
|
||||
if (total == 1) {
|
||||
if (total === 1) {
|
||||
return localize('test.passing', '{0}/{1} test passing', passing, total);
|
||||
}
|
||||
return localize('tests.passing', '{0}/{1} tests passing', passing, total);
|
||||
|
@ -486,7 +480,7 @@ export class ConfigurePresetSelection extends Button {
|
|||
}
|
||||
|
||||
protected getTooltipShort(): string|null {
|
||||
if (this.getTextNormal() == this.getTextShort()) {
|
||||
if (this.getTextNormal() === this.getTextShort()) {
|
||||
return this.prependCMake(this.getTooltipNormal());
|
||||
}
|
||||
return super.getTooltipShort();
|
||||
|
@ -529,7 +523,7 @@ export class BuildPresetSelection extends Button {
|
|||
}
|
||||
|
||||
protected getTooltipShort(): string|null {
|
||||
if (this.getTextNormal() == this.getTextShort()) {
|
||||
if (this.getTextNormal() === this.getTextShort()) {
|
||||
return this.prependCMake(this.getTooltipNormal());
|
||||
}
|
||||
return super.getTooltipShort();
|
||||
|
@ -572,7 +566,7 @@ export class TestPresetSelection extends Button {
|
|||
}
|
||||
|
||||
protected getTooltipShort(): string|null {
|
||||
if (this.getTextNormal() == this.getTextShort()) {
|
||||
if (this.getTextNormal() === this.getTextShort()) {
|
||||
return this.prependCMake(this.getTooltipNormal());
|
||||
}
|
||||
return super.getTooltipShort();
|
||||
|
@ -642,9 +636,9 @@ export class StatusBar implements vscode.Disposable {
|
|||
setTestResults(v: BasicTestResults|null): void { this._testButton.results = v; }
|
||||
setIsBusy(v: boolean): void { this._buildButton.isBusy = v; }
|
||||
setActiveKitName(v: string): void { this._kitSelectionButton.text = v; }
|
||||
setConfigurePresetName(v:string): void { this._configurePresetButton.text = v; }
|
||||
setBuildPresetName(v:string): void { this._buildPresetButton.text = v; }
|
||||
setTestPresetName(v:string): void { this._testPresetButton.text = v; this.setCTestEnabled(true); }
|
||||
setConfigurePresetName(v: string): void { this._configurePresetButton.text = v; }
|
||||
setBuildPresetName(v: string): void { this._buildPresetButton.text = v; }
|
||||
setTestPresetName(v: string): void { this._testPresetButton.text = v; this.setCTestEnabled(true); }
|
||||
|
||||
hideLaunchButton(shouldHide: boolean = true): void { this._launchButton.hidden = shouldHide; }
|
||||
hideDebugButton(shouldHide: boolean = true): void { this._debugButton.hidden = shouldHide; }
|
||||
|
@ -658,4 +652,4 @@ export class StatusBar implements vscode.Disposable {
|
|||
this._buildPresetButton.hidden = !isUsing;
|
||||
this._testPresetButton.hidden = !isUsing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ export class Strand {
|
|||
|
||||
private _enqueue(fn: () => Promise<void>) {
|
||||
this._tailPromise = this._tailPromise.then(
|
||||
() => fn(),
|
||||
() => fn(),
|
||||
fn,
|
||||
fn
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -44,4 +44,4 @@ export class Strand {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
/* ---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
@ -61,4 +61,4 @@ async function getCMakeTasks(taskCommands: TaskCommands): Promise<vscode.Task[]>
|
|||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,4 +53,4 @@ function getPackageInfo(): IPackageInfo {
|
|||
version: packageJSON.version,
|
||||
aiKey: "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
52
src/tree.ts
52
src/tree.ts
|
@ -67,7 +67,7 @@ function addToTree<T>(tree: PathedTree<T>, itemPath: string, item: T) {
|
|||
subtree = {
|
||||
pathPart: el,
|
||||
children: [],
|
||||
items: [],
|
||||
items: []
|
||||
};
|
||||
tree.children.push(subtree);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ function collapseTreeInplace<T>(tree: PathedTree<T>): void {
|
|||
child = {
|
||||
pathPart: path.join(child.pathPart, subchild.pathPart),
|
||||
items: subchild.items,
|
||||
children: subchild.children,
|
||||
children: subchild.children
|
||||
};
|
||||
}
|
||||
collapseTreeInplace(child);
|
||||
|
@ -163,10 +163,10 @@ export class DirectoryNode<Node extends BaseNode> extends BaseNode {
|
|||
}
|
||||
|
||||
update<InputItem extends NamedItem>(opts: {
|
||||
tree: PathedTree<InputItem>,
|
||||
context: TreeUpdateContext,
|
||||
create(input: InputItem): Node,
|
||||
update(existingNode: Node, input: InputItem): void,
|
||||
tree: PathedTree<InputItem>;
|
||||
context: TreeUpdateContext;
|
||||
create(input: InputItem): Node;
|
||||
update(existingNode: Node, input: InputItem): void;
|
||||
}) {
|
||||
const new_subdirs = new Map<string, DirectoryNode<Node>>();
|
||||
const new_leaves = new Map<string, Node>();
|
||||
|
@ -179,7 +179,7 @@ export class DirectoryNode<Node extends BaseNode> extends BaseNode {
|
|||
}
|
||||
existing.update({
|
||||
...opts,
|
||||
tree: new_subdir,
|
||||
tree: new_subdir
|
||||
});
|
||||
new_subdirs.set(new_subdir.pathPart, existing);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ export class DirectoryNode<Node extends BaseNode> extends BaseNode {
|
|||
// We added/removed nodes
|
||||
did_update = true;
|
||||
}
|
||||
if (new_leaves.size != this._leaves.size) {
|
||||
if (new_leaves.size !== this._leaves.size) {
|
||||
// We added/removed leaves
|
||||
did_update = true;
|
||||
}
|
||||
|
@ -226,13 +226,13 @@ export class SourceFileNode extends BaseNode {
|
|||
item.id = this.id;
|
||||
item.resourceUri = vscode.Uri.file(this.filePath);
|
||||
const name = this.name.toLowerCase();
|
||||
const cml = name == "cmakelists.txt";
|
||||
const is_compilable = ['CXX', 'C'].indexOf(this._language||'')!==-1;
|
||||
const cml = name === "cmakelists.txt";
|
||||
const is_compilable = ['CXX', 'C'].indexOf(this._language || '') !== -1;
|
||||
item.contextValue = ['nodeType=file', `compilable=${is_compilable}`, `cmakelists=${cml}`].join(',');
|
||||
item.command = {
|
||||
title: localize('open.file', 'Open file'),
|
||||
command: 'vscode.open',
|
||||
arguments: [item.resourceUri],
|
||||
arguments: [item.resourceUri]
|
||||
};
|
||||
return item;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ export class TargetNode extends BaseNode {
|
|||
if (this._isLaunch) {
|
||||
item.label += ' 🚀';
|
||||
}
|
||||
if (this._fullName != this.name && this._fullName) {
|
||||
if (this._fullName !== this.name && this._fullName) {
|
||||
item.label += ` [${this._fullName}]`;
|
||||
}
|
||||
if (this._type === 'INTERFACE_LIBRARY') {
|
||||
|
@ -305,7 +305,7 @@ export class TargetNode extends BaseNode {
|
|||
`isLaunch=${this._isLaunch}`,
|
||||
`type=${this._type}`,
|
||||
`canBuild=${canBuild}`,
|
||||
`canRun=${canRun}`,
|
||||
`canRun=${canRun}`
|
||||
].join(',');
|
||||
return item;
|
||||
} catch (e) {
|
||||
|
@ -315,8 +315,8 @@ export class TargetNode extends BaseNode {
|
|||
}
|
||||
|
||||
update(cm: codemodel_api.CodeModelTarget, ctx: TreeUpdateContext) {
|
||||
console.assert(this.name == cm.name);
|
||||
console.assert(this.sourceDir == (cm.sourceDirectory || ''));
|
||||
console.assert(this.name === cm.name);
|
||||
console.assert(this.sourceDir === (cm.sourceDirectory || ''));
|
||||
|
||||
let did_update = this._fullName !== (cm.fullName || '');
|
||||
this._fullName = cm.fullName || '';
|
||||
|
@ -343,7 +343,7 @@ export class TargetNode extends BaseNode {
|
|||
const tree: PathedTree<SourceFileNode> = {
|
||||
pathPart: this.sourceDir,
|
||||
items: [],
|
||||
children: [],
|
||||
children: []
|
||||
};
|
||||
|
||||
for (const grp of cm.fileGroups || []) {
|
||||
|
@ -365,7 +365,7 @@ export class TargetNode extends BaseNode {
|
|||
tree,
|
||||
context: ctx,
|
||||
update: (_src, _cm) => {},
|
||||
create: newNode => newNode,
|
||||
create: newNode => newNode
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ class ProjectNode extends BaseNode {
|
|||
if (this.getChildren().length === 0) {
|
||||
item.label += ` — (${localize('empty.project', 'Empty project')})`;
|
||||
}
|
||||
item.tooltip=`${this.name}\n${this.sourceDirectory}`;
|
||||
item.tooltip = `${this.name}\n${this.sourceDirectory}`;
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ class ProjectNode extends BaseNode {
|
|||
const tree: PathedTree<codemodel_api.CodeModelTarget> = {
|
||||
pathPart: '',
|
||||
children: [],
|
||||
items: [],
|
||||
items: []
|
||||
};
|
||||
|
||||
for (const target of pr.targets) {
|
||||
|
@ -431,7 +431,7 @@ class ProjectNode extends BaseNode {
|
|||
const node = new TargetNode(this.id, this.name, cm, this.folder);
|
||||
node.update(cm, ctx);
|
||||
return node;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// const target_tree = mapTreeItems(tree, target => TargetNode.fromCodeModel(pr.name, target));
|
||||
|
@ -449,7 +449,7 @@ export class WorkspaceFolderNode extends BaseNode {
|
|||
private _children: BaseNode[] = [];
|
||||
|
||||
private _active: boolean = false;
|
||||
setActive(active:boolean) {
|
||||
setActive(active: boolean) {
|
||||
this._active = active;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ export class WorkspaceFolderNode extends BaseNode {
|
|||
const item = new vscode.TreeItem(this.wsFolder.uri.fsPath, vscode.TreeItemCollapsibleState.Expanded);
|
||||
item.iconPath = vscode.ThemeIcon.Folder;
|
||||
item.id = this.wsFolder.uri.fsPath;
|
||||
let description:string;
|
||||
let description: string;
|
||||
if (this._active) {
|
||||
description = localize('workspace.active', 'Active Workspace');
|
||||
} else {
|
||||
|
@ -499,7 +499,7 @@ export class ProjectOutlineProvider implements vscode.TreeDataProvider<BaseNode>
|
|||
get onDidChangeTreeData() { return this._changeEvent.event; }
|
||||
|
||||
private readonly _folders = new Map<string, WorkspaceFolderNode>();
|
||||
private _selected_workspace?:WorkspaceFolderNode;
|
||||
private _selected_workspace?: WorkspaceFolderNode;
|
||||
|
||||
addAllCurrentFolders() {
|
||||
for (const wsf of vscode.workspace.workspaceFolders || []) {
|
||||
|
@ -550,8 +550,10 @@ export class ProjectOutlineProvider implements vscode.TreeDataProvider<BaseNode>
|
|||
}
|
||||
}
|
||||
|
||||
setActiveFolder(ws: vscode.WorkspaceFolder | undefined):void {
|
||||
if (!ws) return;
|
||||
setActiveFolder(ws: vscode.WorkspaceFolder | undefined): void {
|
||||
if (!ws) {
|
||||
return;
|
||||
}
|
||||
const current_node = this._selected_workspace;
|
||||
const new_node = this._folders.get(ws.uri.fsPath);
|
||||
if (current_node) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
export interface TargetTriple {
|
||||
triple: string;
|
||||
targetOs: string;
|
||||
|
@ -79,7 +78,7 @@ const TriplePossibleOS: {[index: string]: RegExp} = {
|
|||
uclinux: /^uclinux.*/,
|
||||
bsd: /^(netbsd|openbsd)/,
|
||||
vxworks: /^(vxworks|vxworksae)$/,
|
||||
none: /^none$/,
|
||||
none: /^none$/
|
||||
};
|
||||
|
||||
const TriplePossibleABI: {[index: string]: RegExp} = {
|
||||
|
@ -87,19 +86,19 @@ const TriplePossibleABI: {[index: string]: RegExp} = {
|
|||
marcho: /^darwin.*/,
|
||||
pe: /^(mingw32|mingw|mingw64|w64|msvc|windows|cygwin|msys)/,
|
||||
eabi: /^eabi$/,
|
||||
eabisim: /^eabisim$/,
|
||||
eabisim: /^eabisim$/
|
||||
};
|
||||
|
||||
const TriplePossibleLibC: {[index: string]: RegExp} = {
|
||||
musl: /^musl$/,
|
||||
glibc: /^(gnu|msys|cygwin)$/,
|
||||
msvcrt: /^msvc$/,
|
||||
mingw: /^(mingw32|mingw|mingw64|w64)/,
|
||||
mingw: /^(mingw32|mingw|mingw64|w64)/
|
||||
// 'llvm': /^llvm$/, TODO:https://github.com/llvm/llvm-project/tree/master/libc/src/stdio
|
||||
// otherwise system libc
|
||||
};
|
||||
|
||||
export function computeTargetTriple(target:TargetTriple): string {
|
||||
export function computeTargetTriple(target: TargetTriple): string {
|
||||
let triple = target.targetArch;
|
||||
if (target.vendors.length > 0) {
|
||||
const vendor = target.vendors.join('_');
|
||||
|
@ -183,12 +182,12 @@ export function parseTargetTriple(triple: string): TargetTriple | undefined {
|
|||
targetOs: foundOs === 'unknow' ? 'none' : foundOs,
|
||||
targetArch: foundArch,
|
||||
vendors,
|
||||
abi: foundAbi === 'unknow' ? '': foundAbi,
|
||||
libc: foundLibc === 'unknow' ? '' : foundLibc,
|
||||
abi: foundAbi === 'unknow' ? '' : foundAbi,
|
||||
libc: foundLibc === 'unknow' ? '' : foundLibc
|
||||
};
|
||||
}
|
||||
|
||||
export function majorVersionSemver(semver: string) : string {
|
||||
export function majorVersionSemver(semver: string): string {
|
||||
const major_version_re = /^(\d+)./;
|
||||
const major_version_match = major_version_re.exec(semver);
|
||||
if (Array.isArray(major_version_match)) {
|
||||
|
@ -197,7 +196,7 @@ export function majorVersionSemver(semver: string) : string {
|
|||
return '';
|
||||
}
|
||||
|
||||
export function minorVersionSemver(semver: string) : string {
|
||||
export function minorVersionSemver(semver: string): string {
|
||||
const minor_version_re = /^(\d+).(\d+)/;
|
||||
const minor_version_match = minor_version_re.exec(semver);
|
||||
if (Array.isArray(minor_version_match)) {
|
||||
|
|
20
src/util.ts
20
src/util.ts
|
@ -11,7 +11,6 @@ import rollbar from '@cmt/rollbar';
|
|||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
||||
|
||||
/**
|
||||
* Escape a string so it can be used as a regular expression
|
||||
*/
|
||||
|
@ -219,7 +218,6 @@ export function find<T>(iter: Iterable<T>, predicate: (value: T) => boolean): T|
|
|||
*/
|
||||
export function randint(min: number, max: number): number { return Math.floor(Math.random() * (max - min) + min); }
|
||||
|
||||
|
||||
export function product<T>(arrays: T[][]): T[][] {
|
||||
// clang-format off
|
||||
return arrays.reduce((acc, curr) =>
|
||||
|
@ -248,7 +246,7 @@ export interface CMakeValue {
|
|||
export function cmakeify(value: (string|boolean|number|string[])): CMakeValue {
|
||||
const ret: CMakeValue = {
|
||||
type: 'UNKNOWN',
|
||||
value: '',
|
||||
value: ''
|
||||
};
|
||||
if (value === true || value === false) {
|
||||
ret.type = 'BOOL';
|
||||
|
@ -268,7 +266,6 @@ export function cmakeify(value: (string|boolean|number|string[])): CMakeValue {
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
export async function termProc(child: child_process.ChildProcess) {
|
||||
// Stopping the process isn't as easy as it may seem. cmake --build will
|
||||
// spawn child processes, and CMake won't forward signals to its
|
||||
|
@ -286,8 +283,9 @@ async function _killTree(pid: number) {
|
|||
children = stdout.split('\n').map(line => Number.parseInt(line));
|
||||
}
|
||||
for (const other of children) {
|
||||
if (other)
|
||||
if (other) {
|
||||
await _killTree(other);
|
||||
}
|
||||
}
|
||||
try {
|
||||
process.kill(pid, 'SIGINT');
|
||||
|
@ -336,7 +334,7 @@ export function parseVersion(str: string): Version {
|
|||
return {
|
||||
major: parseInt(major),
|
||||
minor: parseInt(minor),
|
||||
patch: parseInt(patch),
|
||||
patch: parseInt(patch)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -378,7 +376,7 @@ export function mergeEnvironment(...env: EnvironmentVariables[]): EnvironmentVar
|
|||
}
|
||||
|
||||
export function normalizeEnvironmentVarname(varname: string) {
|
||||
return process.platform == 'win32' ? varname.toUpperCase() : varname;
|
||||
return process.platform === 'win32' ? varname.toUpperCase() : varname;
|
||||
}
|
||||
|
||||
export function parseCompileDefinition(str: string): [string, string|null] {
|
||||
|
@ -409,7 +407,7 @@ export function thisExtensionPackage(): PackageJSON {
|
|||
return {
|
||||
name: pkg.name,
|
||||
publisher: pkg.publisher,
|
||||
version: pkg.version,
|
||||
version: pkg.version
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -540,9 +538,9 @@ export function lexicographicalCompare(a: Iterable<string>, b: Iterable<string>)
|
|||
}
|
||||
|
||||
export function getLocaleId(): string {
|
||||
if (typeof(process.env.VSCODE_NLS_CONFIG) == "string") {
|
||||
if (typeof(process.env.VSCODE_NLS_CONFIG) === "string") {
|
||||
const vscodeNlsConfigJson: any = JSON.parse(process.env.VSCODE_NLS_CONFIG);
|
||||
if (typeof(vscodeNlsConfigJson.locale) == "string") {
|
||||
if (typeof(vscodeNlsConfigJson.locale) === "string") {
|
||||
return vscodeNlsConfigJson.locale;
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +603,7 @@ export function isArrayOfString(x: any): x is string[] {
|
|||
export function isNullOrUndefined(x?: any): boolean {
|
||||
// Double equals provides the correct answer for 'null' and 'undefined'
|
||||
// http://www.ecma-international.org/ecma-262/6.0/index.html#sec-abstract-equality-comparison
|
||||
return x == null;
|
||||
return x === null;
|
||||
}
|
||||
|
||||
export function isWorkspaceFolder(x?: any): boolean {
|
||||
|
|
|
@ -73,7 +73,7 @@ export interface VarFileSetting {
|
|||
/**
|
||||
* The possible options for this setting.
|
||||
*/
|
||||
choices: {[key: string]: VarFileOption|undefined;};
|
||||
choices: {[key: string]: VarFileOption|undefined};
|
||||
}
|
||||
/**
|
||||
* The root of a `cmake-variants.(yaml|json)`
|
||||
|
@ -131,16 +131,14 @@ export interface VariantCombination extends vscode.QuickPickItem {
|
|||
|
||||
export function processVariantFileData(root: VarFileRoot): VariantCollection {
|
||||
const settings = util.objectPairs(root).map(([setting_name, setting_def]): VariantSetting => {
|
||||
const choices = util.objectPairs(setting_def!.choices).map(([opt_key, opt_def]): VariantOption => {
|
||||
return {
|
||||
const choices = util.objectPairs(setting_def!.choices).map(([opt_key, opt_def]): VariantOption => ({
|
||||
...opt_def!,
|
||||
key: opt_key,
|
||||
};
|
||||
});
|
||||
key: opt_key
|
||||
}));
|
||||
return {
|
||||
name: setting_name,
|
||||
default: setting_def!.default,
|
||||
choices,
|
||||
choices
|
||||
};
|
||||
});
|
||||
return {settings};
|
||||
|
@ -154,22 +152,22 @@ export const DEFAULT_VARIANTS: VarFileRoot = {
|
|||
debug: {
|
||||
short: 'Debug',
|
||||
long: localize('emit.debug.without.optimizations', 'Emit debug information without performing optimizations'),
|
||||
buildType: 'Debug',
|
||||
buildType: 'Debug'
|
||||
},
|
||||
release: {
|
||||
short: 'Release',
|
||||
long: localize('enable.optimizations.omit.debug', 'Enable optimizations, omit debug info'),
|
||||
buildType: 'Release',
|
||||
buildType: 'Release'
|
||||
},
|
||||
minsize: {
|
||||
short: 'MinSizeRel',
|
||||
long: localize('optimize.for.smallest', 'Optimize for smallest binary size'),
|
||||
buildType: 'MinSizeRel',
|
||||
buildType: 'MinSizeRel'
|
||||
},
|
||||
reldeb: {
|
||||
short: 'RelWithDebInfo',
|
||||
long: localize('optimize.and.debug', 'Perform optimizations AND include debugging information'),
|
||||
buildType: 'RelWithDebInfo',
|
||||
buildType: 'RelWithDebInfo'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +189,6 @@ export class VariantManager implements vscode.Disposable {
|
|||
|
||||
private customVariantsFileExists: boolean = false;
|
||||
|
||||
|
||||
dispose() {
|
||||
// tslint:disable-next-line: no-floating-promises
|
||||
this._variantFileWatcher.close();
|
||||
|
@ -244,7 +241,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
path.join(workdir, 'cmake-variants.json'),
|
||||
path.join(workdir, 'cmake-variants.yaml'),
|
||||
path.join(workdir, '.vscode/cmake-variants.json'),
|
||||
path.join(workdir, '.vscode/cmake-variants.yaml'),
|
||||
path.join(workdir, '.vscode/cmake-variants.yaml')
|
||||
];
|
||||
for (const testpath of candidates) {
|
||||
if (await fs.exists(testpath)) {
|
||||
|
@ -290,15 +287,15 @@ export class VariantManager implements vscode.Disposable {
|
|||
|
||||
variantConfigurationOptionsForKWs(keywordSetting: Map<string, string>): VariantOption[]|string {
|
||||
const vars = this._variants;
|
||||
let error: string|undefined = undefined;
|
||||
let error: string|undefined;
|
||||
const data = Array.from(keywordSetting.entries()).map(([setting_key, opt_key]): VariantOption => {
|
||||
const unknown_choice: VariantOption = {short: 'Unknown', key: '__unknown__'};
|
||||
const found_setting = vars.settings.find(s => s.name == setting_key);
|
||||
const found_setting = vars.settings.find(s => s.name === setting_key);
|
||||
if (!found_setting) {
|
||||
error = localize('missing.setting.in.variant', 'Missing setting "{0}" in variant definition.', setting_key);
|
||||
return unknown_choice;
|
||||
}
|
||||
const found_choice = found_setting.choices.find(o => o.key == opt_key);
|
||||
const found_choice = found_setting.choices.find(o => o.key === opt_key);
|
||||
if (!found_choice) {
|
||||
error = localize('missing.variant.choice', 'Missing variant choice "{0}" on "{1}" in variant definition.', opt_key, setting_key);
|
||||
return unknown_choice;
|
||||
|
@ -321,10 +318,10 @@ export class VariantManager implements vscode.Disposable {
|
|||
linkage: el.linkage || acc.linkage,
|
||||
// TS 2.4 doesn't like using object spread here, for some reason.
|
||||
// tslint:disable-next-line:prefer-object-spread
|
||||
settings: Object.assign({}, acc.settings, el.settings),
|
||||
settings: { ...acc.settings, ...el.settings},
|
||||
short: [acc.short, el.short].join(' ').trim(),
|
||||
long: [acc.long, el.long].join(', '),
|
||||
env: util.mergeEnvironment(acc.env || {}, el.env || {}),
|
||||
env: util.mergeEnvironment(acc.env || {}, el.env || {})
|
||||
}),
|
||||
init);
|
||||
}
|
||||
|
@ -333,7 +330,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
const invalid_variant = {
|
||||
key: '__invalid__',
|
||||
short: 'Unknown',
|
||||
long: 'Unknwon',
|
||||
long: 'Unknwon'
|
||||
};
|
||||
const kws = this.stateManager.activeVariantSettings;
|
||||
if (!kws) {
|
||||
|
@ -366,14 +363,14 @@ export class VariantManager implements vscode.Disposable {
|
|||
const variants = this._variants.settings.map(setting => setting.choices.map(opt => ({
|
||||
settingKey: setting.name,
|
||||
settingValue: opt.key,
|
||||
settings: opt,
|
||||
settings: opt
|
||||
})));
|
||||
const product = util.product(variants);
|
||||
const items: VariantCombination[]
|
||||
= product.map(optionset => ({
|
||||
label: optionset.map(o => o.settings.short).join(' + '),
|
||||
keywordSettings: this.transformChoiceCombinationToKeywordSettings(optionset),
|
||||
description: optionset.map(o => o.settings.long).join(' + '),
|
||||
description: optionset.map(o => o.settings.long).join(' + ')
|
||||
}));
|
||||
if (name) {
|
||||
for (const item of items) {
|
||||
|
@ -413,7 +410,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
return this.stateManager.activeVariantSettings;
|
||||
}
|
||||
|
||||
transformChoiceCombinationToKeywordSettings(choiceCombination: {settingKey: string, settingValue: string}[]):
|
||||
transformChoiceCombinationToKeywordSettings(choiceCombination: {settingKey: string; settingValue: string}[]):
|
||||
Map<string, string> {
|
||||
const keywords = new Map<string, string>();
|
||||
choiceCombination.forEach(kv => keywords.set(kv.settingKey, kv.settingValue));
|
||||
|
@ -423,7 +420,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
findDefaultChoiceCombination(): Map<string, string> {
|
||||
const defaults = this._variants.settings.map(setting => ({
|
||||
settingKey: setting.name,
|
||||
settingValue: setting.default,
|
||||
settingValue: setting.default
|
||||
}));
|
||||
return this.transformChoiceCombinationToKeywordSettings(Array.from(defaults));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export class DirectoryContext {
|
|||
/**
|
||||
* The state management object associated with the directory.
|
||||
*/
|
||||
public readonly state: StateManager,
|
||||
public readonly state: StateManager
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
@ -49,4 +49,4 @@ export class DirectoryContext {
|
|||
* information.
|
||||
*/
|
||||
getCTestPath(overWriteCMakePathSetting?: string): Promise<string|null> { return paths.getCTestPath(this, overWriteCMakePathSetting); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ suite('Build', async () => {
|
|||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state == "failed") {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
|
|
|
@ -62,7 +62,7 @@ suite('Build using Kits and Variants', async () => {
|
|||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state == "failed") {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
|
@ -250,7 +250,7 @@ suite('Build using Presets', async () => {
|
|||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state == "failed") {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
|
|
|
@ -62,7 +62,7 @@ suite('Build', async () => {
|
|||
const logPath = logFilePath();
|
||||
testEnv.clean();
|
||||
if (await fs.exists(logPath)) {
|
||||
if (this.currentTest?.state == "failed") {
|
||||
if (this.currentTest?.state === "failed") {
|
||||
const logContent = await fs.readFile(logPath);
|
||||
logContent.toString().split('\n').forEach(line => {
|
||||
console.log(line);
|
||||
|
|
|
@ -213,8 +213,8 @@ function makeExtensionTestSuite(name: string,
|
|||
context.buildSystem.excludeKit);
|
||||
|
||||
context.pathBackup = process.env.PATH!;
|
||||
if (context.buildSystem.path && context.buildSystem.path.length != 0) {
|
||||
process.env.PATH = context.buildSystem.path.join(process.platform == 'win32' ? ';' : ':');
|
||||
if (context.buildSystem.path && context.buildSystem.path.length !== 0) {
|
||||
process.env.PATH = context.buildSystem.path.join(process.platform === 'win32' ? ';' : ':');
|
||||
}
|
||||
|
||||
context.cmt = await CMakeTools.create(context.testEnv.vsContext, context.testEnv.wsContext);
|
||||
|
|
|
@ -51,7 +51,7 @@ export class DefaultEnvironment {
|
|||
|
||||
private setupShowQuickPickerStub(selections: QuickPickerHandleStrategy[]) {
|
||||
const fakeShowQuickPick = <T>(items: T[] | Thenable<T[]>, options?: vscode.QuickPickOptions, _token?: vscode.CancellationToken): Thenable<T | undefined> => {
|
||||
if (options?.placeHolder == selections[0].identifier) {
|
||||
if (options?.placeHolder === selections[0].identifier) {
|
||||
return Promise.resolve(selections[0].handleQuickPick(items));
|
||||
}
|
||||
console.trace();
|
||||
|
|
|
@ -29,7 +29,7 @@ export class SelectKitPickerHandle implements QuickPickerHandleStrategy {
|
|||
});
|
||||
}
|
||||
|
||||
if (defaultKit && defaultKit.length != 0) {
|
||||
if (defaultKit && defaultKit.length !== 0) {
|
||||
return Promise.resolve(defaultKit[0]);
|
||||
} else {
|
||||
expect.fail('Unable to find compatible kit');
|
||||
|
|
|
@ -16,7 +16,7 @@ smokeSuite('no-ctest-in-bindir', suite => {
|
|||
return ctx.withCMakeTools({
|
||||
kit: await smokeTestDefaultKit(),
|
||||
async run(cmt) {
|
||||
const cmake_filename = process.platform == 'win32' ? 'cmake.bat' : 'cmake.sh';
|
||||
const cmake_filename = process.platform === 'win32' ? 'cmake.bat' : 'cmake.sh';
|
||||
cmt.workspaceContext.config.updatePartial({
|
||||
cmakePath: path.join(ctx.projectDir.uri.fsPath, 'bin', cmake_filename),
|
||||
});
|
||||
|
|
|
@ -155,7 +155,7 @@ suite('Diagnostics', async () => {
|
|||
expect(diag.message).to.eq('comparison of unsigned expression >= 0 is always true [-Wtautological-compare]');
|
||||
expect(diag.location.start.character).to.eq(14);
|
||||
const expected = '/Users/ruslan.sorokin/Projects/Other/dpi/core/dpi_histogram.h';
|
||||
expect(platformPathEquivalent(diag.file, expected), `${diag.file} != ${expected}`).to.be.true;
|
||||
expect(platformPathEquivalent(diag.file, expected), `${diag.file} !== ${expected}`).to.be.true;
|
||||
expect(diag.severity).to.eq('warning');
|
||||
expect(path.posix.normalize(diag.file)).to.eq(diag.file);
|
||||
expect(path.posix.isAbsolute(diag.file)).to.be.true;
|
||||
|
@ -167,7 +167,7 @@ suite('Diagnostics', async () => {
|
|||
expect(build_consumer.compilers.gcc.diagnostics).to.have.length(1);
|
||||
const diag = build_consumer.compilers.gcc.diagnostics[0];
|
||||
const expected = '/Users/Tobias/Code/QUIT/Source/qidespot1.cpp';
|
||||
expect(platformPathEquivalent(diag.file, expected), `${diag.file} != ${expected}`).to.be.true;
|
||||
expect(platformPathEquivalent(diag.file, expected), `${diag.file} !== ${expected}`).to.be.true;
|
||||
expect(diag.location.start.line).to.eq(302);
|
||||
expect(diag.location.start.character).to.eq(48);
|
||||
expect(diag.message).to.eq(`expected ';' after expression`);
|
||||
|
|
|
@ -137,7 +137,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
const codemodel_data = await generateCodeModelForConfiguredDriver();
|
||||
expect(codemodel_data).to.be.not.null;
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'EXECUTABLE' && t.name == 'TestBuildProcess');
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'EXECUTABLE' && t.name === 'TestBuildProcess');
|
||||
expect(target).to.be.not.undefined;
|
||||
|
||||
// Test target name used for node label
|
||||
|
@ -163,7 +163,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
const codemodel_data = await generateCodeModelForConfiguredDriver();
|
||||
expect(codemodel_data).to.be.not.null;
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'STATIC_LIBRARY');
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'STATIC_LIBRARY');
|
||||
expect(target).to.be.not.undefined;
|
||||
|
||||
// Test target name used for node label
|
||||
|
@ -196,7 +196,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
const codemodel_data = await generateCodeModelForConfiguredDriver();
|
||||
expect(codemodel_data).to.be.not.null;
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'SHARED_LIBRARY');
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'SHARED_LIBRARY');
|
||||
expect(target).to.be.not.undefined;
|
||||
|
||||
// Test target name used for node label
|
||||
|
@ -232,8 +232,8 @@ export function makeCodeModelDriverTestsuite(
|
|||
const codemodel_data = await generateCodeModelForConfiguredDriver();
|
||||
expect(codemodel_data).to.be.not.null;
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'UTILITY'
|
||||
&& t.name == 'runTestTarget');
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'UTILITY'
|
||||
&& t.name === 'runTestTarget');
|
||||
expect(target).to.be.not.undefined;
|
||||
|
||||
// maybe could be used to exclude file list from utility targets
|
||||
|
@ -250,7 +250,7 @@ export function makeCodeModelDriverTestsuite(
|
|||
const codemodel_data = await generateCodeModelForConfiguredDriver(['-DCMAKE_SYSROOT=/tmp']);
|
||||
expect(codemodel_data).to.be.not.null;
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'EXECUTABLE');
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'EXECUTABLE');
|
||||
expect(target).to.be.not.undefined;
|
||||
expect(target!.sysroot).to.be.eq('/tmp');
|
||||
}).timeout(90000);
|
||||
|
@ -264,8 +264,8 @@ export function makeCodeModelDriverTestsuite(
|
|||
['subdir_target', 'subdir', '../../main.cpp']] as
|
||||
const) {
|
||||
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type == 'EXECUTABLE'
|
||||
&& t.name == target_name);
|
||||
const target = codemodel_data!.configurations[0].projects[0].targets.find(t => t.type === 'EXECUTABLE'
|
||||
&& t.name === target_name);
|
||||
expect(target).to.be.not.undefined;
|
||||
|
||||
// Assert correct target names for node labels
|
||||
|
|
|
@ -131,11 +131,11 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
expect(await driver.build(driver.allTargetName)).to.be.eq(0);
|
||||
|
||||
expect(driver.executableTargets.length).to.be.eq(2);
|
||||
const targetInTopLevelBuildDir = driver.executableTargets.find(t => t.name == 'TestBuildProcess');
|
||||
const targetInTopLevelBuildDir = driver.executableTargets.find(t => t.name === 'TestBuildProcess');
|
||||
expect(targetInTopLevelBuildDir).to.not.undefined;
|
||||
expect(fs.existsSync(targetInTopLevelBuildDir!.path)).to.be.true;
|
||||
|
||||
const targetInRuntimeOutputDir = driver.executableTargets.find(t => t.name == 'TestBuildProcessOtherOutputDir');
|
||||
const targetInRuntimeOutputDir = driver.executableTargets.find(t => t.name === 'TestBuildProcessOtherOutputDir');
|
||||
expect(targetInRuntimeOutputDir).to.not.undefined;
|
||||
expect(fs.existsSync(targetInRuntimeOutputDir!.path)).to.be.true;
|
||||
}).timeout(90000);
|
||||
|
@ -255,7 +255,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
let called = false;
|
||||
const checkPreconditionHelper = async (e: CMakePreconditionProblems) => {
|
||||
if (e == CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
if (e === CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
@ -276,7 +276,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
let called = false;
|
||||
const checkPreconditionHelper = async (e: CMakePreconditionProblems) => {
|
||||
if (e == CMakePreconditionProblems.ConfigureIsAlreadyRunning) {
|
||||
if (e === CMakePreconditionProblems.ConfigureIsAlreadyRunning) {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
@ -297,7 +297,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
let called = false;
|
||||
const checkPreconditionHelper = async (e: CMakePreconditionProblems) => {
|
||||
if (e == CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
if (e === CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
@ -318,7 +318,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
let called = false;
|
||||
const checkPreconditionHelper = async (e: CMakePreconditionProblems) => {
|
||||
if (e == CMakePreconditionProblems.ConfigureIsAlreadyRunning) {
|
||||
if (e === CMakePreconditionProblems.ConfigureIsAlreadyRunning) {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
@ -339,7 +339,7 @@ export function makeDriverTestsuite(driver_generator: (cmake: CMakeExecutable,
|
|||
|
||||
let called = false;
|
||||
const checkPreconditionHelper = async (e: CMakePreconditionProblems) => {
|
||||
if (e == CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
if (e === CMakePreconditionProblems.BuildIsAlreadyRunning) {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ function getTestRootFilePath(filename: string): string {
|
|||
}
|
||||
|
||||
function getPathWithoutCompilers() {
|
||||
if (process.arch == 'win32') {
|
||||
if (process.arch === 'win32') {
|
||||
return 'C:\\TMP';
|
||||
} else {
|
||||
return '/tmp';
|
||||
|
|
|
@ -47,11 +47,11 @@ suite('Kits test', async () => {
|
|||
});
|
||||
|
||||
test('Test load env vars from shell script', async() => {
|
||||
const fname_extension = process.platform == 'win32' ? 'bat' : 'sh';
|
||||
const fname_extension = process.platform === 'win32' ? 'bat' : 'sh';
|
||||
const fname = `cmake-kit-test-${Math.random().toString()}.${fname_extension}`;
|
||||
const script_path = path.join(paths.tmpDir, fname);
|
||||
// generate a file with test batch / shell script that sets two env vars
|
||||
if (process.platform == 'win32') {
|
||||
if (process.platform === 'win32') {
|
||||
await fs.writeFile(script_path, `set "TESTVAR12=abc"\r\nset "TESTVAR13=cde"`);
|
||||
} else {
|
||||
await fs.writeFile(script_path, `export "TESTVAR12=abc"\nexport "TESTVAR13=cde"`);
|
||||
|
|
1873
yarn.lock
1873
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче