Skip to content

Commit

Permalink
fix inheritance for environment, cache variables, etc (#3604)
Browse files Browse the repository at this point in the history
* fix inheritance for environment, cache variables, etc

* fix inheritance

* update changelog
  • Loading branch information
gcampbell-msft authored Feb 22, 2024
1 parent 810cd00 commit 02c548e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# What's New?

## 1.17.17

Bug Fixes:

- Fix the regression for inheritance of cache variables and other inheritable fields. [#3603](https://github.com/microsoft/vscode-cmake-tools/issues/3603)

## 1.17.16

Bug Fixes:
Expand Down
23 changes: 8 additions & 15 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ function getVendorForConfigurePresetHelper(folder: string, preset: ConfigurePres
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parent of reversedInherits) {
for (const parent of preset.inherits) {
const parentVendor = getVendorForConfigurePresetImpl(folder, parent, allowUserPreset);
if (parentVendor) {
for (const key in parentVendor) {
Expand Down Expand Up @@ -1111,12 +1110,11 @@ async function expandConfigurePresetHelper(folder: string, preset: ConfigurePres
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parentName of reversedInherits) {
for (const parentName of preset.inherits) {
const parent = await expandConfigurePresetImpl(folder, parentName, workspaceFolder, sourceDir, allowUserPreset);
if (parent) {
// Inherit environment
inheritedEnv = EnvironmentUtils.mergePreserveNull([inheritedEnv, parent.environment]);
inheritedEnv = EnvironmentUtils.mergePreserveNull([parent.environment, inheritedEnv]);
// Inherit cache vars
for (const name in parent.cacheVariables) {
if (preset.cacheVariables[name] === undefined) {
Expand Down Expand Up @@ -1295,8 +1293,7 @@ function getConfigurePresetForPresetHelper(folder: string, preset: BuildPreset |
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parent of reversedInherits) {
for (const parent of preset.inherits) {
const parentConfigurePreset = getConfigurePresetForPresetImpl(folder, parent, presetType, allowUserPreset);
if (parentConfigurePreset) {
preset.configurePreset = parentConfigurePreset;
Expand Down Expand Up @@ -1418,8 +1415,7 @@ async function expandBuildPresetHelper(folder: string, preset: BuildPreset, work
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parentName of reversedInherits) {
for (const parentName of preset.inherits) {
const parent = await expandBuildPresetImpl(folder, parentName, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, allowUserPreset);
if (parent) {
// Inherit environment
Expand Down Expand Up @@ -1604,8 +1600,7 @@ async function expandTestPresetHelper(folder: string, preset: TestPreset, worksp
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parentName of reversedInherits) {
for (const parentName of preset.inherits) {
const parent = await expandTestPresetImpl(folder, parentName, workspaceFolder, sourceDir, preferredGeneratorName, allowUserPreset);
if (parent) {
// Inherit environment
Expand Down Expand Up @@ -1733,8 +1728,7 @@ async function expandPackagePresetHelper(folder: string, preset: PackagePreset,
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parentName of reversedInherits) {
for (const parentName of preset.inherits) {
const parent = await expandPackagePresetImpl(folder, parentName, workspaceFolder, sourceDir, preferredGeneratorName, allowUserPreset);
if (parent) {
// Inherit environment
Expand Down Expand Up @@ -1868,8 +1862,7 @@ async function expandWorkflowPresetHelper(folder: string, preset: WorkflowPreset
if (util.isString(preset.inherits)) {
preset.inherits = [preset.inherits];
}
const reversedInherits = preset.inherits.slice().reverse();
for (const parentName of reversedInherits) {
for (const parentName of preset.inherits) {
const parent = await expandWorkflowPresetImpl(folder, parentName, workspaceFolder, sourceDir, preferredGeneratorName, allowUserPreset);
if (parent) {
// Inherit environment
Expand Down

0 comments on commit 02c548e

Please sign in to comment.