Refactor CMake preset parser to own module - #621
Merged
nikobockerman merged 1 commit intoJul 21, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extracts the CMake preset parsing logic used by the C++ solver into a dedicated aoc_main._cmake_presets module, and adds unit tests to validate the preset lookup and inheritance behavior.
Changes:
- Added
aoc_main._cmake_presetsas a minimal CMake preset reader (workflow configure-step lookup +binaryDirresolution with inheritance). - Refactored the C++ solver’s CMake config resolver to delegate preset parsing/queries to the new module.
- Added a pytest suite covering preset resolution and error cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| aoc-main/tests/test_cmake_presets.py | Adds unit tests for workflow/configure preset lookups and binaryDir inheritance behavior. |
| aoc-main/src/aoc_main/_solver_cpp.py | Removes inline JSON parsing and delegates preset parsing to aoc_main._cmake_presets. |
| aoc-main/src/aoc_main/_cmake_presets.py | Introduces the new preset parsing module used by the C++ solver. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nikobockerman
force-pushed
the
refactor-cmake-preset-parser-to-separate-module
branch
from
July 21, 2026 20:52
a2b7a1e to
1b1523d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
aoc-main/src/aoc_main/_solver_cpp.py:12
pathlib(andIterable) are only imported underTYPE_CHECKING, but this module uses them in runtime-evaluated type annotations (there is nofrom __future__ import annotations), which will raiseNameErrorat import time. Import them at runtime (or addfrom __future__ import annotations).
import asyncio
import os
from dataclasses import dataclass
from functools import cached_property
from typing import TYPE_CHECKING
from aoc_main import _cmake_presets, _logging, _solvers, _types
if TYPE_CHECKING:
import pathlib
from collections.abc import Iterable
aoc-main/src/aoc_main/_cmake_presets.py:116
binary_dir()can loop forever if presets contain an inheritance cycle (or repeated parents). Track visited preset names while walking the breadth-first inheritance graph so lookup always terminates with a clear error.
pending = [configure_preset_name]
while pending:
name = pending.pop(0)
preset = self._get_preset("configure", name)
if preset is None:
msg = f"Configure preset not found: {name}"
raise CMakePresetError(msg)
binary_dir = preset.get("binaryDir")
if binary_dir is not None:
_logger.debug("Found binaryDir from preset %s: %s", name, binary_dir)
return pathlib.Path(binary_dir)
_logger.debug(
"binaryDir not set on preset %s; checking inherited presets", name
)
pending.extend(preset.get("inherits", []))
nikobockerman
deleted the
refactor-cmake-preset-parser-to-separate-module
branch
July 21, 2026 21:03
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.
No description provided.