Consider parallel jobs setting in generated defaultBuildPreset (#2817)

This commit is contained in:
maxmitti 2023-01-12 21:42:46 +01:00 коммит произвёл GitHub
Родитель 4ccb03c702
Коммит e80038f65d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -11,6 +11,7 @@ Improvements:
- Add a public API for extension authors that depend on CMake Tools. [#494](https://github.com/microsoft/vscode-cmake-tools/issues/494)
- Support explicit typing in `cmake.configureSettings`. [#1457](https://github.com/microsoft/vscode-cmake-tools/issues/1457)
- Scan for kits will now add ARM64 hosts for MSVC. [PR #2887](https://github.com/microsoft/vscode-cmake-tools/pull/2887) [@scaryrawr](https://github.com/scaryrawr)
- Adhere to the setting entry "Parallel Jobs" (`cmake.parallelJobs`) when generating the default build preset. [#2765](https://github.com/microsoft/vscode-cmake-tools/issues/2765) [@maxmitti](https://github.com/maxmitti)
Bug Fixes:
- Fix warning message that appears when using a default build preset with a multi-config generator. [#2353](https://github.com/microsoft/vscode-cmake-tools/issues/2353)

Просмотреть файл

@ -309,6 +309,7 @@ export class CMakeProject {
buildPreset,
lightNormalizePath(this.folderPath || '.'),
this.sourceDir,
this.workspaceContext.config.parallelJobs,
this.getPreferredGeneratorName(),
true,
this.configurePreset?.name);

Просмотреть файл

@ -9,6 +9,7 @@ import { expandString, 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 } from './config';
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
@ -1148,7 +1149,7 @@ function getConfigurePresetForPresetHelper(folder: string, preset: BuildPreset |
return null;
}
export async function expandBuildPreset(folder: string, name: string, workspaceFolder: string, sourceDir: string, preferredGeneratorName?: string, allowUserPreset: boolean = false, configurePreset?: string): Promise<BuildPreset | null> {
export async function expandBuildPreset(folder: string, name: string, workspaceFolder: string, sourceDir: string, parallelJobs?: number, preferredGeneratorName?: string, allowUserPreset: boolean = false, configurePreset?: string): Promise<BuildPreset | null> {
const refs = referencedBuildPresets.get(folder);
if (!refs) {
referencedBuildPresets.set(folder, new Set());
@ -1156,7 +1157,7 @@ export async function expandBuildPreset(folder: string, name: string, workspaceF
refs.clear();
}
const preset = await expandBuildPresetImpl(folder, name, workspaceFolder, sourceDir, preferredGeneratorName, allowUserPreset, configurePreset);
const preset = await expandBuildPresetImpl(folder, name, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, allowUserPreset, configurePreset);
if (!preset) {
return null;
}
@ -1201,16 +1202,16 @@ export async function expandBuildPreset(folder: string, name: string, workspaceF
return expandedPreset;
}
async function expandBuildPresetImpl(folder: string, name: string, workspaceFolder: string, sourceDir: string, preferredGeneratorName?: string, allowUserPreset: boolean = false, configurePreset?: string): Promise<BuildPreset | null> {
async function expandBuildPresetImpl(folder: string, name: string, workspaceFolder: string, sourceDir: string, parallelJobs?: number, preferredGeneratorName?: string, allowUserPreset: boolean = false, configurePreset?: string): Promise<BuildPreset | null> {
let preset = getPresetByName(buildPresets(folder), name);
if (preset) {
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, preferredGeneratorName);
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName);
}
if (allowUserPreset) {
preset = getPresetByName(userBuildPresets(folder), name);
if (preset) {
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, preferredGeneratorName, true);
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, true);
}
}
@ -1220,16 +1221,17 @@ async function expandBuildPresetImpl(folder: string, name: string, workspaceFold
name: defaultBuildPreset.name,
displayName: defaultBuildPreset.displayName,
description: defaultBuildPreset.description,
jobs: parallelJobs || defaultNumJobs(),
configurePreset
};
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, preferredGeneratorName, true);
return expandBuildPresetHelper(folder, preset, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, true);
}
log.error(localize('build.preset.not.found', 'Could not find build preset with name {0}', name));
return null;
}
async function expandBuildPresetHelper(folder: string, preset: BuildPreset, workspaceFolder: string, sourceDir: string, preferredGeneratorName?: string, allowUserPreset: boolean = false) {
async function expandBuildPresetHelper(folder: string, preset: BuildPreset, workspaceFolder: string, sourceDir: string, parallelJobs?: number, preferredGeneratorName?: string, allowUserPreset: boolean = false) {
if (preset.__expanded) {
return preset;
}
@ -1258,7 +1260,7 @@ async function expandBuildPresetHelper(folder: string, preset: BuildPreset, work
preset.inherits = [preset.inherits];
}
for (const parentName of preset.inherits) {
const parent = await expandBuildPresetImpl(folder, parentName, workspaceFolder, sourceDir, preferredGeneratorName, allowUserPreset);
const parent = await expandBuildPresetImpl(folder, parentName, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, allowUserPreset);
if (parent) {
// Inherit environment
inheritedEnv = EnvironmentUtils.mergePreserveNull([parent.environment, inheritedEnv]);