Elffuss BraidHub

kikocis/kleidiai public

main · 988 BRawPermalink
1#!/usr/bin/env python3
2#
3# SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
4#
5# SPDX-License-Identifier: Apache-2.0
6"""Helpers for discovering implemented micro-kernels."""
7from dataclasses import dataclass
8from pathlib import Path
9
10
11@dataclass(frozen=True, order=True)
12class Microkernel:
13 operation: str
14 directory: str
15 name: str
16
17
18def gather_microkernels(ukernels_dir: str) -> set[Microkernel]:
19 """Gather micro-kernels implemented as .c files under a ukernels directory."""
20 root = Path(ukernels_dir)
21 microkernels: set[Microkernel] = set()
22
23 for path in root.rglob("*.c"):
24 relative_path = path.relative_to(root)
25 if len(relative_path.parts) < 2:
26 continue
27
28 microkernels.add(
29 Microkernel(
30 operation=relative_path.parts[0],
31 directory=path.parent.name,
32 name=path.stem,
33 )
34 )
35
36 return microkernels