Release v2.1.0
This commit is contained in:
@@ -4,6 +4,20 @@
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
|
||||
CORE_CONFIG = {
|
||||
"CM7": {
|
||||
"dir_key": "m7_dir",
|
||||
"type_key": "m7_type",
|
||||
"supported_type": "ST",
|
||||
},
|
||||
"CM4": {
|
||||
"dir_key": "m4_dir",
|
||||
"type_key": "m4_type",
|
||||
"supported_type": "Zephyr",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def find_project_root(
|
||||
start: Path | None = None,
|
||||
filename: str = "neoecu.toml",
|
||||
@@ -27,7 +41,52 @@ def load_config(root: Path) -> dict:
|
||||
with open(config_path, "rb") as f:
|
||||
return tomllib.load(f)
|
||||
|
||||
|
||||
def configured_cores(config: dict) -> list[str]:
|
||||
build_config = config.get("build", {})
|
||||
cores: list[str] = []
|
||||
|
||||
for core, core_config in CORE_CONFIG.items():
|
||||
if all(build_config.get(key) for key in (core_config["dir_key"], core_config["type_key"])):
|
||||
cores.append(core)
|
||||
|
||||
return cores
|
||||
|
||||
|
||||
def core_root(root: Path, config: dict, core: str) -> Path:
|
||||
return root / config["build"][CORE_CONFIG[core]["dir_key"]]
|
||||
|
||||
|
||||
def select_cores(config: dict, args) -> list[str]:
|
||||
selected = []
|
||||
|
||||
if getattr(args, "CM7", False):
|
||||
selected.append("CM7")
|
||||
if getattr(args, "CM4", False):
|
||||
selected.append("CM4")
|
||||
|
||||
if not selected:
|
||||
selected = configured_cores(config)
|
||||
|
||||
configured = configured_cores(config)
|
||||
missing = [core for core in selected if core not in configured]
|
||||
if missing:
|
||||
missing_cores = ", ".join(missing)
|
||||
raise ValueError(f"{missing_cores} is not fully configured in neoecu.toml")
|
||||
|
||||
return selected
|
||||
|
||||
|
||||
def check_pair(config: dict) -> bool:
|
||||
if (config["build"]["m7_type"] == "ST") & (config["build"]["m4_type"] == "Zephyr"):
|
||||
return True
|
||||
return False
|
||||
build_config = config.get("build", {})
|
||||
cores = configured_cores(config)
|
||||
|
||||
if not cores:
|
||||
return False
|
||||
|
||||
for core in cores:
|
||||
core_config = CORE_CONFIG[core]
|
||||
if build_config[core_config["type_key"]] != core_config["supported_type"]:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user