Refactor and improve test infrastructure, starting with automated version validation tests (#4126)
* renamed to end-to-end-tests and moved backend unit tests to unit-tests folder * create folder for kits code, refactor imports to use @cmt and @test * move variants into the kits folder * refactor into better folder structure, still more to go * Initial refactor making presets validation unit testing possible. This seems to work well so far, I have v1-v3 presets tested, with some more refactors regarding error reporting to come. However, the design/infrastructure refactor seems to be allowing us to unit test validation. * implemented Presets version validation automated testing * Added version testing for presets v1-9. This adds testing for our version validation for all Presets versions currently supported. It creates presets on the fly and ensures that we correctly get errors, or don't, depending on the setup and what fields are present with what versions. * fix workflows * Ensure that we correctly initialize the presetsParser class * refactor imports * refactor imports * more import fixes * imports in projectStatus * missed one * workflow imports * added comment about definite assignment * add comments * fix launch file to make sure breakpoints happen * fix syntax error
This commit is contained in:
Родитель
bab2895173
Коммит
46f2d16e31
|
@ -1,3 +1,3 @@
|
|||
*.js
|
||||
test/extension-tests/successful-build/project-folder/build
|
||||
test/end-to-end-tests/successful-build/project-folder/build
|
||||
tools/prepublish.js
|
||||
|
|
|
@ -59,17 +59,17 @@ jobs:
|
|||
- name: Run successful-build test
|
||||
uses: GabrielBB/xvfb-action@v1.6
|
||||
with:
|
||||
run: yarn extensionTestsSuccessfulBuild
|
||||
run: yarn endToEndTestsSuccessfulBuild
|
||||
|
||||
- name: Run single root test
|
||||
uses: GabrielBB/xvfb-action@v1.6
|
||||
with:
|
||||
run: yarn extensionTestsSingleRoot
|
||||
run: yarn endToEndTestsSingleRoot
|
||||
|
||||
- name: Run multi root test
|
||||
uses: GabrielBB/xvfb-action@v1.6
|
||||
with:
|
||||
run: yarn extensionTestsMultiRoot
|
||||
run: yarn endToEndTestsMultiRoot
|
||||
|
||||
- name: Upload test logs if tests failed
|
||||
if: failure()
|
||||
|
|
|
@ -46,7 +46,7 @@ jobs:
|
|||
|
||||
|
||||
- name: Run successful-build test
|
||||
run: yarn extensionTestsSuccessfulBuild
|
||||
run: yarn endToEndTestsSuccessfulBuild
|
||||
|
||||
- name: Run backend tests
|
||||
run: yarn backendTests
|
||||
|
@ -58,10 +58,10 @@ jobs:
|
|||
run: yarn unitTests
|
||||
|
||||
- name: Run single root test
|
||||
run: yarn extensionTestsSingleRoot
|
||||
run: yarn endToEndTestsSingleRoot
|
||||
|
||||
- name: Run multi root test
|
||||
run: yarn extensionTestsMultiRoot
|
||||
run: yarn endToEndTestsMultiRoot
|
||||
|
||||
- name: Upload test logs if tests failed
|
||||
if: failure()
|
||||
|
|
|
@ -55,13 +55,13 @@ jobs:
|
|||
run: yarn unitTests
|
||||
|
||||
- name: Run successful-build test
|
||||
run: yarn extensionTestsSuccessfulBuild
|
||||
run: yarn endToEndTestsSuccessfulBuild
|
||||
|
||||
- name: Run single root test
|
||||
run: yarn extensionTestsSingleRoot
|
||||
run: yarn endToEndTestsSingleRoot
|
||||
|
||||
- name: Run multi root test
|
||||
run: yarn extensionTestsMultiRoot
|
||||
run: yarn endToEndTestsMultiRoot
|
||||
|
||||
- name: Upload test logs if tests failed
|
||||
if: failure()
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/*",
|
||||
"${workspaceFolder}/out/src/*",
|
||||
"${workspaceFolder}/out/src/**",
|
||||
"${workspaceFolder}/out/test/*",
|
||||
"${workspaceFolder}/out/test/unit-tests/*"
|
||||
"${workspaceFolder}/out/test/unit-tests/**",
|
||||
],
|
||||
"env": {
|
||||
"CMT_TESTING": "1",
|
||||
|
@ -50,17 +50,17 @@
|
|||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceFolder}/test/extension-tests/successful-build/project-folder",
|
||||
"${workspaceFolder}/test/end-to-end-tests/successful-build/project-folder",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/successful-build/index"
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/end-to-end-tests/successful-build/index"
|
||||
],
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/*",
|
||||
"${workspaceFolder}/out/src/*",
|
||||
"${workspaceFolder}/out/src/**",
|
||||
"${workspaceFolder}/out/test/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/successful-build/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/successful-build/test/*"
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/successful-build/*",
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/successful-build/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"env": {
|
||||
|
@ -75,17 +75,17 @@
|
|||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceFolder}/test/extension-tests/single-root-UI/project-folder",
|
||||
"${workspaceFolder}/test/end-to-end-tests/single-root-UI/project-folder",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/single-root-UI/index"
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/end-to-end-tests/single-root-UI/index"
|
||||
],
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/*",
|
||||
"${workspaceFolder}/out/src/*",
|
||||
"${workspaceFolder}/out/src/**",
|
||||
"${workspaceFolder}/out/test/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/single-root-UI/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/single-root-UI/test/*"
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/single-root-UI/*",
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/single-root-UI/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"env": {
|
||||
|
@ -100,17 +100,17 @@
|
|||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"${workspaceFolder}/test/extension-tests/multi-root-UI/project-workspace.code-workspace",
|
||||
"${workspaceFolder}/test/end-to-end-tests/multi-root-UI/project-workspace.code-workspace",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/extension-tests/multi-root-UI/index"
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test/end-to-end-tests/multi-root-UI/index"
|
||||
],
|
||||
"sourceMaps": true,
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/*",
|
||||
"${workspaceFolder}/out/src/*",
|
||||
"${workspaceFolder}/out/src/**",
|
||||
"${workspaceFolder}/out/test/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/multi-root-UI/*",
|
||||
"${workspaceFolder}/out/test/extension-tests/multi-root-UI/test/*"
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/multi-root-UI/*",
|
||||
"${workspaceFolder}/out/test/end-to-end-tests/multi-root-UI/test/*"
|
||||
],
|
||||
"preLaunchTask": "Pretest",
|
||||
"env": {
|
||||
|
@ -122,7 +122,7 @@
|
|||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Run Backend tests",
|
||||
"name": "Run Backend Unit tests",
|
||||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||
"args": [
|
||||
"-u",
|
||||
|
@ -134,7 +134,7 @@
|
|||
"ts-node/register",
|
||||
"-r",
|
||||
"tsconfig-paths/register",
|
||||
"${workspaceFolder}/test/backend-unit-tests/**/*.test.ts"
|
||||
"${workspaceFolder}/test/unit-tests/backend/**/*.test.ts"
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"env": {
|
||||
|
|
|
@ -3701,10 +3701,10 @@
|
|||
"lint": "gulp lint",
|
||||
"smokeTests": "yarn run pretest && node ./out/test/smoke/badProject/runTest.js && node ./out/test/smoke/goodProject/runTest.js && node ./out/test/smoke/noCtest/runTest.js",
|
||||
"unitTests": "yarn run pretest && node ./out/test/unit-tests/runTest.js",
|
||||
"extensionTestsSuccessfulBuild": "yarn run pretest && node ./out/test/extension-tests/successful-build/runTest.js",
|
||||
"extensionTestsSingleRoot": "yarn run pretest && node ./out/test/extension-tests/single-root-UI/runTest.js",
|
||||
"extensionTestsMultiRoot": "yarn run pretest && node ./out/test/extension-tests/multi-root-UI/runTest.js",
|
||||
"backendTests": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors -r ts-node/register -r tsconfig-paths/register ./test/backend-unit-tests/**/*.test.ts",
|
||||
"endToEndTestsSuccessfulBuild": "yarn run pretest && node ./out/test/end-to-end-tests/successful-build/runTest.js",
|
||||
"endToEndTestsSingleRoot": "yarn run pretest && node ./out/test/end-to-end-tests/single-root-UI/runTest.js",
|
||||
"endToEndTestsMultiRoot": "yarn run pretest && node ./out/test/end-to-end-tests/multi-root-UI/runTest.js",
|
||||
"backendTests": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors -r ts-node/register -r tsconfig-paths/register ./test/unit-tests/backend/**/*.test.ts",
|
||||
"build-product-icon-font": "yarn --cwd ./tools/product-icon-font-generator/ install && yarn --cwd ./tools/product-icon-font-generator/ build && node ./tools/product-icon-font-generator/dist/index.js --source-directory ./res/product-icons/ --output-directory ./res/ --woff2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
* Module for reading from the CMake cache
|
||||
*/ /** */
|
||||
|
||||
import * as logging from './logging';
|
||||
import { fs } from './pr';
|
||||
import rollbar from './rollbar';
|
||||
import * as util from './util';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import * as util from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as proc from '../proc';
|
||||
import * as util from '../util';
|
||||
import {setContextAndStore} from '../extension';
|
||||
import * as proc from '@cmt/proc';
|
||||
import * as util from '@cmt/util';
|
||||
import {setContextAndStore} from '@cmt/extension';
|
||||
import * as logging from '@cmt/logging';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { CMakeCache } from '@cmt/cache';
|
||||
import { CMakeExecutable, getCMakeExecutableInformation } from '@cmt/cmake/cmakeExecutable';
|
||||
import { CMakeExecutable, getCMakeExecutableInformation } from '@cmt/cmakeExecutable';
|
||||
import { CompilationDatabase } from '@cmt/compilationDatabase';
|
||||
import * as debuggerModule from '@cmt/debugger';
|
||||
import * as debuggerModule from '@cmt/debug/debugger';
|
||||
import collections from '@cmt/diagnostics/collections';
|
||||
import * as shlex from '@cmt/shlex';
|
||||
import { Strand } from '@cmt/strand';
|
||||
|
@ -23,34 +23,34 @@ import {
|
|||
ExecutableTarget,
|
||||
NoGeneratorError
|
||||
} from '@cmt/drivers/drivers';
|
||||
import { CTestDriver } from './ctest';
|
||||
import { CPackDriver } from './cpack';
|
||||
import { WorkflowDriver } from './workflow';
|
||||
import { CMakeBuildConsumer } from './diagnostics/build';
|
||||
import { CMakeOutputConsumer } from './diagnostics/cmake';
|
||||
import { FileDiagnostic, populateCollection } from './diagnostics/util';
|
||||
import { expandStrings, expandString, ExpansionOptions } from './expand';
|
||||
import { CMakeGenerator, Kit, SpecialKits } from './kit';
|
||||
import * as logging from './logging';
|
||||
import { fs } from './pr';
|
||||
import { CTestDriver } from '@cmt/ctest';
|
||||
import { CPackDriver } from '@cmt/cpack';
|
||||
import { WorkflowDriver } from '@cmt/workflow';
|
||||
import { CMakeBuildConsumer } from '@cmt/diagnostics/build';
|
||||
import { CMakeOutputConsumer } from '@cmt/diagnostics/cmake';
|
||||
import { FileDiagnostic, populateCollection } from '@cmt/diagnostics/util';
|
||||
import { expandStrings, expandString, ExpansionOptions } from '@cmt/expand';
|
||||
import { CMakeGenerator, Kit, SpecialKits } from '@cmt/kits/kit';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { buildCmdStr, DebuggerEnvironmentVariable, ExecutionResult, ExecutionOptions } from './proc';
|
||||
import { FireLate, Property } from './prop';
|
||||
import rollbar from './rollbar';
|
||||
import * as telemetry from './telemetry';
|
||||
import { VariantManager } from './variant';
|
||||
import { FireLate, Property } from '@cmt/prop';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import { VariantManager } from '@cmt/kits/variant';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { ConfigurationWebview } from './cacheView';
|
||||
import { enableFullFeatureSet, extensionManager, updateFullFeatureSet, setContextAndStore } from './extension';
|
||||
import { CMakeCommunicationMode, ConfigurationReader, OptionConfig, UseCMakePresets, checkConfigureOverridesPresent } from './config';
|
||||
import * as preset from '@cmt/preset';
|
||||
import { ConfigurationWebview } from '@cmt/ui/cacheView';
|
||||
import { enableFullFeatureSet, extensionManager, updateFullFeatureSet, setContextAndStore } from '@cmt/extension';
|
||||
import { CMakeCommunicationMode, ConfigurationReader, OptionConfig, UseCMakePresets, checkConfigureOverridesPresent } from '@cmt/config';
|
||||
import * as preset from '@cmt/presets/preset';
|
||||
import * as util from '@cmt/util';
|
||||
import { Environment, EnvironmentUtils } from './environmentVariables';
|
||||
import { KitsController } from './kitsController';
|
||||
import { PresetsController } from './presetsController';
|
||||
import paths from './paths';
|
||||
import { ProjectController } from './projectController';
|
||||
import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
import { KitsController } from '@cmt/kits/kitsController';
|
||||
import { PresetsController } from '@cmt/presets/presetsController';
|
||||
import paths from '@cmt/paths';
|
||||
import { ProjectController } from '@cmt/projectController';
|
||||
import { MessageItem } from 'vscode';
|
||||
import { DebugTrackerFactory, DebuggerInformation, getDebuggerPipeName } from './debug/debuggerConfigureDriver';
|
||||
import { DebugTrackerFactory, DebuggerInformation, getDebuggerPipeName } from '@cmt/debug/cmakeDebugger/debuggerConfigureDriver';
|
||||
import { ConfigurationType } from 'vscode-cmake-tools';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Environment, EnvironmentUtils } from './environmentVariables';
|
|||
import * as logging from './logging';
|
||||
import { extensionManager, getActiveProject } from './extension';
|
||||
import { CMakeProject, ConfigureTrigger } from './cmakeProject';
|
||||
import * as preset from '@cmt/preset';
|
||||
import * as preset from '@cmt/presets/preset';
|
||||
import { UseCMakePresets } from './config';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import * as util from '@cmt/util';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as shlex from '@cmt/shlex';
|
||||
import { createLogger } from './logging';
|
||||
import { fs } from './pr';
|
||||
import * as util from './util';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as util from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -10,8 +10,8 @@ import * as os from 'os';
|
|||
import * as telemetry from '@cmt/telemetry';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { CppDebugConfiguration } from './debugger';
|
||||
import { Environment } from './environmentVariables';
|
||||
import { CppDebugConfiguration } from '@cmt/debug/debugger';
|
||||
import { Environment } from '@cmt/environmentVariables';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { DirectoryContext } from '@cmt/workspace';
|
||||
import * as vscode from 'vscode';
|
||||
import { CMakeDriver } from '@cmt/drivers/drivers';
|
||||
import { OutputConsumer } from './proc';
|
||||
import { OutputConsumer } from '@cmt/proc';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { PackagePreset } from './preset';
|
||||
import { expandString } from './expand';
|
||||
import { PackagePreset } from '@cmt/presets/preset';
|
||||
import { expandString } from '@cmt/expand';
|
||||
import * as proc from '@cmt/proc';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -14,7 +14,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import * as cpptools from 'vscode-cpptools';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { TargetTypeString } from './drivers/drivers';
|
||||
import { TargetTypeString } from '@cmt/drivers/drivers';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
16
src/ctest.ts
16
src/ctest.ts
|
@ -5,16 +5,16 @@ import * as xml2js from 'xml2js';
|
|||
import * as zlib from 'zlib';
|
||||
|
||||
import { CMakeDriver } from '@cmt/drivers/drivers';
|
||||
import * as logging from './logging';
|
||||
import { fs } from './pr';
|
||||
import { OutputConsumer } from './proc';
|
||||
import * as util from './util';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { OutputConsumer } from '@cmt/proc';
|
||||
import * as util from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { testArgs, TestPreset } from './preset';
|
||||
import { expandString } from './expand';
|
||||
import { testArgs, TestPreset } from '@cmt/presets/preset';
|
||||
import { expandString } from '@cmt/expand';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { ProjectController } from './projectController';
|
||||
import { extensionManager } from './extension';
|
||||
import { ProjectController } from '@cmt/projectController';
|
||||
import { extensionManager } from '@cmt/extension';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { extensionManager } from "@cmt/extension";
|
||||
import * as vscode from "vscode";
|
||||
import { DebuggerInformation, getDebuggerPipeName } from "./debuggerConfigureDriver";
|
||||
import { executeScriptWithDebugger } from "./debuggerScriptDriver";
|
||||
import { DebuggerInformation, getDebuggerPipeName } from "@cmt/debug/cmakeDebugger/debuggerConfigureDriver";
|
||||
import { executeScriptWithDebugger } from "@cmt/debug/cmakeDebugger/debuggerScriptDriver";
|
||||
|
||||
import * as logging from '../logging';
|
||||
import * as logging from '@cmt/logging';
|
||||
import * as nls from "vscode-nls";
|
||||
import { fs } from "../pr";
|
||||
import { DebugOrigin, logCMakeDebuggerTelemetry} from "./cmakeDebuggerTelemetry";
|
||||
import { fs } from "@cmt/pr";
|
||||
import { DebugOrigin, logCMakeDebuggerTelemetry} from "@cmt/debug/cmakeDebugger/cmakeDebuggerTelemetry";
|
||||
import { ConfigureTrigger } from "@cmt/cmakeProject";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
|
@ -1,9 +1,9 @@
|
|||
import { CMakeOutputConsumer, StateMessage } from '@cmt/diagnostics/cmake';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { DebuggerInformation } from './debuggerConfigureDriver';
|
||||
import { getCMakeExecutableInformation } from '@cmt/cmake/cmakeExecutable';
|
||||
import { DebuggerInformation } from '@cmt/debug/cmakeDebugger/debuggerConfigureDriver';
|
||||
import { getCMakeExecutableInformation } from '@cmt/cmakeExecutable';
|
||||
import { extensionManager } from '@cmt/extension';
|
||||
import * as logging from '../logging';
|
||||
import * as logging from '@cmt/logging';
|
||||
import * as nls from "vscode-nls";
|
||||
import { EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { CMakeCache } from '@cmt/cache';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { createLogger } from './logging';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { fs } from './pr';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { ExecutableTarget } from '@cmt/drivers/drivers';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
|
@ -8,13 +8,13 @@ import { OutputConsumer } from '@cmt/proc';
|
|||
import * as util from '@cmt/util';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import * as gcc from './gcc';
|
||||
import * as ghs from './ghs';
|
||||
import * as diab from './diab';
|
||||
import * as gnu_ld from './gnu-ld';
|
||||
import * as mvsc from './msvc';
|
||||
import * as iar from './iar';
|
||||
import { FileDiagnostic, RawDiagnosticParser } from './util';
|
||||
import * as gcc from '@cmt/diagnostics/gcc';
|
||||
import * as ghs from '@cmt/diagnostics/ghs';
|
||||
import * as diab from '@cmt/diagnostics/diab';
|
||||
import * as gnu_ld from '@cmt/diagnostics/gnu-ld';
|
||||
import * as mvsc from '@cmt/diagnostics/msvc';
|
||||
import * as iar from '@cmt/diagnostics/iar';
|
||||
import { FileDiagnostic, RawDiagnosticParser } from '@cmt/diagnostics/util';
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
|
||||
export class Compilers {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { OutputConsumer } from '@cmt/proc';
|
|||
import * as util from '@cmt/util';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { FileDiagnostic, oneLess } from './util';
|
||||
import { FileDiagnostic, oneLess } from '@cmt/diagnostics/util';
|
||||
|
||||
export enum StateMessage {
|
||||
WaitingForDebuggerClient = "Waiting for debugger client to connect...",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from './util';
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from '@cmt/diagnostics/util';
|
||||
|
||||
export const REGEX = /^\"(.*)\",\s+(?:line\s+(\d+):\s+)?(info|warning|(?:|fatal |catastrophic )error)\s+\((.*)\):\s+(.*)$/;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { oneLess, RawDiagnostic, RawDiagnosticParser, RawRelated, FeedLineResult } from './util';
|
||||
import { oneLess, RawDiagnostic, RawDiagnosticParser, RawRelated, FeedLineResult } from '@cmt/diagnostics/util';
|
||||
|
||||
export const REGEX = /^(.*):(\d+):(\d+):\s+(?:fatal )?(\w*)(?:\sfatale)?\s?:\s+(.*)/;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from './util';
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from '@cmt/diagnostics/util';
|
||||
|
||||
export const REGEX = /^\"(.*)\",\s+(?:(?:line\s+(\d+)\s+\(col\.\s+(\d+)\))|(?:At end of source)):\s+(?:fatal )?(remark|warning|error)\s+(.*)/;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { FeedLineResult, oneLess, RawDiagnosticParser } from './util';
|
||||
import { FeedLineResult, oneLess, RawDiagnosticParser } from '@cmt/diagnostics/util';
|
||||
|
||||
export const REGEX = /^(.*):(\d+)\s?:\s+(.*[^\]])$/;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult, RawDiagnostic } from './util';
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult, RawDiagnostic } from '@cmt/diagnostics/util';
|
||||
|
||||
const CODE_REGEX = /^\"(?<file>.*)\",(?<line>\d+)\s+(?<severity>[A-Za-z ]+)\[(?<code>[A-Za-z]+[0-9]+)\]:(?<message_start>.*)$/;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from './util';
|
||||
import { oneLess, RawDiagnosticParser, FeedLineResult } from '@cmt/diagnostics/util';
|
||||
|
||||
export const REGEX = /^\s*(\d+>)?\s*([^\s>].*)\((\d+|\d+,\d+|\d+,\d+,\d+,\d+)\)\s*:\s+((?:fatal )?error|warning|info)\s*(\w{1,2}\d+)?\s*:\s*(.*)$/;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import * as lodash from "lodash";
|
||||
|
||||
import { CMakeExecutable } from '@cmt/cmake/cmakeExecutable';
|
||||
import { CMakeExecutable } from '@cmt/cmakeExecutable';
|
||||
import * as codepages from '@cmt/codePageTable';
|
||||
import { ConfigureCancelInformation, ConfigureTrigger, DiagnosticsConfiguration } from "@cmt/cmakeProject";
|
||||
import { CompileCommand } from '@cmt/compilationDatabase';
|
||||
|
@ -16,7 +16,7 @@ import { CMakeOutputConsumer } from '@cmt/diagnostics/cmake';
|
|||
import { RawDiagnosticParser } from '@cmt/diagnostics/util';
|
||||
import { ProgressMessage } from '@cmt/drivers/drivers';
|
||||
import * as expand from '@cmt/expand';
|
||||
import { CMakeGenerator, effectiveKitEnvironment, Kit, kitChangeNeedsClean, KitDetect, getKitDetect, getVSKitEnvironment } from '@cmt/kit';
|
||||
import { CMakeGenerator, effectiveKitEnvironment, Kit, kitChangeNeedsClean, KitDetect, getKitDetect, getVSKitEnvironment } from '@cmt/kits/kit';
|
||||
import * as logging from '@cmt/logging';
|
||||
import paths from '@cmt/paths';
|
||||
import { fs } from '@cmt/pr';
|
||||
|
@ -24,17 +24,17 @@ import * as proc from '@cmt/proc';
|
|||
import rollbar from '@cmt/rollbar';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import * as util from '@cmt/util';
|
||||
import { ConfigureArguments, VariantOption } from '@cmt/variant';
|
||||
import { ConfigureArguments, VariantOption } from '@cmt/kits/variant';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { majorVersionSemver, minorVersionSemver, parseTargetTriple, TargetTriple } from '@cmt/triple';
|
||||
import * as preset from '@cmt/preset';
|
||||
import * as preset from '@cmt/presets/preset';
|
||||
import * as codeModel from '@cmt/drivers/codeModel';
|
||||
import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
import { CMakeTask, CMakeTaskProvider, CustomBuildTaskTerminal } from '@cmt/cmakeTaskProvider';
|
||||
import { getValue } from '@cmt/preset';
|
||||
import { getValue } from '@cmt/presets/preset';
|
||||
import { CacheEntry } from '@cmt/cache';
|
||||
import { CMakeBuildRunner } from '@cmt/cmakeBuildRunner';
|
||||
import { DebuggerInformation } from '@cmt/debug/debuggerConfigureDriver';
|
||||
import { DebuggerInformation } from '@cmt/debug/cmakeDebugger/debuggerConfigureDriver';
|
||||
import { onBuildSettingsChange, onTestSettingsChange, onPackageSettingsChange } from '@cmt/ui/util';
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { CMakeCache, CacheEntry } from '@cmt/cache';
|
||||
import { CMakeExecutable } from '@cmt/cmake/cmakeExecutable';
|
||||
import { CMakeExecutable } from '@cmt/cmakeExecutable';
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
import {
|
||||
createQueryFileForApi,
|
||||
|
@ -18,7 +18,7 @@ import {
|
|||
NoGeneratorError
|
||||
} from '@cmt/drivers/drivers';
|
||||
import * as codeModel from '@cmt/drivers/codeModel';
|
||||
import { CMakeGenerator, Kit } from '@cmt/kit';
|
||||
import { CMakeGenerator, Kit } from '@cmt/kits/kit';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as proc from '@cmt/proc';
|
||||
|
@ -26,9 +26,9 @@ import rollbar from '@cmt/rollbar';
|
|||
import * as util from '@cmt/util';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import { BuildPreset, ConfigurePreset, getValue, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/preset';
|
||||
import { BuildPreset, ConfigurePreset, getValue, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/presets/preset';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { DebuggerInformation } from '@cmt/debug/debuggerConfigureDriver';
|
||||
import { DebuggerInformation } from '@cmt/debug/cmakeDebugger/debuggerConfigureDriver';
|
||||
import { CMakeOutputConsumer, StateMessage } from '@cmt/diagnostics/cmake';
|
||||
import { ConfigureTrigger } from '@cmt/cmakeProject';
|
||||
import { onConfigureSettingsChange } from '@cmt/ui/util';
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
* Can also talk to newer versions of CMake via the command line.
|
||||
*/ /** */
|
||||
|
||||
import { CMakeExecutable } from '@cmt/cmake/cmakeExecutable';
|
||||
import { CMakeExecutable } from '@cmt/cmakeExecutable';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { CMakeCache, CacheEntry } from '@cmt/cache';
|
||||
import { CMakeDriver, CMakePreconditionProblemSolver } from '@cmt/drivers/drivers';
|
||||
import { Kit, CMakeGenerator } from '@cmt/kit';
|
||||
import { Kit, CMakeGenerator } from '@cmt/kits/kit';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as proc from '@cmt/proc';
|
||||
|
@ -16,8 +16,8 @@ import rollbar from '@cmt/rollbar';
|
|||
import * as util from '@cmt/util';
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { BuildPreset, ConfigurePreset, getValue, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/preset';
|
||||
import { CodeModelContent } from './codeModel';
|
||||
import { BuildPreset, ConfigurePreset, getValue, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/presets/preset';
|
||||
import { CodeModelContent } from '@cmt/drivers/codeModel';
|
||||
import { ConfigureTrigger } from '@cmt/cmakeProject';
|
||||
import { onConfigureSettingsChange } from '@cmt/ui/util';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as net from 'net';
|
|||
import * as path from 'path';
|
||||
|
||||
import * as cache from '@cmt/cache';
|
||||
import { CMakeGenerator } from '@cmt/kit';
|
||||
import { CMakeGenerator } from '@cmt/kits/kit';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CMakeExecutable } from '@cmt/cmake/cmakeExecutable';
|
||||
import { CMakeExecutable } from '@cmt/cmakeExecutable';
|
||||
import { InputFileSet } from '@cmt/dirty';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
|
@ -16,14 +16,14 @@ import {
|
|||
Target,
|
||||
NoGeneratorError
|
||||
} from '@cmt/drivers/drivers';
|
||||
import { Kit, CMakeGenerator } from '@cmt/kit';
|
||||
import { Kit, CMakeGenerator } from '@cmt/kits/kit';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import * as proc from '@cmt/proc';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
import { errorToString } from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { BuildPreset, ConfigurePreset, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/preset';
|
||||
import { BuildPreset, ConfigurePreset, TestPreset, PackagePreset, WorkflowPreset } from '@cmt/presets/preset';
|
||||
import { CodeModelConfiguration, CodeModelContent, CodeModelFileGroup, CodeModelProject, CodeModelTarget } from '@cmt/drivers/codeModel';
|
||||
import { ConfigureTrigger } from '@cmt/cmakeProject';
|
||||
import { onConfigureSettingsChange } from '@cmt/ui/util';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export * from './cmakeDriver';
|
||||
export * from './cmakeFileApi';
|
||||
export * from './cmakeFileApiDriver';
|
||||
export * from './cmakeLegacyDriver';
|
||||
export * from './cmakeServerClient';
|
||||
export * from './cmakeServerDriver';
|
||||
export * from '@cmt/drivers/cmakeDriver';
|
||||
export * from '@cmt/drivers/cmakeFileApi';
|
||||
export * from '@cmt/drivers/cmakeFileApiDriver';
|
||||
export * from '@cmt/drivers/cmakeLegacyDriver';
|
||||
export * from '@cmt/drivers/cmakeServerClient';
|
||||
export * from '@cmt/drivers/cmakeServerDriver';
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { createLogger } from './logging';
|
||||
import { replaceAll, fixPaths, errorToString } from './util';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import { replaceAll, fixPaths, errorToString } from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { EnvironmentWithNull, EnvironmentUtils } from './environmentVariables';
|
||||
import { EnvironmentWithNull, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
import * as matchAll from 'string.prototype.matchall';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
@ -107,7 +107,7 @@ export interface ExpansionOptions {
|
|||
|
||||
export interface ExpansionErrorHandler {
|
||||
errorList: [string, string][];
|
||||
tempErrorList: [string, string][];
|
||||
tempErrorList: [string, string][]; // This is primarily used to store errors that will then be re-used and modified with additional context to be added into the `errorList`
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,8 +22,8 @@ import {
|
|||
USER_KITS_FILEPATH,
|
||||
findCLCompilerPath,
|
||||
scanForKitsIfNeeded
|
||||
} from '@cmt/kit';
|
||||
import { KitsController } from '@cmt/kitsController';
|
||||
} from '@cmt/kits/kit';
|
||||
import { KitsController } from '@cmt/kits/kitsController';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { FireNow, FireLate } from '@cmt/prop';
|
||||
|
@ -31,24 +31,24 @@ import rollbar from '@cmt/rollbar';
|
|||
import { StateManager } from './state';
|
||||
import { cmakeTaskProvider, CMakeTaskProvider } from '@cmt/cmakeTaskProvider';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import { ProjectOutline, ProjectNode, TargetNode, SourceFileNode, WorkspaceFolderNode } from '@cmt/projectOutline/projectOutline';
|
||||
import { ProjectOutline, ProjectNode, TargetNode, SourceFileNode, WorkspaceFolderNode } from '@cmt/ui/projectOutline/projectOutline';
|
||||
import * as util from '@cmt/util';
|
||||
import { ProgressHandle, DummyDisposable, reportProgress, runCommand } from '@cmt/util';
|
||||
import { DEFAULT_VARIANTS } from '@cmt/variant';
|
||||
import { DEFAULT_VARIANTS } from '@cmt/kits/variant';
|
||||
import { expandString, KitContextVars } from '@cmt/expand';
|
||||
import paths from '@cmt/paths';
|
||||
import { CMakeDriver, CMakePreconditionProblems } from './drivers/cmakeDriver';
|
||||
import { platform } from 'os';
|
||||
import { CMakeToolsApiImpl } from './api';
|
||||
import { DirectoryContext } from './workspace';
|
||||
import { ProjectStatus } from './projectStatus';
|
||||
import { PinnedCommands } from './pinnedCommands';
|
||||
import { CMakeToolsApiImpl } from '@cmt/api';
|
||||
import { DirectoryContext } from '@cmt/workspace';
|
||||
import { ProjectStatus } from '@cmt/ui/projectStatus';
|
||||
import { PinnedCommands } from '@cmt/ui/pinnedCommands';
|
||||
import { StatusBar } from '@cmt/status';
|
||||
import { DebugAdapterNamedPipeServerDescriptorFactory } from './debug/debugAdapterNamedPipeServerDescriptorFactory';
|
||||
import { getCMakeExecutableInformation } from './cmake/cmakeExecutable';
|
||||
import { DebuggerInformation, getDebuggerPipeName } from './debug/debuggerConfigureDriver';
|
||||
import { DebugConfigurationProvider, DynamicDebugConfigurationProvider } from './debug/debugConfigurationProvider';
|
||||
import { deIntegrateTestExplorer } from './ctest';
|
||||
import { DebugAdapterNamedPipeServerDescriptorFactory } from '@cmt/debug/cmakeDebugger/debugAdapterNamedPipeServerDescriptorFactory';
|
||||
import { getCMakeExecutableInformation } from '@cmt/cmakeExecutable';
|
||||
import { DebuggerInformation, getDebuggerPipeName } from '@cmt/debug/cmakeDebugger/debuggerConfigureDriver';
|
||||
import { DebugConfigurationProvider, DynamicDebugConfigurationProvider } from '@cmt/debug/cmakeDebugger/debugConfigurationProvider';
|
||||
import { deIntegrateTestExplorer } from "@cmt/ctest";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -10,9 +10,9 @@ import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
|||
import * as iconv from 'iconv-lite';
|
||||
import * as codepages from '@cmt/codePageTable';
|
||||
|
||||
import * as logging from '../logging';
|
||||
import * as proc from '../proc';
|
||||
import { thisExtensionPath } from '../util';
|
||||
import * as logging from '@cmt/logging';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { thisExtensionPath } from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -8,21 +8,21 @@ import * as util from '@cmt/util';
|
|||
import * as json5 from 'json5';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as kitsController from '@cmt/kitsController';
|
||||
import * as kitsController from '@cmt/kits/kitsController';
|
||||
|
||||
import CMakeProject from './cmakeProject';
|
||||
import * as expand from './expand';
|
||||
import { VSInstallation, vsInstallations, getHostTargetArchString, varsForVSInstallation, generatorPlatformFromVSArch } from './installs/visualStudio';
|
||||
import * as logging from './logging';
|
||||
import paths, { PathWithTrust } from './paths';
|
||||
import { fs } from './pr';
|
||||
import * as proc from './proc';
|
||||
import { loadSchema } from './schema';
|
||||
import { TargetTriple, findTargetTriple, parseTargetTriple, computeTargetTriple } from './triple';
|
||||
import { compare, dropNulls, Ordering, versionLess } from './util';
|
||||
import CMakeProject from '@cmt/cmakeProject';
|
||||
import * as expand from '@cmt/expand';
|
||||
import { VSInstallation, vsInstallations, getHostTargetArchString, varsForVSInstallation, generatorPlatformFromVSArch } from '@cmt/installs/visualStudio';
|
||||
import * as logging from '@cmt/logging';
|
||||
import paths, { PathWithTrust } from '@cmt/paths';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { loadSchema } from "@cmt/schema";
|
||||
import { TargetTriple, findTargetTriple, parseTargetTriple, computeTargetTriple } from '@cmt/triple';
|
||||
import { compare, dropNulls, Ordering, versionLess } from "@cmt/util";
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Environment, EnvironmentUtils } from './environmentVariables';
|
||||
import { getCMakeExecutableInformation } from './cmake/cmakeExecutable';
|
||||
import { Environment, EnvironmentUtils } from "@cmt/environmentVariables";
|
||||
import { getCMakeExecutableInformation } from "@cmt/cmakeExecutable";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|
@ -17,7 +17,7 @@ import {
|
|||
SpecialKits,
|
||||
SpecialKitsCount,
|
||||
getAdditionalKits
|
||||
} from '@cmt/kit';
|
||||
} from '@cmt/kits/kit';
|
||||
import * as logging from '@cmt/logging';
|
||||
import paths from '@cmt/paths';
|
||||
import { fs } from '@cmt/pr';
|
|
@ -7,13 +7,13 @@ import * as telemetry from '@cmt/telemetry';
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
import * as logging from './logging';
|
||||
import { fs } from './pr';
|
||||
import { Environment, EnvironmentUtils } from './environmentVariables';
|
||||
import rollbar from './rollbar';
|
||||
import { loadSchema } from './schema';
|
||||
import { StateManager } from './state';
|
||||
import * as util from './util';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import { loadSchema } from '@cmt/schema';
|
||||
import { StateManager } from '@cmt/state';
|
||||
import * as util from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
|
@ -7,9 +7,9 @@ import * as path from 'path';
|
|||
import * as which from 'which';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { vsInstallations } from './installs/visualStudio';
|
||||
import { expandString } from './expand';
|
||||
import { fs } from './pr';
|
||||
import { vsInstallations } from '@cmt/installs/visualStudio';
|
||||
import { expandString } from '@cmt/expand';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as util from '@cmt/util';
|
||||
|
||||
interface VSCMakePaths {
|
||||
|
|
|
@ -10,8 +10,8 @@ import { execute } from '@cmt/proc';
|
|||
import { errorHandlerHelper, expandString, ExpansionErrorHandler, ExpansionOptions } from '@cmt/expand';
|
||||
import paths from '@cmt/paths';
|
||||
import { compareVersions, VSInstallation, vsInstallations, enumerateMsvcToolsets, varsForVSInstallation, getVcVarsBatScript } from '@cmt/installs/visualStudio';
|
||||
import { EnvironmentUtils, EnvironmentWithNull } from './environmentVariables';
|
||||
import { defaultNumJobs, UseVsDeveloperEnvironment } from './config';
|
||||
import { EnvironmentUtils, EnvironmentWithNull } from '@cmt/environmentVariables';
|
||||
import { defaultNumJobs, UseVsDeveloperEnvironment } from '@cmt/config';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
@ -1211,7 +1211,7 @@ async function getConfigurePresetInheritsImpl(folder: string, name: string, allo
|
|||
}
|
||||
|
||||
log.error(localize('config.preset.not.found.full', 'Could not find configure preset with name {0}', name));
|
||||
errorHandler?.tempErrorList.push([localize('config.preset.not.found', 'Could not find configure preset'), name]);
|
||||
errorHandler?.errorList.push([localize('config.preset.not.found', 'Could not find configure preset'), name]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1592,7 @@ async function getBuildPresetInheritsImpl(folder: string, name: string, workspac
|
|||
}
|
||||
|
||||
log.error(localize('build.preset.not.found.full', 'Could not find build preset with name {0}', name));
|
||||
errorHandler?.tempErrorList.push([localize('build.preset.not.found', 'Could not find build preset'), name]);
|
||||
errorHandler?.errorList.push([localize('build.preset.not.found', 'Could not find build preset'), name]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1653,7 +1653,7 @@ async function getBuildPresetInheritsHelper(folder: string, preset: BuildPreset,
|
|||
|
||||
if (!expandedConfigurePreset) {
|
||||
log.error(localize('configure.preset.not.found.full', 'Could not find configure preset with name {0}', preset.configurePreset));
|
||||
errorHandler?.tempErrorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
errorHandler?.errorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1770,7 +1770,7 @@ async function getTestPresetInheritsImpl(folder: string, name: string, workspace
|
|||
}
|
||||
|
||||
log.error(localize('test.preset.not.found.full', 'Could not find test preset with name {0}', name));
|
||||
errorHandler?.tempErrorList.push([localize('test.preset.not.found', 'Could not find test preset'), name]);
|
||||
errorHandler?.errorList.push([localize('test.preset.not.found', 'Could not find test preset'), name]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1829,7 +1829,7 @@ async function getTestPresetInheritsHelper(folder: string, preset: TestPreset, w
|
|||
|
||||
if (!expandedConfigurePreset) {
|
||||
log.error(localize('configure.preset.not.found.full', 'Could not find configure preset with name {0}', preset.configurePreset));
|
||||
errorHandler?.tempErrorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
errorHandler?.errorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2043,7 +2043,7 @@ async function getPackagePresetInheritsHelper(folder: string, preset: PackagePre
|
|||
|
||||
if (!expandedConfigurePreset) {
|
||||
log.error(localize('configure.preset.not.found.full', 'Could not find configure preset with name {0}', preset.configurePreset));
|
||||
errorHandler?.tempErrorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
errorHandler?.errorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), preset.configurePreset]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2154,7 +2154,7 @@ async function getWorkflowPresetInheritsImpl(folder: string, name: string, works
|
|||
return getWorkflowPresetInheritsHelper(folder, preset, workspaceFolder, sourceDir, true, usePresetsPlusIncluded, errorHandler);
|
||||
}
|
||||
log.error(localize('workflow.preset.not.found', 'Could not find workflow preset with name {0}', name));
|
||||
errorHandler?.tempErrorList.push([localize('workflow.preset.not.found', 'Could not find workflow preset'), name]);
|
||||
errorHandler?.errorList.push([localize('workflow.preset.not.found', 'Could not find workflow preset'), name]);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2199,7 +2199,7 @@ async function getWorkflowPresetInheritsHelper(folder: string, preset: WorkflowP
|
|||
}
|
||||
if (!expandedConfigurePreset) {
|
||||
log.error(localize('configure.preset.not.found.full', 'Could not find configure preset with name {0}', workflowConfigurePreset));
|
||||
errorHandler?.tempErrorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), workflowConfigurePreset]);
|
||||
errorHandler?.errorList.push([localize('configure.preset.not.found', 'Could not find configure preset'), workflowConfigurePreset]);
|
||||
return null;
|
||||
}
|
||||
// The below is critical when the workflow step0 configure preset is different than the
|
|
@ -2,21 +2,19 @@ import * as chokidar from 'chokidar';
|
|||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as lodash from "lodash";
|
||||
|
||||
import { CMakeProject, ConfigureTrigger, ConfigureType } from '@cmt/cmakeProject';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { fs } from '@cmt/pr';
|
||||
import * as preset from '@cmt/preset';
|
||||
import * as preset from '@cmt/presets/preset';
|
||||
import { PresetsParser } from '@cmt/presets/presetsParser';
|
||||
import * as util from '@cmt/util';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import { expandString, ExpansionErrorHandler, ExpansionOptions, MinimalPresetContextVars } from '@cmt/expand';
|
||||
import { ExpansionErrorHandler, ExpansionOptions } from '@cmt/expand';
|
||||
import paths from '@cmt/paths';
|
||||
import { KitsController } from '@cmt/kitsController';
|
||||
import { descriptionForKit, Kit, SpecialKits } from '@cmt/kit';
|
||||
import { KitsController } from '@cmt/kits/kitsController';
|
||||
import { descriptionForKit, Kit, SpecialKits } from '@cmt/kits/kit';
|
||||
import { getHostTargetArchString } from '@cmt/installs/visualStudio';
|
||||
import { loadSchema } from '@cmt/schema';
|
||||
import json5 = require('json5');
|
||||
import { Diagnostic, DiagnosticSeverity, Position, Range } from 'vscode';
|
||||
import collections from '@cmt/diagnostics/collections';
|
||||
|
||||
|
@ -25,16 +23,12 @@ const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|||
|
||||
const log = logging.createLogger('presetController');
|
||||
|
||||
type SetPresetsFileFunc = (folder: string, presets: preset.PresetsFile | undefined) => void;
|
||||
|
||||
export class PresetsController implements vscode.Disposable {
|
||||
private _presetsWatchers: FileWatcher | undefined;
|
||||
private _sourceDir: string = '';
|
||||
private _sourceDirChangedSub: vscode.Disposable | undefined;
|
||||
private _presetsFileExists = false;
|
||||
private _userPresetsFileExists = false;
|
||||
private _isChangingPresets = false;
|
||||
private _referencedFiles: string[] = [];
|
||||
private _presetsParser!: PresetsParser; // Using definite assigment (!) because we initialize it in the init method
|
||||
|
||||
private readonly _presetsChangedEmitter = new vscode.EventEmitter<preset.PresetsFile | undefined>();
|
||||
private readonly _userPresetsChangedEmitter = new vscode.EventEmitter<preset.PresetsFile | undefined>();
|
||||
|
@ -64,7 +58,12 @@ export class PresetsController implements vscode.Disposable {
|
|||
return util.normalizeAndVerifySourceDir(dir, expansionOpts);
|
||||
};
|
||||
|
||||
presetsController._sourceDir = await expandSourceDir(project.sourceDir);
|
||||
presetsController._presetsParser = new PresetsParser(project.folderPath, await expandSourceDir(project.sourceDir), project.workspaceFolder.uri.fsPath, presetsController.reportPresetsFileErrors, presetsController.showPresetsFileVersionError, (filePath: string) => {
|
||||
collections.presets.set(
|
||||
vscode.Uri.file(filePath),
|
||||
undefined
|
||||
);
|
||||
}, presetsController._presetsChangedEmitter.fire, presetsController._userPresetsChangedEmitter.fire);
|
||||
|
||||
// We explicitly read presets file here, instead of on the initialization of the file watcher. Otherwise
|
||||
// there might be timing issues, since listeners are invoked async.
|
||||
|
@ -101,11 +100,11 @@ export class PresetsController implements vscode.Disposable {
|
|||
private constructor(private readonly project: CMakeProject, private readonly _kitsController: KitsController, private isMultiProject: boolean) {}
|
||||
|
||||
get presetsPath() {
|
||||
return path.join(this._sourceDir, 'CMakePresets.json');
|
||||
return this._presetsParser.presetsPath;
|
||||
}
|
||||
|
||||
get userPresetsPath() {
|
||||
return path.join(this._sourceDir, 'CMakeUserPresets.json');
|
||||
return this._presetsParser.userPresetsPath;
|
||||
}
|
||||
|
||||
get workspaceFolder() {
|
||||
|
@ -121,7 +120,7 @@ export class PresetsController implements vscode.Disposable {
|
|||
}
|
||||
|
||||
get presetsFileExist() {
|
||||
return this._presetsFileExists || this._userPresetsFileExists;
|
||||
return this._presetsParser.presetsFileExists;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,86 +137,17 @@ export class PresetsController implements vscode.Disposable {
|
|||
return this._userPresetsChangedEmitter.event(listener);
|
||||
}
|
||||
|
||||
private readonly _setExpandedPresets = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setExpandedPresets(folder, clone);
|
||||
this._presetsChangedEmitter.fire(clone);
|
||||
};
|
||||
|
||||
private readonly _setExpandedUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setExpandedUserPresetsFile(folder, clone);
|
||||
this._userPresetsChangedEmitter.fire(clone);
|
||||
};
|
||||
|
||||
private readonly _setPresetsPlusIncluded = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setPresetsPlusIncluded(folder, clone);
|
||||
this._presetsChangedEmitter.fire(clone);
|
||||
};
|
||||
|
||||
private readonly _setUserPresetsPlusIncluded = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setUserPresetsPlusIncluded(folder, clone);
|
||||
this._userPresetsChangedEmitter.fire(clone);
|
||||
};
|
||||
|
||||
private readonly _setOriginalPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setOriginalPresetsFile(folder, clone);
|
||||
};
|
||||
|
||||
private readonly _setOriginalUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setOriginalUserPresetsFile(folder, clone);
|
||||
};
|
||||
|
||||
private async resetPresetsFile(file: string, setExpandedPresets: SetPresetsFileFunc, setPresetsPlusIncluded: SetPresetsFileFunc, setOriginalPresetsFile: SetPresetsFileFunc, fileExistCallback: (fileExists: boolean) => void, referencedFiles: Map<string, preset.PresetsFile | undefined>) {
|
||||
const presetsFileBuffer = await this.readPresetsFile(file);
|
||||
|
||||
// There might be a better location for this, but for now this is the best one...
|
||||
fileExistCallback(Boolean(presetsFileBuffer));
|
||||
|
||||
// Record the file as referenced, even if the file does not exist.
|
||||
let presetsFile = await this.parsePresetsFile(presetsFileBuffer, file);
|
||||
referencedFiles.set(file, presetsFile);
|
||||
if (presetsFile) {
|
||||
setOriginalPresetsFile(this.folderPath, presetsFile);
|
||||
} else {
|
||||
setOriginalPresetsFile(this.folderPath, undefined);
|
||||
}
|
||||
|
||||
const expansionErrors: ExpansionErrorHandler = { errorList: [], tempErrorList: []};
|
||||
|
||||
presetsFile = await this.validatePresetsFile(presetsFile, file);
|
||||
if (presetsFile) {
|
||||
// Private fields must be set after validation, otherwise validation would fail.
|
||||
this.populatePrivatePresetsFields(presetsFile, file);
|
||||
await this.mergeIncludeFiles(presetsFile, file, referencedFiles, expansionErrors);
|
||||
|
||||
if (expansionErrors.errorList.length > 0 || expansionErrors.tempErrorList.length > 0) {
|
||||
presetsFile = undefined;
|
||||
} else {
|
||||
// add the include files to the original presets file
|
||||
setPresetsPlusIncluded(this.folderPath, presetsFile);
|
||||
|
||||
// set the pre-expanded version so we can call expandPresetsFile on it
|
||||
setExpandedPresets(this.folderPath, presetsFile);
|
||||
presetsFile = await this.expandPresetsFile(presetsFile, expansionErrors);
|
||||
}
|
||||
}
|
||||
|
||||
setExpandedPresets(this.folderPath, presetsFile);
|
||||
}
|
||||
|
||||
// Need to reapply presets every time presets changed since the binary dir or cmake path could change
|
||||
// (need to clean or reload driver)
|
||||
async reapplyPresets() {
|
||||
const referencedFiles: Map<string, preset.PresetsFile | undefined> = new Map();
|
||||
|
||||
// Reset all changes due to expansion since parents could change
|
||||
await this.resetPresetsFile(this.presetsPath, this._setExpandedPresets, this._setPresetsPlusIncluded, this._setOriginalPresetsFile, exists => this._presetsFileExists = exists, referencedFiles);
|
||||
await this.resetPresetsFile(this.userPresetsPath, this._setExpandedUserPresetsFile, this._setUserPresetsPlusIncluded, this._setOriginalUserPresetsFile, exists => this._userPresetsFileExists = exists, referencedFiles);
|
||||
await this._presetsParser.resetPresetsFiles(
|
||||
referencedFiles,
|
||||
this.project.workspaceContext.config.allowCommentsInPresetsFile,
|
||||
this.project.workspaceContext.config.allowUnsupportedPresetsVersions
|
||||
);
|
||||
|
||||
// reset all expanded presets storage.
|
||||
this._referencedFiles = Array.from(referencedFiles.keys());
|
||||
|
@ -1564,335 +1494,6 @@ export class PresetsController implements vscode.Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
private async readPresetsFile(file: string): Promise<Buffer | undefined> {
|
||||
if (!await fs.exists(file)) {
|
||||
return undefined;
|
||||
}
|
||||
log.debug(localize('reading.presets.file', 'Reading presets file {0}', file));
|
||||
return fs.readFile(file);
|
||||
}
|
||||
|
||||
private async parsePresetsFile(fileContent: Buffer | undefined, file: string): Promise<preset.PresetsFile | undefined> {
|
||||
if (!fileContent) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let presetsFile: preset.PresetsFile;
|
||||
try {
|
||||
if (this.project.workspaceContext.config.allowCommentsInPresetsFile) {
|
||||
presetsFile = json5.parse(fileContent.toLocaleString());
|
||||
} else {
|
||||
presetsFile = JSON.parse(fileContent.toLocaleString());
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(localize('failed.to.parse', 'Failed to parse {0}: {1}', path.basename(file), util.errorToString(e)));
|
||||
return undefined;
|
||||
}
|
||||
return presetsFile;
|
||||
}
|
||||
|
||||
private populatePrivatePresetsFields(presetsFile: preset.PresetsFile | undefined, file: string) {
|
||||
if (!presetsFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
presetsFile.__path = file;
|
||||
const setFile = (presets?: preset.Preset[]) => {
|
||||
if (presets) {
|
||||
for (const preset of presets) {
|
||||
preset.__file = presetsFile;
|
||||
}
|
||||
}
|
||||
};
|
||||
setFile(presetsFile.configurePresets);
|
||||
setFile(presetsFile.buildPresets);
|
||||
setFile(presetsFile.testPresets);
|
||||
setFile(presetsFile.workflowPresets);
|
||||
setFile(presetsFile.packagePresets);
|
||||
}
|
||||
|
||||
private async getExpandedInclude(presetsFile: preset.PresetsFile, include: string, file: string, hostSystemName: string, expansionErrors: ExpansionErrorHandler): Promise<string> {
|
||||
return presetsFile.version >= 9
|
||||
? expandString(include, {
|
||||
vars: {
|
||||
sourceDir: this.folderPath,
|
||||
sourceParentDir: path.dirname(this.folderPath),
|
||||
sourceDirName: path.basename(this.folderPath),
|
||||
hostSystemName: hostSystemName,
|
||||
fileDir: path.dirname(file),
|
||||
pathListSep: path.delimiter
|
||||
},
|
||||
envOverride: {} // $env{} expansions are not supported in `include` v9
|
||||
}, expansionErrors)
|
||||
: presetsFile.version >= 7
|
||||
? // Version 7 and later support $penv{} expansions in include paths
|
||||
expandString(include, {
|
||||
// No vars are supported in Version 7 for include paths.
|
||||
vars: {} as MinimalPresetContextVars,
|
||||
envOverride: {} // $env{} expansions are not supported in `include` v9
|
||||
}, expansionErrors)
|
||||
: include;
|
||||
}
|
||||
|
||||
private async mergeIncludeFiles(presetsFile: preset.PresetsFile | undefined, file: string, referencedFiles: Map<string, preset.PresetsFile | undefined>, expansionErrors: ExpansionErrorHandler): Promise<void> {
|
||||
if (!presetsFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hostSystemName = await util.getHostSystemNameMemo();
|
||||
|
||||
// CMakeUserPresets.json file should include CMakePresets.json file, by default.
|
||||
if (this.presetsFileExist && file === this.userPresetsPath) {
|
||||
presetsFile.include = presetsFile.include || [];
|
||||
const filteredIncludes = [];
|
||||
for (const include of presetsFile.include) {
|
||||
const expandedInclude = await this.getExpandedInclude(presetsFile, include, file, hostSystemName, expansionErrors);
|
||||
if (path.normalize(path.resolve(path.dirname(file), expandedInclude)) === this.presetsPath) {
|
||||
filteredIncludes.push(include);
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredIncludes.length === 0) {
|
||||
presetsFile.include.push(this.presetsPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!presetsFile.include) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Merge the includes in reverse order so that the final presets order is correct
|
||||
for (let i = presetsFile.include.length - 1; i >= 0; i--) {
|
||||
const rawInclude = presetsFile.include[i];
|
||||
const includePath = await this.getExpandedInclude(presetsFile, rawInclude, file, hostSystemName, expansionErrors);
|
||||
const fullIncludePath = path.normalize(path.resolve(path.dirname(file), includePath));
|
||||
|
||||
// Do not include files more than once
|
||||
if (referencedFiles.has(fullIncludePath)) {
|
||||
const referencedIncludeFile = referencedFiles.get(fullIncludePath);
|
||||
if (referencedIncludeFile) {
|
||||
if (referencedIncludeFile.configurePresets) {
|
||||
presetsFile.configurePresets = lodash.unionWith(referencedIncludeFile.configurePresets, presetsFile.configurePresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (referencedIncludeFile.buildPresets) {
|
||||
presetsFile.buildPresets = lodash.unionWith(referencedIncludeFile.buildPresets, presetsFile.buildPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (referencedIncludeFile.testPresets) {
|
||||
presetsFile.testPresets = lodash.unionWith(referencedIncludeFile.testPresets, presetsFile.testPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (referencedIncludeFile.packagePresets) {
|
||||
presetsFile.packagePresets = lodash.unionWith(referencedIncludeFile.packagePresets, presetsFile.packagePresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (referencedIncludeFile.workflowPresets) {
|
||||
presetsFile.workflowPresets = lodash.unionWith(referencedIncludeFile.workflowPresets, presetsFile.workflowPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (referencedIncludeFile.cmakeMinimumRequired) {
|
||||
if (!presetsFile.cmakeMinimumRequired || util.versionLess(presetsFile.cmakeMinimumRequired, referencedIncludeFile.cmakeMinimumRequired)) {
|
||||
presetsFile.cmakeMinimumRequired = referencedIncludeFile.cmakeMinimumRequired;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Record the file as referenced, even if the file does not exist.
|
||||
referencedFiles.set(fullIncludePath, undefined);
|
||||
|
||||
const includeFileBuffer = await this.readPresetsFile(fullIncludePath);
|
||||
if (!includeFileBuffer) {
|
||||
log.error(localize('included.presets.file.not.found', 'Included presets file {0} cannot be found', fullIncludePath));
|
||||
expansionErrors.errorList.push([localize('included.presets.file.not.found', 'Included presets file {0} cannot be found', fullIncludePath), file]);
|
||||
continue;
|
||||
}
|
||||
|
||||
let includeFile = await this.parsePresetsFile(includeFileBuffer, fullIncludePath);
|
||||
referencedFiles.set(fullIncludePath, includeFile);
|
||||
includeFile = await this.validatePresetsFile(includeFile, fullIncludePath);
|
||||
if (!includeFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Private fields must be set after validation, otherwise validation would fail.
|
||||
this.populatePrivatePresetsFields(includeFile, fullIncludePath);
|
||||
|
||||
// Recursively merge included files
|
||||
await this.mergeIncludeFiles(includeFile, fullIncludePath, referencedFiles, expansionErrors);
|
||||
|
||||
if (includeFile.configurePresets) {
|
||||
presetsFile.configurePresets = lodash.unionWith(includeFile.configurePresets, presetsFile.configurePresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (includeFile.buildPresets) {
|
||||
presetsFile.buildPresets = lodash.unionWith(includeFile.buildPresets, presetsFile.buildPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (includeFile.testPresets) {
|
||||
presetsFile.testPresets = lodash.unionWith(includeFile.testPresets, presetsFile.testPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (includeFile.packagePresets) {
|
||||
presetsFile.packagePresets = lodash.unionWith(includeFile.packagePresets, presetsFile.packagePresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (includeFile.workflowPresets) {
|
||||
presetsFile.workflowPresets = lodash.unionWith(includeFile.workflowPresets, presetsFile.workflowPresets || [], (a, b) => a.name === b.name);
|
||||
}
|
||||
if (includeFile.cmakeMinimumRequired) {
|
||||
if (!presetsFile.cmakeMinimumRequired || util.versionLess(presetsFile.cmakeMinimumRequired, includeFile.cmakeMinimumRequired)) {
|
||||
presetsFile.cmakeMinimumRequired = includeFile.cmakeMinimumRequired;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (expansionErrors.errorList.length > 0 || expansionErrors.tempErrorList.length > 0) {
|
||||
expansionErrors.tempErrorList.forEach((error) => expansionErrors.errorList.unshift(error));
|
||||
log.error(localize('expansion.errors', 'Expansion errors found in the presets file.'));
|
||||
await this.reportPresetsFileErrors(presetsFile.__path, expansionErrors);
|
||||
} else {
|
||||
collections.presets.set(vscode.Uri.file(presetsFile.__path || ""), undefined);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expanded presets file if there are no errors, otherwise returns undefined
|
||||
* Does not apply vsdevenv to the presets file
|
||||
*/
|
||||
private async expandPresetsFile(presetsFile: preset.PresetsFile | undefined, expansionErrors: ExpansionErrorHandler): Promise<preset.PresetsFile | undefined> {
|
||||
|
||||
if (!presetsFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
log.info(localize('expanding.presets.file', 'Expanding presets file {0}', presetsFile?.__path || ''));
|
||||
|
||||
const expandedConfigurePresets: preset.ConfigurePreset[] = [];
|
||||
for (const configurePreset of presetsFile?.configurePresets || []) {
|
||||
const inheritedPreset = await preset.getConfigurePresetInherits(
|
||||
this.folderPath,
|
||||
configurePreset.name,
|
||||
true,
|
||||
false,
|
||||
expansionErrors);
|
||||
if (inheritedPreset) {
|
||||
expandedConfigurePresets.push(await preset.expandConfigurePresetVariables(
|
||||
inheritedPreset,
|
||||
this.folderPath,
|
||||
configurePreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
true,
|
||||
false,
|
||||
expansionErrors
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const expandedBuildPresets: preset.BuildPreset[] = [];
|
||||
for (const buildPreset of presetsFile?.buildPresets || []) {
|
||||
const inheritedPreset = await preset.getBuildPresetInherits(
|
||||
this.folderPath,
|
||||
buildPreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
buildPreset.configurePreset,
|
||||
false,
|
||||
expansionErrors);
|
||||
if (inheritedPreset) {
|
||||
expandedBuildPresets.push(await preset.expandBuildPresetVariables(
|
||||
inheritedPreset,
|
||||
buildPreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const expandedTestPresets: preset.TestPreset[] = [];
|
||||
for (const testPreset of presetsFile?.testPresets || []) {
|
||||
const inheritedPreset = await preset.getTestPresetInherits(
|
||||
this.folderPath,
|
||||
testPreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
true,
|
||||
testPreset.configurePreset,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedTestPresets.push(await preset.expandTestPresetVariables(
|
||||
inheritedPreset,
|
||||
testPreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const expandedPackagePresets: preset.PackagePreset[] = [];
|
||||
for (const packagePreset of presetsFile?.packagePresets || []) {
|
||||
const inheritedPreset = await preset.getPackagePresetInherits(
|
||||
this.folderPath,
|
||||
packagePreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
true,
|
||||
packagePreset.configurePreset,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedPackagePresets.push(await preset.expandPackagePresetVariables(
|
||||
inheritedPreset,
|
||||
packagePreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const expandedWorkflowPresets: preset.WorkflowPreset[] = [];
|
||||
for (const workflowPreset of presetsFile?.workflowPresets || []) {
|
||||
const inheritedPreset = await preset.getWorkflowPresetInherits(
|
||||
this.folderPath,
|
||||
workflowPreset.name,
|
||||
this.workspaceFolder.uri.fsPath,
|
||||
this._sourceDir,
|
||||
true, // should this always be true?
|
||||
undefined, // should this always be undefined?
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset && inheritedPreset !== null) {
|
||||
expandedWorkflowPresets.push(inheritedPreset);
|
||||
}
|
||||
}
|
||||
|
||||
if (expansionErrors.errorList.length > 0) {
|
||||
log.error(localize('expansion.errors', 'Expansion errors found in the presets file.'));
|
||||
await this.reportPresetsFileErrors(presetsFile.__path, expansionErrors);
|
||||
return undefined;
|
||||
} else {
|
||||
log.info(localize('successfully.expanded.presets.file', 'Successfully expanded presets file {0}', presetsFile?.__path || ''));
|
||||
|
||||
// cache everything that we just expanded
|
||||
// we'll only need to expand again on set preset - to apply the vs dev env if needed
|
||||
presetsFile.configurePresets = expandedConfigurePresets;
|
||||
presetsFile.buildPresets = expandedBuildPresets;
|
||||
presetsFile.testPresets = expandedTestPresets;
|
||||
presetsFile.packagePresets = expandedPackagePresets;
|
||||
presetsFile.workflowPresets = expandedWorkflowPresets;
|
||||
|
||||
// clear out the errors since there are none now
|
||||
collections.presets.set(vscode.Uri.file(presetsFile.__path || ""), undefined);
|
||||
|
||||
return presetsFile;
|
||||
}
|
||||
}
|
||||
|
||||
private async reportPresetsFileErrors(path: string = "", expansionErrors: ExpansionErrorHandler) {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
for (const error of expansionErrors.errorList) {
|
||||
|
@ -1912,109 +1513,6 @@ export class PresetsController implements vscode.Disposable {
|
|||
collections.presets.set(vscode.Uri.file(path), diagnostics);
|
||||
}
|
||||
|
||||
private async validatePresetsFile(presetsFile: preset.PresetsFile | undefined, file: string) {
|
||||
if (!presetsFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
log.info(localize('validating.presets.file', 'Reading and validating the presets "file {0}"', file));
|
||||
let schemaFile;
|
||||
const maxSupportedVersion = 9;
|
||||
const validationErrorsAreWarnings = presetsFile.version > maxSupportedVersion && this.project.workspaceContext.config.allowUnsupportedPresetsVersions;
|
||||
if (presetsFile.version < 2) {
|
||||
await this.showPresetsFileVersionError(file);
|
||||
return undefined;
|
||||
} else if (presetsFile.version === 2) {
|
||||
schemaFile = './schemas/CMakePresets-schema.json';
|
||||
} else if (presetsFile.version === 3) {
|
||||
schemaFile = './schemas/CMakePresets-v3-schema.json';
|
||||
} else if (presetsFile.version === 4) {
|
||||
schemaFile = './schemas/CMakePresets-v4-schema.json';
|
||||
} else if (presetsFile.version === 5) {
|
||||
schemaFile = './schemas/CMakePresets-v5-schema.json';
|
||||
} else if (presetsFile.version === 6) {
|
||||
schemaFile = './schemas/CMakePresets-v6-schema.json';
|
||||
} else if (presetsFile.version === 7) {
|
||||
schemaFile = './schemas/CMakePresets-v7-schema.json';
|
||||
} else {
|
||||
// This can be used for v9 as well, there is no schema difference.
|
||||
schemaFile = "./schemas/CMakePresets-v8-schema.json";
|
||||
}
|
||||
|
||||
const validator = await loadSchema(schemaFile);
|
||||
const is_valid = validator(presetsFile);
|
||||
if (!is_valid) {
|
||||
const showErrors = (logFunc: (x: string) => void) => {
|
||||
const errors = validator.errors!;
|
||||
logFunc(localize('unsupported.presets', 'Unsupported presets detected in {0}. Support is limited to features defined by version {1}.', file, maxSupportedVersion));
|
||||
for (const err of errors) {
|
||||
if (err.params && 'additionalProperty' in err.params) {
|
||||
logFunc(` >> ${err.dataPath}: ${localize('no.additional.properties', 'should NOT have additional properties')}: ${err.params.additionalProperty}`);
|
||||
} else {
|
||||
logFunc(` >> ${err.dataPath}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (validationErrorsAreWarnings) {
|
||||
showErrors(x => log.warning(x));
|
||||
return presetsFile;
|
||||
} else {
|
||||
showErrors(x => log.error(x));
|
||||
log.error(localize('unsupported.presets.disable', 'Unknown properties and macros can be ignored by using the {0} setting.', "'cmake.allowUnsupportedPresetsVersions'"));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.buildPresets || []) {
|
||||
const dupe = presetsFile?.buildPresets?.find(p => (pr.name === p.name && p !== pr));
|
||||
if (dupe) {
|
||||
log.error(localize('duplicate.build.preset.found', 'Found duplicates within the build presets collection: "{0}"', pr.name));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.testPresets || []) {
|
||||
const dupe = presetsFile?.testPresets?.find(p => (pr.name === p.name && p !== pr));
|
||||
if (dupe) {
|
||||
log.error(localize('duplicate.test.preset.found', 'Found duplicates within the test presets collection: "{0}"', pr.name));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.packagePresets || []) {
|
||||
const dupe = presetsFile?.packagePresets?.find(p => (pr.name === p.name && p !== pr));
|
||||
if (dupe) {
|
||||
log.error(localize('duplicate.package.preset.found', 'Found duplicates within the package presets collection: "{0}"', pr.name));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.workflowPresets || []) {
|
||||
const dupe = presetsFile?.workflowPresets?.find(p => (pr.name === p.name && p !== pr));
|
||||
if (dupe) {
|
||||
log.error(localize('duplicate.workflow.preset.found', 'Found duplicates within the workflow presets collection: "{0}"', pr.name));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile.workflowPresets || []) {
|
||||
if (pr.steps.length < 1 || pr.steps[0].type !== "configure") {
|
||||
log.error(localize('workflow.does.not.start.configure.step', 'The workflow preset "{0}" does not start with a configure step.', pr.name));
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (const step of pr.steps) {
|
||||
if (step.type === "configure" && step !== pr.steps[0]) {
|
||||
log.error(localize('workflow.has.subsequent.configure.preset', 'The workflow preset "{0}" has another configure preset "{1}" besides the first step "{2}": ', pr.name, step.name, pr.steps[0].name));
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info(localize('successfully.validated.presets', 'Successfully validated {0} against presets schema', file));
|
||||
return presetsFile;
|
||||
}
|
||||
|
||||
private async showPresetsFileVersionError(file: string): Promise<void> {
|
||||
const useKitsVars = localize('use.kits.variants', 'Use kits and variants');
|
||||
const changePresets = localize('edit.presets', 'Locate');
|
|
@ -0,0 +1,903 @@
|
|||
import * as preset from "@cmt/presets/preset";
|
||||
import json5 = require("json5");
|
||||
import * as nls from "vscode-nls";
|
||||
import * as logging from "@cmt/logging";
|
||||
import * as path from "path";
|
||||
import * as util from "@cmt/util";
|
||||
import { fs } from "@cmt/pr";
|
||||
import * as lodash from "lodash";
|
||||
import { expandString, ExpansionErrorHandler, MinimalPresetContextVars } from "@cmt/expand";
|
||||
import { loadSchema } from "@cmt/schema";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
||||
const log = logging.createLogger("presetController");
|
||||
|
||||
type SetPresetsFileFunc = (folder: string, presets: preset.PresetsFile | undefined) => void;
|
||||
|
||||
/**
|
||||
* This class is designed to be a file that parses and evaluates the presets file (along with the user presets file).
|
||||
* This is designed to be able to take in a folder location or a file location and parse the presets file accordingly.
|
||||
* This class is designed to be used in the PresetController class, and it's designed to be standalone from vscode specific implementation
|
||||
* so that it can be unit tested in isolation.
|
||||
*/
|
||||
export class PresetsParser {
|
||||
private folderPath: string;
|
||||
private _sourceDir: string;
|
||||
private workspaceFolder: string;
|
||||
private presetsFileErrorReporter: (
|
||||
path: string,
|
||||
expansionErrors: ExpansionErrorHandler
|
||||
) => Promise<void>;
|
||||
private showPresetsFileVersionError: (file: string) => Promise<void>;
|
||||
private _presetsFileExists = false;
|
||||
private _userPresetsFileExists = false;
|
||||
private collectionsModifier: (filePath: string) => void;
|
||||
private presetsChangedHandler: (presets: preset.PresetsFile | undefined) => void;
|
||||
private userPresetsChangedHandler: (presets: preset.PresetsFile | undefined) => void;
|
||||
|
||||
/**
|
||||
* Constructs the PresetsParser object
|
||||
* @param folderPath Folder path of the presets file.
|
||||
* @param sourceDir Source directory of the presets file.
|
||||
* @param workspaceFolder Workspace folder of the presets file.
|
||||
* @param presetsFileErrorReporter Callback that reports errors in the presets file.
|
||||
* @param showPresetsFileVersionError Callback that reports errors with unsupported Presets versions.
|
||||
* @param collectionsModifier Callback that modifies the collections (Problems pane) of the presets file.
|
||||
* @param presetsChangedHandler Callback that handles the presets file being changed.
|
||||
* @param userPresetsChangedHandler Callback that handles the user presets file being changed.
|
||||
*/
|
||||
public constructor(
|
||||
folderPath: string,
|
||||
sourceDir: string,
|
||||
workspaceFolder: string,
|
||||
presetsFileErrorReporter: (
|
||||
path: string,
|
||||
expansionErrors: ExpansionErrorHandler
|
||||
) => Promise<void>,
|
||||
showPresetsFileVersionError: (file: string) => Promise<void>,
|
||||
collectionsModifier: (filePath: string) => void,
|
||||
presetsChangedHandler: (presets: preset.PresetsFile | undefined) => void,
|
||||
userPresetsChangedHandler: (presets: preset.PresetsFile | undefined) => void
|
||||
) {
|
||||
this.folderPath = folderPath;
|
||||
this._sourceDir = sourceDir;
|
||||
this.workspaceFolder = workspaceFolder;
|
||||
this.presetsFileErrorReporter = presetsFileErrorReporter;
|
||||
this.showPresetsFileVersionError = showPresetsFileVersionError;
|
||||
this.collectionsModifier = collectionsModifier;
|
||||
this.presetsChangedHandler = presetsChangedHandler;
|
||||
this.userPresetsChangedHandler = userPresetsChangedHandler;
|
||||
}
|
||||
|
||||
set sourceDir(sourceDir: string) {
|
||||
this._sourceDir = sourceDir;
|
||||
}
|
||||
|
||||
get presetsFileExists(): boolean {
|
||||
return this._presetsFileExists || this._userPresetsFileExists;
|
||||
}
|
||||
|
||||
get presetsPath() {
|
||||
return path.join(this._sourceDir, 'CMakePresets.json');
|
||||
}
|
||||
|
||||
get userPresetsPath() {
|
||||
return path.join(this._sourceDir, 'CMakeUserPresets.json');
|
||||
}
|
||||
|
||||
public async resetPresetsFiles(referencedFiles: Map<string, preset.PresetsFile | undefined>, allowCommentsInPresetsFile: boolean, allowUnsupportedPresetsVersions: boolean) {
|
||||
await this.resetPresetsFile(this.presetsPath, this._setExpandedPresets, this._setPresetsPlusIncluded, this._setOriginalPresetsFile, exists => this._presetsFileExists = exists, referencedFiles, allowCommentsInPresetsFile, allowUnsupportedPresetsVersions);
|
||||
await this.resetPresetsFile(this.userPresetsPath, this._setExpandedUserPresetsFile, this._setUserPresetsPlusIncluded, this._setOriginalUserPresetsFile, exists => this._userPresetsFileExists = exists, referencedFiles, allowCommentsInPresetsFile, allowUnsupportedPresetsVersions);
|
||||
}
|
||||
|
||||
private readonly _setExpandedPresets = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setExpandedPresets(folder, clone);
|
||||
this.presetsChangedHandler(clone);
|
||||
};
|
||||
|
||||
private readonly _setExpandedUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setExpandedUserPresetsFile(folder, clone);
|
||||
this.userPresetsChangedHandler(clone);
|
||||
};
|
||||
|
||||
private readonly _setPresetsPlusIncluded = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setPresetsPlusIncluded(folder, clone);
|
||||
this.presetsChangedHandler(clone);
|
||||
};
|
||||
|
||||
private readonly _setUserPresetsPlusIncluded = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setUserPresetsPlusIncluded(folder, clone);
|
||||
this.userPresetsChangedHandler(clone);
|
||||
};
|
||||
|
||||
private readonly _setOriginalPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setOriginalPresetsFile(folder, clone);
|
||||
};
|
||||
|
||||
private readonly _setOriginalUserPresetsFile = (folder: string, presetsFile: preset.PresetsFile | undefined) => {
|
||||
const clone = lodash.cloneDeep(presetsFile);
|
||||
preset.setOriginalUserPresetsFile(folder, clone);
|
||||
};
|
||||
|
||||
private async validatePresetsFile(
|
||||
presetsFile: preset.PresetsFile | undefined,
|
||||
file: string,
|
||||
allowUnsupportedPresetsVersions: boolean,
|
||||
expansionErrors: ExpansionErrorHandler
|
||||
): Promise<preset.PresetsFile | undefined> {
|
||||
if (!presetsFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
log.info(
|
||||
localize(
|
||||
"validating.presets.file",
|
||||
'Reading and validating the presets "file {0}"',
|
||||
file
|
||||
)
|
||||
);
|
||||
let schemaFile;
|
||||
const maxSupportedVersion = 9;
|
||||
const validationErrorsAreWarnings =
|
||||
presetsFile.version > maxSupportedVersion &&
|
||||
allowUnsupportedPresetsVersions;
|
||||
if (presetsFile.version < 2) {
|
||||
await this.showPresetsFileVersionError(file);
|
||||
return undefined;
|
||||
} else if (presetsFile.version === 2) {
|
||||
schemaFile = "./schemas/CMakePresets-schema.json";
|
||||
} else if (presetsFile.version === 3) {
|
||||
schemaFile = "./schemas/CMakePresets-v3-schema.json";
|
||||
} else if (presetsFile.version === 4) {
|
||||
schemaFile = "./schemas/CMakePresets-v4-schema.json";
|
||||
} else if (presetsFile.version === 5) {
|
||||
schemaFile = "./schemas/CMakePresets-v5-schema.json";
|
||||
} else if (presetsFile.version === 6) {
|
||||
schemaFile = "./schemas/CMakePresets-v6-schema.json";
|
||||
} else if (presetsFile.version === 7) {
|
||||
schemaFile = "./schemas/CMakePresets-v7-schema.json";
|
||||
} else {
|
||||
// This can be used for v9 as well, there is no schema difference.
|
||||
schemaFile = "./schemas/CMakePresets-v8-schema.json";
|
||||
}
|
||||
|
||||
const validator = await loadSchema(schemaFile);
|
||||
const is_valid = validator(presetsFile);
|
||||
if (!is_valid) {
|
||||
const showErrors = (logFunc: (x: string) => void) => {
|
||||
const errors = validator.errors!;
|
||||
logFunc(
|
||||
localize(
|
||||
"unsupported.presets",
|
||||
"Unsupported presets detected in {0}. Support is limited to features defined by version {1}.",
|
||||
file,
|
||||
maxSupportedVersion
|
||||
)
|
||||
);
|
||||
for (const err of errors) {
|
||||
if (err.params && "additionalProperty" in err.params) {
|
||||
logFunc(
|
||||
` >> ${err.dataPath}: ${localize(
|
||||
"no.additional.properties",
|
||||
"should NOT have additional properties"
|
||||
)}: ${err.params.additionalProperty}`
|
||||
);
|
||||
} else {
|
||||
logFunc(` >> ${err.dataPath}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (validationErrorsAreWarnings) {
|
||||
showErrors((x) => log.warning(x));
|
||||
return presetsFile;
|
||||
} else {
|
||||
showErrors((x) => {
|
||||
log.error(x);
|
||||
expansionErrors.errorList.push([x, file]);
|
||||
});
|
||||
log.error(
|
||||
localize(
|
||||
"unsupported.presets.disable",
|
||||
"Unknown properties and macros can be ignored by using the {0} setting.",
|
||||
"'cmake.allowUnsupportedPresetsVersions'"
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.buildPresets || []) {
|
||||
const dupe = presetsFile?.buildPresets?.find(
|
||||
(p) => pr.name === p.name && p !== pr
|
||||
);
|
||||
if (dupe) {
|
||||
log.error(
|
||||
localize(
|
||||
"duplicate.build.preset.found",
|
||||
'Found duplicates within the build presets collection: "{0}"',
|
||||
pr.name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.testPresets || []) {
|
||||
const dupe = presetsFile?.testPresets?.find(
|
||||
(p) => pr.name === p.name && p !== pr
|
||||
);
|
||||
if (dupe) {
|
||||
log.error(
|
||||
localize(
|
||||
"duplicate.test.preset.found",
|
||||
'Found duplicates within the test presets collection: "{0}"',
|
||||
pr.name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.packagePresets || []) {
|
||||
const dupe = presetsFile?.packagePresets?.find(
|
||||
(p) => pr.name === p.name && p !== pr
|
||||
);
|
||||
if (dupe) {
|
||||
log.error(
|
||||
localize(
|
||||
"duplicate.package.preset.found",
|
||||
'Found duplicates within the package presets collection: "{0}"',
|
||||
pr.name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile?.workflowPresets || []) {
|
||||
const dupe = presetsFile?.workflowPresets?.find(
|
||||
(p) => pr.name === p.name && p !== pr
|
||||
);
|
||||
if (dupe) {
|
||||
log.error(
|
||||
localize(
|
||||
"duplicate.workflow.preset.found",
|
||||
'Found duplicates within the workflow presets collection: "{0}"',
|
||||
pr.name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of presetsFile.workflowPresets || []) {
|
||||
if (pr.steps.length < 1 || pr.steps[0].type !== "configure") {
|
||||
log.error(
|
||||
localize(
|
||||
"workflow.does.not.start.configure.step",
|
||||
'The workflow preset "{0}" does not start with a configure step.',
|
||||
pr.name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (const step of pr.steps) {
|
||||
if (step.type === "configure" && step !== pr.steps[0]) {
|
||||
log.error(
|
||||
localize(
|
||||
"workflow.has.subsequent.configure.preset",
|
||||
'The workflow preset "{0}" has another configure preset "{1}" besides the first step "{2}": ',
|
||||
pr.name,
|
||||
step.name,
|
||||
pr.steps[0].name
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info(
|
||||
localize(
|
||||
"successfully.validated.presets",
|
||||
"Successfully validated {0} against presets schema",
|
||||
file
|
||||
)
|
||||
);
|
||||
return presetsFile;
|
||||
}
|
||||
|
||||
private async getExpandedInclude(
|
||||
presetsFile: preset.PresetsFile,
|
||||
include: string,
|
||||
file: string,
|
||||
hostSystemName: string,
|
||||
expansionErrors: ExpansionErrorHandler
|
||||
): Promise<string> {
|
||||
return presetsFile.version >= 9
|
||||
? expandString(
|
||||
include,
|
||||
{
|
||||
vars: {
|
||||
sourceDir: this.folderPath,
|
||||
sourceParentDir: path.dirname(this.folderPath),
|
||||
sourceDirName: path.basename(this.folderPath),
|
||||
hostSystemName: hostSystemName,
|
||||
fileDir: path.dirname(file),
|
||||
pathListSep: path.delimiter
|
||||
},
|
||||
envOverride: {} // $env{} expansions are not supported in `include` v9
|
||||
},
|
||||
expansionErrors
|
||||
)
|
||||
: presetsFile.version >= 7
|
||||
? // Version 7 and later support $penv{} expansions in include paths
|
||||
expandString(
|
||||
include,
|
||||
{
|
||||
// No vars are supported in Version 7 for include paths.
|
||||
vars: {} as MinimalPresetContextVars,
|
||||
envOverride: {} // $env{} expansions are not supported in `include` v9
|
||||
},
|
||||
expansionErrors
|
||||
)
|
||||
: include;
|
||||
}
|
||||
|
||||
private async mergeIncludeFiles(
|
||||
presetsFile: preset.PresetsFile | undefined,
|
||||
file: string,
|
||||
referencedFiles: Map<string, preset.PresetsFile | undefined>,
|
||||
expansionErrors: ExpansionErrorHandler,
|
||||
allowCommentsInPresetsFile: boolean,
|
||||
allowUnsupportedPresetsVersions: boolean
|
||||
): Promise<void> {
|
||||
if (!presetsFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hostSystemName = await util.getHostSystemNameMemo();
|
||||
|
||||
// CMakeUserPresets.json file should include CMakePresets.json file, by default.
|
||||
if (this.presetsFileExists && file === this.userPresetsPath) {
|
||||
presetsFile.include = presetsFile.include || [];
|
||||
const filteredIncludes = [];
|
||||
for (const include of presetsFile.include) {
|
||||
const expandedInclude = await this.getExpandedInclude(
|
||||
presetsFile,
|
||||
include,
|
||||
file,
|
||||
hostSystemName,
|
||||
expansionErrors
|
||||
);
|
||||
if (
|
||||
path.normalize(
|
||||
path.resolve(path.dirname(file), expandedInclude)
|
||||
) === this.presetsPath
|
||||
) {
|
||||
filteredIncludes.push(include);
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredIncludes.length === 0) {
|
||||
presetsFile.include.push(this.presetsPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!presetsFile.include) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Merge the includes in reverse order so that the final presets order is correct
|
||||
for (let i = presetsFile.include.length - 1; i >= 0; i--) {
|
||||
const rawInclude = presetsFile.include[i];
|
||||
const includePath = await this.getExpandedInclude(
|
||||
presetsFile,
|
||||
rawInclude,
|
||||
file,
|
||||
hostSystemName,
|
||||
expansionErrors
|
||||
);
|
||||
const fullIncludePath = path.normalize(
|
||||
path.resolve(path.dirname(file), includePath)
|
||||
);
|
||||
|
||||
// Do not include files more than once
|
||||
if (referencedFiles.has(fullIncludePath)) {
|
||||
const referencedIncludeFile =
|
||||
referencedFiles.get(fullIncludePath);
|
||||
if (referencedIncludeFile) {
|
||||
if (referencedIncludeFile.configurePresets) {
|
||||
presetsFile.configurePresets = lodash.unionWith(
|
||||
referencedIncludeFile.configurePresets,
|
||||
presetsFile.configurePresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (referencedIncludeFile.buildPresets) {
|
||||
presetsFile.buildPresets = lodash.unionWith(
|
||||
referencedIncludeFile.buildPresets,
|
||||
presetsFile.buildPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (referencedIncludeFile.testPresets) {
|
||||
presetsFile.testPresets = lodash.unionWith(
|
||||
referencedIncludeFile.testPresets,
|
||||
presetsFile.testPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (referencedIncludeFile.packagePresets) {
|
||||
presetsFile.packagePresets = lodash.unionWith(
|
||||
referencedIncludeFile.packagePresets,
|
||||
presetsFile.packagePresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (referencedIncludeFile.workflowPresets) {
|
||||
presetsFile.workflowPresets = lodash.unionWith(
|
||||
referencedIncludeFile.workflowPresets,
|
||||
presetsFile.workflowPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (referencedIncludeFile.cmakeMinimumRequired) {
|
||||
if (
|
||||
!presetsFile.cmakeMinimumRequired ||
|
||||
util.versionLess(
|
||||
presetsFile.cmakeMinimumRequired,
|
||||
referencedIncludeFile.cmakeMinimumRequired
|
||||
)
|
||||
) {
|
||||
presetsFile.cmakeMinimumRequired =
|
||||
referencedIncludeFile.cmakeMinimumRequired;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Record the file as referenced, even if the file does not exist.
|
||||
referencedFiles.set(fullIncludePath, undefined);
|
||||
|
||||
const includeFileBuffer = await this.readPresetsFile(
|
||||
fullIncludePath
|
||||
);
|
||||
if (!includeFileBuffer) {
|
||||
log.error(
|
||||
localize(
|
||||
"included.presets.file.not.found",
|
||||
"Included presets file {0} cannot be found",
|
||||
fullIncludePath
|
||||
)
|
||||
);
|
||||
expansionErrors.errorList.push([
|
||||
localize(
|
||||
"included.presets.file.not.found",
|
||||
"Included presets file {0} cannot be found",
|
||||
fullIncludePath
|
||||
),
|
||||
file
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
let includeFile = await this.parsePresetsFile(
|
||||
includeFileBuffer,
|
||||
fullIncludePath,
|
||||
allowCommentsInPresetsFile
|
||||
);
|
||||
referencedFiles.set(fullIncludePath, includeFile);
|
||||
includeFile = await this.validatePresetsFile(
|
||||
includeFile,
|
||||
fullIncludePath,
|
||||
allowUnsupportedPresetsVersions,
|
||||
expansionErrors
|
||||
);
|
||||
if (!includeFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Private fields must be set after validation, otherwise validation would fail.
|
||||
this.populatePrivatePresetsFields(includeFile, fullIncludePath);
|
||||
|
||||
// Recursively merge included files
|
||||
await this.mergeIncludeFiles(
|
||||
includeFile,
|
||||
fullIncludePath,
|
||||
referencedFiles,
|
||||
expansionErrors,
|
||||
allowCommentsInPresetsFile,
|
||||
allowUnsupportedPresetsVersions
|
||||
);
|
||||
|
||||
if (includeFile.configurePresets) {
|
||||
presetsFile.configurePresets = lodash.unionWith(
|
||||
includeFile.configurePresets,
|
||||
presetsFile.configurePresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (includeFile.buildPresets) {
|
||||
presetsFile.buildPresets = lodash.unionWith(
|
||||
includeFile.buildPresets,
|
||||
presetsFile.buildPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (includeFile.testPresets) {
|
||||
presetsFile.testPresets = lodash.unionWith(
|
||||
includeFile.testPresets,
|
||||
presetsFile.testPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (includeFile.packagePresets) {
|
||||
presetsFile.packagePresets = lodash.unionWith(
|
||||
includeFile.packagePresets,
|
||||
presetsFile.packagePresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (includeFile.workflowPresets) {
|
||||
presetsFile.workflowPresets = lodash.unionWith(
|
||||
includeFile.workflowPresets,
|
||||
presetsFile.workflowPresets || [],
|
||||
(a, b) => a.name === b.name
|
||||
);
|
||||
}
|
||||
if (includeFile.cmakeMinimumRequired) {
|
||||
if (
|
||||
!presetsFile.cmakeMinimumRequired ||
|
||||
util.versionLess(
|
||||
presetsFile.cmakeMinimumRequired,
|
||||
includeFile.cmakeMinimumRequired
|
||||
)
|
||||
) {
|
||||
presetsFile.cmakeMinimumRequired =
|
||||
includeFile.cmakeMinimumRequired;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
expansionErrors.errorList.length > 0 ||
|
||||
expansionErrors.tempErrorList.length > 0
|
||||
) {
|
||||
expansionErrors.tempErrorList.forEach((error) =>
|
||||
expansionErrors.errorList.unshift(error)
|
||||
);
|
||||
log.error(
|
||||
localize(
|
||||
"expansion.errors",
|
||||
"Expansion errors found in the presets file."
|
||||
)
|
||||
);
|
||||
expansionErrors.tempErrorList = [];
|
||||
} else {
|
||||
this.collectionsModifier(presetsFile.__path || "");
|
||||
}
|
||||
}
|
||||
|
||||
private async readPresetsFile(file: string): Promise<Buffer | undefined> {
|
||||
if (!(await fs.exists(file))) {
|
||||
return undefined;
|
||||
}
|
||||
log.debug(
|
||||
localize("reading.presets.file", "Reading presets file {0}", file)
|
||||
);
|
||||
return fs.readFile(file);
|
||||
}
|
||||
|
||||
private async parsePresetsFile(
|
||||
fileContent: Buffer | undefined,
|
||||
file: string,
|
||||
allowCommentsInPresetsFile: boolean
|
||||
): Promise<preset.PresetsFile | undefined> {
|
||||
if (!fileContent) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let presetsFile: preset.PresetsFile;
|
||||
try {
|
||||
if (allowCommentsInPresetsFile) {
|
||||
presetsFile = json5.parse(fileContent.toLocaleString());
|
||||
} else {
|
||||
presetsFile = JSON.parse(fileContent.toLocaleString());
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(
|
||||
localize(
|
||||
"failed.to.parse",
|
||||
"Failed to parse {0}: {1}",
|
||||
path.basename(file),
|
||||
util.errorToString(e)
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
return presetsFile;
|
||||
}
|
||||
|
||||
private populatePrivatePresetsFields(
|
||||
presetsFile: preset.PresetsFile | undefined,
|
||||
file: string
|
||||
) {
|
||||
if (!presetsFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
presetsFile.__path = file;
|
||||
const setFile = (presets?: preset.Preset[]) => {
|
||||
if (presets) {
|
||||
for (const preset of presets) {
|
||||
preset.__file = presetsFile;
|
||||
}
|
||||
}
|
||||
};
|
||||
setFile(presetsFile.configurePresets);
|
||||
setFile(presetsFile.buildPresets);
|
||||
setFile(presetsFile.testPresets);
|
||||
setFile(presetsFile.workflowPresets);
|
||||
setFile(presetsFile.packagePresets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expanded presets file if there are no errors, otherwise returns undefined
|
||||
* Does not apply vsdevenv to the presets file
|
||||
*/
|
||||
private async expandPresetsFile(
|
||||
presetsFile: preset.PresetsFile | undefined,
|
||||
expansionErrors: ExpansionErrorHandler
|
||||
): Promise<preset.PresetsFile | undefined> {
|
||||
if (!presetsFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
log.info(
|
||||
localize(
|
||||
"expanding.presets.file",
|
||||
"Expanding presets file {0}",
|
||||
presetsFile?.__path || ""
|
||||
)
|
||||
);
|
||||
|
||||
const expandedConfigurePresets: preset.ConfigurePreset[] = [];
|
||||
for (const configurePreset of presetsFile?.configurePresets || []) {
|
||||
const inheritedPreset = await preset.getConfigurePresetInherits(
|
||||
this.folderPath,
|
||||
configurePreset.name,
|
||||
true,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedConfigurePresets.push(
|
||||
await preset.expandConfigurePresetVariables(
|
||||
inheritedPreset,
|
||||
this.folderPath,
|
||||
configurePreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
true,
|
||||
false,
|
||||
expansionErrors
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const expandedBuildPresets: preset.BuildPreset[] = [];
|
||||
for (const buildPreset of presetsFile?.buildPresets || []) {
|
||||
const inheritedPreset = await preset.getBuildPresetInherits(
|
||||
this.folderPath,
|
||||
buildPreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
buildPreset.configurePreset,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedBuildPresets.push(
|
||||
await preset.expandBuildPresetVariables(
|
||||
inheritedPreset,
|
||||
buildPreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const expandedTestPresets: preset.TestPreset[] = [];
|
||||
for (const testPreset of presetsFile?.testPresets || []) {
|
||||
const inheritedPreset = await preset.getTestPresetInherits(
|
||||
this.folderPath,
|
||||
testPreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
true,
|
||||
testPreset.configurePreset,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedTestPresets.push(
|
||||
await preset.expandTestPresetVariables(
|
||||
inheritedPreset,
|
||||
testPreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const expandedPackagePresets: preset.PackagePreset[] = [];
|
||||
for (const packagePreset of presetsFile?.packagePresets || []) {
|
||||
const inheritedPreset = await preset.getPackagePresetInherits(
|
||||
this.folderPath,
|
||||
packagePreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
undefined,
|
||||
true,
|
||||
packagePreset.configurePreset,
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset) {
|
||||
expandedPackagePresets.push(
|
||||
await preset.expandPackagePresetVariables(
|
||||
inheritedPreset,
|
||||
packagePreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
expansionErrors
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const expandedWorkflowPresets: preset.WorkflowPreset[] = [];
|
||||
for (const workflowPreset of presetsFile?.workflowPresets || []) {
|
||||
const inheritedPreset = await preset.getWorkflowPresetInherits(
|
||||
this.folderPath,
|
||||
workflowPreset.name,
|
||||
this.workspaceFolder,
|
||||
this._sourceDir,
|
||||
true, // should this always be true?
|
||||
undefined, // should this always be undefined?
|
||||
false,
|
||||
expansionErrors
|
||||
);
|
||||
if (inheritedPreset && inheritedPreset !== null) {
|
||||
expandedWorkflowPresets.push(inheritedPreset);
|
||||
}
|
||||
}
|
||||
|
||||
if (expansionErrors.errorList.length > 0) {
|
||||
log.error(
|
||||
localize(
|
||||
"expansion.errors",
|
||||
"Expansion errors found in the presets file."
|
||||
)
|
||||
);
|
||||
return undefined;
|
||||
} else {
|
||||
log.info(
|
||||
localize(
|
||||
"successfully.expanded.presets.file",
|
||||
"Successfully expanded presets file {0}",
|
||||
presetsFile?.__path || ""
|
||||
)
|
||||
);
|
||||
|
||||
// cache everything that we just expanded
|
||||
// we'll only need to expand again on set preset - to apply the vs dev env if needed
|
||||
presetsFile.configurePresets = expandedConfigurePresets;
|
||||
presetsFile.buildPresets = expandedBuildPresets;
|
||||
presetsFile.testPresets = expandedTestPresets;
|
||||
presetsFile.packagePresets = expandedPackagePresets;
|
||||
presetsFile.workflowPresets = expandedWorkflowPresets;
|
||||
|
||||
// clear out the errors since there are none now
|
||||
this.collectionsModifier(presetsFile.__path || "");
|
||||
|
||||
return presetsFile;
|
||||
}
|
||||
}
|
||||
|
||||
private async resetPresetsFile(
|
||||
file: string,
|
||||
setExpandedPresets: SetPresetsFileFunc,
|
||||
setPresetsPlusIncluded: SetPresetsFileFunc,
|
||||
setOriginalPresetsFile: SetPresetsFileFunc,
|
||||
fileExistCallback: (fileExists: boolean) => void,
|
||||
referencedFiles: Map<string, preset.PresetsFile | undefined>,
|
||||
allowCommentsInPresetsFile: boolean,
|
||||
allowUnsupportedPresetsVersions: boolean
|
||||
) {
|
||||
const presetsFileBuffer = await this.readPresetsFile(file);
|
||||
|
||||
// There might be a better location for this, but for now this is the best one...
|
||||
fileExistCallback(Boolean(presetsFileBuffer));
|
||||
|
||||
// Record the file as referenced, even if the file does not exist.
|
||||
let presetsFile = await this.parsePresetsFile(
|
||||
presetsFileBuffer,
|
||||
file,
|
||||
allowCommentsInPresetsFile
|
||||
);
|
||||
referencedFiles.set(file, presetsFile);
|
||||
if (presetsFile) {
|
||||
setOriginalPresetsFile(this.folderPath, presetsFile);
|
||||
} else {
|
||||
setOriginalPresetsFile(this.folderPath, undefined);
|
||||
}
|
||||
|
||||
const expansionErrors: ExpansionErrorHandler = {
|
||||
errorList: [],
|
||||
tempErrorList: []
|
||||
};
|
||||
|
||||
presetsFile = await this.validatePresetsFile(
|
||||
presetsFile,
|
||||
file,
|
||||
allowUnsupportedPresetsVersions,
|
||||
expansionErrors
|
||||
);
|
||||
if (presetsFile) {
|
||||
// Private fields must be set after validation, otherwise validation would fail.
|
||||
this.populatePrivatePresetsFields(presetsFile, file);
|
||||
await this.mergeIncludeFiles(
|
||||
presetsFile,
|
||||
file,
|
||||
referencedFiles,
|
||||
expansionErrors,
|
||||
allowCommentsInPresetsFile,
|
||||
allowUnsupportedPresetsVersions
|
||||
);
|
||||
|
||||
if (
|
||||
expansionErrors.errorList.length > 0 ||
|
||||
expansionErrors.tempErrorList.length > 0
|
||||
) {
|
||||
presetsFile = undefined;
|
||||
} else {
|
||||
// add the include files to the original presets file
|
||||
setPresetsPlusIncluded(this.folderPath, presetsFile);
|
||||
|
||||
// set the pre-expanded version so we can call expandPresetsFile on it
|
||||
setExpandedPresets(this.folderPath, presetsFile);
|
||||
presetsFile = await this.expandPresetsFile(
|
||||
presetsFile,
|
||||
expansionErrors
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (expansionErrors.errorList.length > 0 ||
|
||||
expansionErrors.tempErrorList.length > 0
|
||||
) {
|
||||
await this.presetsFileErrorReporter(file, expansionErrors);
|
||||
}
|
||||
|
||||
setExpandedPresets(this.folderPath, presetsFile);
|
||||
}
|
||||
}
|
|
@ -7,11 +7,11 @@
|
|||
import * as proc from 'child_process';
|
||||
import * as iconv from 'iconv-lite';
|
||||
|
||||
import { createLogger } from './logging';
|
||||
import rollbar from './rollbar';
|
||||
import * as util from './util';
|
||||
import { createLogger } from '@cmt/logging';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import * as util from '@cmt/util';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Environment, EnvironmentUtils } from './environmentVariables';
|
||||
import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -9,17 +9,17 @@ import * as logging from '@cmt/logging';
|
|||
import CMakeProject from '@cmt/cmakeProject';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import { disposeAll, DummyDisposable } from '@cmt/util';
|
||||
import { ConfigurationReader, OptionConfig } from './config';
|
||||
import { CMakeDriver } from './drivers/drivers';
|
||||
import { DirectoryContext } from './workspace';
|
||||
import { StateManager } from './state';
|
||||
import { getStatusBar } from './extension';
|
||||
import * as telemetry from './telemetry';
|
||||
import { StatusBar } from './status';
|
||||
import { FireNow } from './prop';
|
||||
import { setContextAndStore } from './extension';
|
||||
import * as ext from './extension';
|
||||
import { ProjectStatus } from './projectStatus';
|
||||
import { ConfigurationReader, OptionConfig } from '@cmt/config';
|
||||
import { CMakeDriver } from '@cmt/drivers/drivers';
|
||||
import { DirectoryContext } from '@cmt/workspace';
|
||||
import { StateManager } from '@cmt/state';
|
||||
import { getStatusBar } from '@cmt/extension';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import { StatusBar } from '@cmt/status';
|
||||
import { FireNow } from '@cmt/prop';
|
||||
import { setContextAndStore } from '@cmt/extension';
|
||||
import * as ext from '@cmt/extension';
|
||||
import { ProjectStatus } from '@cmt/ui/projectStatus';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
* Wrapper around Rollbar, for error reporting.
|
||||
*/
|
||||
|
||||
import * as logging from './logging';
|
||||
import * as logging from '@cmt/logging';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as path from 'path';
|
||||
import { logEvent } from './telemetry';
|
||||
import { logEvent } from '@cmt/telemetry';
|
||||
import * as lodash from "lodash";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import Ajv, { ValidateFunction } from 'ajv';
|
||||
import * as path from 'path';
|
||||
|
||||
import { fs } from './pr';
|
||||
import { thisExtensionPath } from './util';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { thisExtensionPath } from '@cmt/util';
|
||||
|
||||
export async function loadSchema(filepath: string): Promise<ValidateFunction> {
|
||||
const schema_path = path.isAbsolute(filepath) ? filepath : path.join(thisExtensionPath(), filepath);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ConfigurationReader, StatusBarOptionVisibility, StatusBarTextOptionVisibility, StatusBarStaticOptionVisibility, StatusBarIconOptionVisibility, checkConfigureOverridesPresent, checkBuildOverridesPresent, checkTestOverridesPresent, checkPackageOverridesPresent } from '@cmt/config';
|
||||
import { SpecialKits } from '@cmt/kit';
|
||||
import { SpecialKits } from '@cmt/kits/kit';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* ------------------------------------------------------------------------------------------ */
|
||||
'use strict';
|
||||
|
||||
import * as util from './util';
|
||||
import * as util from '@cmt/util';
|
||||
import * as vscode from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { getExperimentationServiceAsync, IExperimentationService, IExperimentationTelemetry, TargetPopulation } from 'vscode-tas-client';
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as telemetry from '@cmt/telemetry';
|
||||
import * as util from './util';
|
||||
import * as util from '@cmt/util';
|
||||
|
||||
import { CacheEntryType, CMakeCache } from './cache';
|
||||
import { CacheEntryType, CMakeCache } from '@cmt/cache';
|
||||
|
||||
import * as logging from './logging';
|
||||
import * as logging from '@cmt/logging';
|
||||
const log = logging.createLogger('cache');
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
|
@ -1,7 +1,7 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { getExtensionActiveCommands, getExtensionLocalizedStrings, onExtensionActiveCommandsChanged } from './extension';
|
||||
import * as logging from './logging';
|
||||
import { getExtensionActiveCommands, getExtensionLocalizedStrings, onExtensionActiveCommandsChanged } from '@cmt/extension';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { ConfigurationReader } from '@cmt/config';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
|
@ -5,7 +5,7 @@ import * as codeModel from '@cmt/drivers/codeModel';
|
|||
import rollbar from '@cmt/rollbar';
|
||||
import { lexicographicalCompare, splitPath } from '@cmt/util';
|
||||
import CMakeProject from '@cmt/cmakeProject';
|
||||
import { populateViewCodeModel } from './targetsViewCodeModel';
|
||||
import { populateViewCodeModel } from '@cmt/ui/projectOutline/targetsViewCodeModel';
|
||||
import { fs } from '@cmt/pr';
|
||||
import { CodeModelKind } from '@cmt/drivers/cmakeFileApi';
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import CMakeProject from './cmakeProject';
|
||||
import * as preset from './preset';
|
||||
import { runCommand } from './util';
|
||||
import { OptionConfig, checkBuildOverridesPresent, checkConfigureOverridesPresent, checkTestOverridesPresent, checkPackageOverridesPresent } from './config';
|
||||
import CMakeProject from '@cmt/cmakeProject';
|
||||
import * as preset from '@cmt/presets/preset';
|
||||
import { runCommand } from '@cmt/util';
|
||||
import { OptionConfig, checkBuildOverridesPresent, checkConfigureOverridesPresent, checkTestOverridesPresent, checkPackageOverridesPresent } from '@cmt/config';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
|
@ -1,5 +1,5 @@
|
|||
import { getStatusBar } from "@cmt/extension";
|
||||
import { treeDataProvider } from "@cmt/projectStatus";
|
||||
import { treeDataProvider } from "@cmt/ui/projectStatus";
|
||||
|
||||
export async function onConfigureSettingsChange(): Promise<void> {
|
||||
await treeDataProvider.refreshConfigNode();
|
||||
|
|
|
@ -5,14 +5,14 @@ import * as path from 'path';
|
|||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as os from 'os';
|
||||
import * as contex from './contextKeyExpr';
|
||||
import * as contex from '@cmt/contextKeyExpr';
|
||||
|
||||
import { DebuggerEnvironmentVariable, execute } from '@cmt/proc';
|
||||
import rollbar from '@cmt/rollbar';
|
||||
import { Environment, EnvironmentUtils } from './environmentVariables';
|
||||
import { Environment, EnvironmentUtils } from '@cmt/environmentVariables';
|
||||
import { TargetPopulation } from 'vscode-tas-client';
|
||||
import { expandString, ExpansionOptions } from './expand';
|
||||
import { ExtensionManager } from './extension';
|
||||
import { expandString, ExpansionOptions } from '@cmt/expand';
|
||||
import { ExtensionManager } from '@cmt/extension';
|
||||
import * as glob from "glob";
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
|
|
|
@ -2,16 +2,16 @@ import { DirectoryContext } from '@cmt/workspace';
|
|||
import * as vscode from 'vscode';
|
||||
import { CMakeDriver } from '@cmt/drivers/drivers';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { ConfigureType } from './cmakeProject';
|
||||
import { WorkflowPreset, ConfigurePreset, BuildPreset, TestPreset, PackagePreset, getPresetByName, allConfigurePresets, allBuildPresets, allTestPresets, allPackagePresets } from './preset';
|
||||
import { ConfigureType } from '@cmt/cmakeProject';
|
||||
import { WorkflowPreset, ConfigurePreset, BuildPreset, TestPreset, PackagePreset, getPresetByName, allConfigurePresets, allBuildPresets, allTestPresets, allPackagePresets } from '@cmt/presets/preset';
|
||||
import * as proc from '@cmt/proc';
|
||||
import { ProjectController } from './projectController';
|
||||
import { ProjectController } from '@cmt/projectController';
|
||||
|
||||
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
|
||||
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
|
||||
|
||||
import * as logging from './logging';
|
||||
import { ConfigureTrigger } from './cmakeProject';
|
||||
import * as logging from '@cmt/logging';
|
||||
import { ConfigureTrigger } from '@cmt/cmakeProject';
|
||||
const log = logging.createLogger('workflow');
|
||||
|
||||
export class WorkflowDriver implements vscode.Disposable {
|
||||
|
|
|
@ -12,7 +12,7 @@ async function main() {
|
|||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/extension-tests/multi-root-UI/project-workspace.code-workspace');
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/end-to-end-tests/multi-root-UI/project-workspace.code-workspace');
|
||||
|
||||
const launchArgs = ["--disable-extensions", "--disable-workspace-trust", testWorkspace];
|
||||
const extensionTestsEnv: { [key: string]: string | undefined } = {
|
|
@ -23,7 +23,7 @@ suite('Build', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
folder2 = new DefaultEnvironment('test/extension-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
folder2 = new DefaultEnvironment('test/end-to-end-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
compdb_cp_path = path.join(folder2.projectFolder.location, 'compdb_cp.json');
|
||||
|
||||
// This test will use all on the same kit.
|
|
@ -10,7 +10,7 @@ suite('Debug/Launch interface', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
|
||||
const kit = await getFirstSystemKit();
|
||||
await vscode.commands.executeCommand('cmake.setKitByName', kit.name);
|
|
@ -13,7 +13,7 @@ suite('Environment Variables in Variants', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/multi-root-UI/project-folder-2', build_loc, exe_res);
|
||||
|
||||
// This test will use all on the same kit.
|
||||
// No rescan of the tools is needed
|
|
@ -12,7 +12,7 @@ async function main() {
|
|||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './index');
|
||||
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/extension-tests/single-root-UI/project-folder');
|
||||
const testWorkspace = path.resolve(extensionDevelopmentPath, 'test/end-to-end-tests/single-root-UI/project-folder');
|
||||
|
||||
const launchArgs = ["--disable-extensions", "--disable-workspace-trust", testWorkspace];
|
||||
|
|
@ -22,7 +22,7 @@ suite('Build using Kits and Variants', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
compdb_cp_path = path.join(testEnv.projectFolder.location, 'compdb_cp.json');
|
||||
|
||||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'never');
|
|
@ -19,7 +19,7 @@ suite('Build using Presets', () => {
|
|||
const exe_res = 'output.txt';
|
||||
|
||||
// CMakePresets.json and CMakeUserPresets.json exist so will use presets by default
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
compdb_cp_path = path.join(testEnv.projectFolder.location, 'compdb_cp.json');
|
||||
|
||||
await clearExistingKitConfigurationFile();
|
|
@ -10,7 +10,7 @@ suite('Debug/Launch interface using Kits and Variants', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
|
||||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'never');
|
||||
await vscode.commands.executeCommand('cmake.getSettingsChangePromise');
|
|
@ -10,7 +10,7 @@ suite('Debug/Launch interface using Presets', () => {
|
|||
const build_loc = 'build';
|
||||
const exe_res = 'output.txt';
|
||||
|
||||
testEnv = new DefaultEnvironment('test/extension-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
testEnv = new DefaultEnvironment('test/end-to-end-tests/single-root-UI/project-folder', build_loc, exe_res);
|
||||
testEnv.projectFolder.buildDirectory.clear();
|
||||
|
||||
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'always');
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче