Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cppython/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def write_generator_presets(path: Path, generator_name: str, toolchain_path: Pat
root_preset = read_model_json(root_preset_path, CMakePresets)

for include_path in root_preset.include:
if Path(include_path).name is "cppython.json":
if Path(include_path).name == "cppython.json":
include_path = json_path

write_model_json(root_preset_path, root_preset)
Expand Down
35 changes: 24 additions & 11 deletions cppython/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ class Preset(BaseModel):

name: str
hidden: Optional[bool]
inherits: list[str] = []
inherits: Optional[list[str] | str]
displayName: Optional[str]
description: Optional[str]

@validator("inherits")
def validate_str(cls, values):
"""
Conform to list
"""
if isinstance(values, str):
return [values]

return values


class ConfigurePreset(Preset):
"""
Expand Down Expand Up @@ -73,22 +83,25 @@ class CMakePresets(BaseModel, extra=Extra.forbid):
"""

version: int = Field(default=4, const=True)
cmakeMinimumRequired: CMakeVersion = CMakeVersion() # TODO: 'version' compatability validation
include: list[str] = []
cmakeMinimumRequired: CMakeVersion = CMakeVersion() # TODO: 'version' compatibility validation
include: Optional[list[str]]
vendor: Optional[Any]
configurePresets: list[ConfigurePreset] = []
buildPresets: list[BuildPreset] = []
testPresets: list[TestPreset] = []
configurePresets: Optional[list[ConfigurePreset]]
buildPresets: Optional[list[BuildPreset]]
testPresets: Optional[list[TestPreset]]

@validator("include")
def validate_path(cls, v):
def validate_path(cls, values):
"""
TODO
"""
output = []
for value in v:
output.append(Path(value).as_posix())
return output
if values is not None:
output = []
for value in values:
output.append(Path(value).as_posix())
return output

return None


@dataclass
Expand Down