2"""Embed the three compiled runtime-module regression fixtures."""
4from pathlib
import Path
6parser = argparse.ArgumentParser(description=__doc__)
7parser.add_argument(
"--provider", type=Path, required=
True)
8parser.add_argument(
"--consumer", type=Path, required=
True)
9parser.add_argument(
"--undeclared", type=Path, required=
True)
10parser.add_argument(
"--output", type=Path, required=
True)
11args = parser.parse_args()
13 '// Generated runtime-module regression fixtures.',
14 '#include "pedigree/kernel/processor/types.h"',
17for kind
in (
"provider",
"consumer",
"undeclared"):
18 data = getattr(args, kind).read_bytes()
19 if not data
or len(data) > 1024 * 1024:
20 parser.error(f
"{kind} fixture must contain between 1 byte and 1 MiB")
21 name = f
"runtime_{kind}_image"
22 lines.append(f
"alignas(16) extern const uint8_t {name}[] = {{")
23 for offset
in range(0, len(data), 16):
24 lines.append(
" " +
", ".join(f
"0x{byte:02x}" for byte
in data[offset:offset + 16]) +
",")
25 lines += [
"};", f
"extern const size_t {name}_size = sizeof({name});"]
27args.output.write_text(
"\n".join(lines))