Enhance generator mismatch detection and clean-up logic#4892
Open
hanniavalera wants to merge 8 commits intomainfrom
Open
Enhance generator mismatch detection and clean-up logic#4892hanniavalera wants to merge 8 commits intomainfrom
hanniavalera wants to merge 8 commits intomainfrom
Conversation
- 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.
d36ebc9 to
d3d6669
Compare
Contributor
There was a problem hiding this comment.
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
preferredGeneratorwhen 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withCMakeCache.txtis detected, including during driver reloads triggered by generator-related setting changes. [1] [2] [3] [4]Improved generator selection logic for Visual Studio kits:
preferredGeneratorat scan time.Testing and reliability:
generatorMismatchto detect generator mismatches between the desired generator and the one cached inCMakeCache.txt, and exported it for direct unit testing. [1] [2]Documentation updates:
docs/kits.mdto clarify how Visual Studio kits handle generator selection, when and howpreferredGeneratoris 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]