Skip to content

Commit b5a604d

Browse files
committed
Overwrite Include Reference
1 parent 27e5c4e commit b5a604d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cppython/project.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pydantic import create_model
2323

2424
from cppython.schema import API, CMakePresets, ConfigurePreset, ProjectConfiguration
25-
from cppython.utility import write_model_json
25+
from cppython.utility import read_model_json, write_model_json
2626

2727

2828
class ProjectBuilder:
@@ -156,6 +156,19 @@ def write_generator_presets(path: Path, generator_name: str, toolchain_path: Pat
156156

157157
write_model_json(json_path, presets)
158158

159+
# Read the top level json file and replace the include reference
160+
161+
root_preset_path = self.configuration.root_path / "CMakePresets.json"
162+
163+
if root_preset_path.exists():
164+
root_preset = read_model_json(root_preset_path, CMakePresets)
165+
166+
for include_path in root_preset.include:
167+
if Path(include_path).name is "cppython.json":
168+
include_path = json_path
169+
170+
write_model_json(root_preset_path, root_preset)
171+
159172

160173
class Project(API):
161174
"""

0 commit comments

Comments
 (0)