xref: /openbmc/openbmc/meta-arm/ci/listmachines.py (revision bec4ebc2)
1#! /usr/bin/env python3
2
3import pathlib
4import typing
5import sys
6
7"""
8List all of the machines available under the listed sub-layers of meta-arm.
9"""
10def list_machines(layers: typing.Sequence[str]) -> typing.Set[str]:
11    machines = set()
12
13    # We know we're in meta-arm/scripts, so find the top-level directory
14    metaarm = pathlib.Path(__file__).resolve().parent.parent
15    if metaarm.name != "meta-arm":
16        raise Exception("Not running inside meta-arm")
17
18    for layer in layers:
19        machines |= set(p.stem for p in (metaarm / layer / "conf" / "machine").glob("*.conf"))
20    return machines
21
22if __name__ == "__main__":
23    if len(sys.argv) > 1:
24        machines = list_machines(sys.argv[1:])
25        print(" ".join(sorted(machines)))
26        sys.exit(0)
27    else:
28        print("Usage:\n$ %s [layer name ...] " % sys.argv[0])
29        sys.exit(1)
30