Tooling V1

This commit is contained in:
2026-03-21 22:23:08 +01:00
parent 6ea8f7ddbd
commit 0e8a6f7e9f
8 changed files with 508 additions and 4 deletions

33
src/neoecu/common.py Normal file
View File

@@ -0,0 +1,33 @@
# Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
# Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path
import tomllib
def find_project_root(
start: Path | None = None,
filename: str = "neoecu.toml",
max_depth: int = 10
) -> Path | None:
current = start or Path.cwd()
for _ in range(max_depth + 1):
if (current / filename).exists():
return current # return the directory (project root)
if current.parent == current:
break
current = current.parent
return None
def load_config(root: Path) -> dict:
config_path = root / "neoecu.toml"
with open(config_path, "rb") as f:
return tomllib.load(f)
def check_pair(config: dict) -> bool:
if (config["build"]["m7_type"] == "ST") & (config["build"]["m4_type"] == "Zephyr"):
return True
return False