Tooling V1
This commit is contained in:
33
src/neoecu/common.py
Normal file
33
src/neoecu/common.py
Normal 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
|
||||
Reference in New Issue
Block a user