Skip to content

Enhance generator mismatch detection and clean-up logic#4892

Open
hanniavalera wants to merge 8 commits intomainfrom
dev/hanniavalera/fixConfigGen
Open

Enhance generator mismatch detection and clean-up logic#4892
hanniavalera wants to merge 8 commits intomainfrom
dev/hanniavalera/fixConfigGen

Conversation

@hanniavalera
Copy link
Copy Markdown
Contributor

@hanniavalera hanniavalera commented Apr 16, 2026

This pull request addresses a regression affecting Visual Studio kits with Ninja-based build caches, enhances generator selection and fallback logic for Visual Studio kits, and introduces improved detection and handling of generator mismatches to prevent build failures. It also updates documentation to clarify generator selection behavior and adds targeted unit tests for generator mismatch detection.

Bug fixes and generator selection improvements:

  • Fixed a regression where Visual Studio kits with an existing Ninja-based build cache would fail after updating CMake Tools due to a generator mismatch. Ninja is now again preferred when available, and for stale VS kits missing preferredGenerator, the correct VS generator is derived at runtime as a fallback. The extension now auto-cleans the build directory when a generator mismatch with CMakeCache.txt is detected, including during driver reloads triggered by generator-related setting changes. [1] [2] [3] [4]

  • Improved generator selection logic for Visual Studio kits:

    • Kits scanned for known VS versions now get a preferredGenerator at scan time.
    • If a kit was scanned before support for a VS version, the correct generator is derived at runtime and only used after Ninja/Unix Makefiles fallbacks.
    • Documentation and code comments clarify the generator precedence order and fallback behavior. [1] [2] [3] [4] [5] [6] [7]

Testing and reliability:

  • Added a pure helper function generatorMismatch to detect generator mismatches between the desired generator and the one cached in CMakeCache.txt, and exported it for direct unit testing. [1] [2]
  • Added comprehensive unit tests for generator mismatch detection, covering a variety of scenarios including cache parsing and different generator combinations.

Documentation updates:

  • Updated docs/kits.md to clarify how Visual Studio kits handle generator selection, when and how preferredGenerator is set or derived, and the order in which generators are considered. Also documented the new safety net for cleaning the build directory on generator mismatches. [1] [2] [3]

@hanniavalera hanniavalera marked this pull request as ready for review April 17, 2026 14:27
Comment thread src/drivers/cmakeDriver.ts Outdated
Comment thread src/drivers/cmakeDriver.ts
- Added a new method to clean prior configurations if the generator changes..
- Removed deprecated functions related to Visual Studio generator mapping.
- Introduced unit tests to verify generator mismatch detection and kit change logic.
…pping

- Modify kit scanning logic to derive preferred generators for Visual Studio kits lacking a predefined generator.
- Introduce utility functions for mapping Visual Studio versions to CMake generators.
- Add unit tests to verify correct generator mapping for various Visual Studio versions.
@hanniavalera hanniavalera force-pushed the dev/hanniavalera/fixConfigGen branch from d36ebc9 to d3d6669 Compare April 17, 2026 21:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves generator selection and generator-mismatch handling in kits mode, primarily to prevent failures when a project’s existing CMakeCache.txt was produced with a different generator than the one newly selected (notably affecting Visual Studio kits and Ninja caches).

Changes:

  • Add generator-mismatch detection in the driver and trigger clean-up when switching kits in-place.
  • Refine Visual Studio kit generator preference handling (use preferredGenerator when present; derive VS generator only as a last-resort fallback).
  • Update kits documentation + changelog entry; add unit tests for kit-change clean detection and cache generator parsing.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/drivers/cmakeDriver.ts Adds _hasGeneratorChanged() and uses it during setKit() to decide whether to clean prior configuration.
src/kits/kit.ts Minor refactor/clarification in VS generator derivation helpers.
test/unit-tests/kit-scan.test.ts Adds regression tests for kitChangeNeedsClean() around preferredGenerator changes.
test/unit-tests/generator-mismatch.test.ts Adds tests around reading CMAKE_GENERATOR from cache content.
docs/kits.md Documents generator selection precedence and generator-mismatch clean behavior.
CHANGELOG.md Adds a 1.23.51 bug-fix entry describing the regression fix.

Comment thread test/unit-tests/kit-scan.test.ts
Comment thread docs/kits.md Outdated
Comment thread test/unit-tests/generator-mismatch.test.ts Outdated
Comment thread src/drivers/cmakeDriver.ts
Comment thread test/unit-tests/kit-scan.test.ts
@hanniavalera hanniavalera linked an issue Apr 20, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REGRESSION] Ninja generator no longer being used after update

3 participants