blob: 3f9327b1515b70aa0b790798cf6a7a2c2b851b25 [file] [log] [blame]
Lorenz Brun1dc60af2023-10-03 15:40:09 +02001def _node_image_impl(ctx):
2 img_file = ctx.actions.declare_file(ctx.label.name + ".img")
3 ctx.actions.run(
4 mnemonic = "MkImage",
5 executable = ctx.executable._mkimage,
6 arguments = [
7 "-efi",
8 ctx.file.kernel.path,
9 "-system",
10 ctx.file.system.path,
Tim Windelschmidt272c8302024-11-05 05:17:44 +010011 "-abloader",
12 ctx.file.abloader.path,
Lorenz Brun1dc60af2023-10-03 15:40:09 +020013 "-out",
14 img_file.path,
15 ],
16 inputs = [
17 ctx.file.kernel,
18 ctx.file.system,
Tim Windelschmidt272c8302024-11-05 05:17:44 +010019 ctx.file.abloader,
Lorenz Brun1dc60af2023-10-03 15:40:09 +020020 ],
21 outputs = [img_file],
22 )
23
24 return [DefaultInfo(files = depset([img_file]), runfiles = ctx.runfiles(files = [img_file]))]
25
26node_image = rule(
27 implementation = _node_image_impl,
28 doc = """
Tim Windelschmidt272c8302024-11-05 05:17:44 +010029 Build a disk image from an EFI kernel payload, ABLoader and system partition
Tim Windelschmidtc2290c22024-08-15 19:56:00 +020030 contents. See //osbase/build/mkimage for more information.
Lorenz Brun1dc60af2023-10-03 15:40:09 +020031 """,
32 attrs = {
33 "kernel": attr.label(
34 doc = "EFI binary containing a kernel.",
35 mandatory = True,
36 allow_single_file = True,
37 ),
38 "system": attr.label(
39 doc = "Contents of the system partition.",
40 mandatory = True,
41 allow_single_file = True,
42 ),
Tim Windelschmidt272c8302024-11-05 05:17:44 +010043 "abloader": attr.label(
44 doc = "ABLoader binary",
45 mandatory = True,
46 allow_single_file = True,
47 ),
Lorenz Brun1dc60af2023-10-03 15:40:09 +020048 "_mkimage": attr.label(
49 doc = "The mkimage executable.",
Tim Windelschmidtc2290c22024-08-15 19:56:00 +020050 default = "//osbase/build/mkimage",
Lorenz Brun1dc60af2023-10-03 15:40:09 +020051 allow_single_file = True,
52 executable = True,
53 cfg = "exec",
54 ),
55 },
56)