···178178 else if final.isLoongArch64 then "loongarch"
179179 else final.parsed.cpu.name;
180180181181+ # https://source.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106
182182+ ubootArch =
183183+ if final.isx86_32 then "x86" # not i386
184184+ else if final.isMips64 then "mips64" # uboot *does* distinguish between mips32/mips64
185185+ else final.linuxArch; # other cases appear to agree with linuxArch
186186+181187 qemuArch =
182188 if final.isAarch32 then "arm"
183189 else if final.isS390 && !final.isS390x then null
···11import ast
22import sys
33+from pathlib import Path
3445"""
56This program takes all the Machine class methods and prints its methods in
···40414142"""
42434343-assert len(sys.argv) == 2
4444+4545+def main() -> None:
4646+ if len(sys.argv) != 2:
4747+ print(f"Usage: {sys.argv[0]} <path-to-test-driver>")
4848+ sys.exit(1)
4949+5050+ module = ast.parse(Path(sys.argv[1]).read_text())
5151+5252+ class_definitions = (node for node in module.body if isinstance(node, ast.ClassDef))
44534545-with open(sys.argv[1], "r") as f:
4646- module = ast.parse(f.read())
5454+ machine_class = next(filter(lambda x: x.name == "Machine", class_definitions))
5555+ assert machine_class is not None
47564848-class_definitions = (node for node in module.body if isinstance(node, ast.ClassDef))
5757+ function_definitions = [
5858+ node for node in machine_class.body if isinstance(node, ast.FunctionDef)
5959+ ]
6060+ function_definitions.sort(key=lambda x: x.name)
49615050-machine_class = next(filter(lambda x: x.name == "Machine", class_definitions))
5151-assert machine_class is not None
6262+ for function in function_definitions:
6363+ docstr = ast.get_docstring(function)
6464+ if docstr is not None:
6565+ args = ", ".join(a.arg for a in function.args.args[1:])
6666+ args = f"({args})"
52675353-function_definitions = [
5454- node for node in machine_class.body if isinstance(node, ast.FunctionDef)
5555-]
5656-function_definitions.sort(key=lambda x: x.name)
6868+ docstr = "\n".join(f" {line}" for line in docstr.strip().splitlines())
57695858-for f in function_definitions:
5959- docstr = ast.get_docstring(f)
6060- if docstr is not None:
6161- args = ", ".join((a.arg for a in f.args.args[1:]))
6262- args = f"({args})"
7070+ print(f"{function.name}{args}\n\n:{docstr[1:]}\n")
63716464- docstr = "\n".join((f" {l}" for l in docstr.strip().splitlines()))
65726666- print(f"{f.name}{args}\n\n:{docstr[1:]}\n")
7373+if __name__ == "__main__":
7474+ main()
···5454# guess may not align with u-boot's nomenclature correctly, so it can
5555# be overridden.
5656# See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L81-106 for a list.
5757-, uInitrdArch ? stdenvNoCC.hostPlatform.linuxArch
5757+, uInitrdArch ? stdenvNoCC.hostPlatform.ubootArch
58585959# The name of the compression, as recognised by u-boot.
6060# See https://gitlab.denx.de/u-boot/u-boot/-/blob/9bfb567e5f1bfe7de8eb41f8c6d00f49d2b9a426/common/image.c#L195-204 for a list.