Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame^] | 1 | def _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, |
| 11 | "-out", |
| 12 | img_file.path, |
| 13 | ], |
| 14 | inputs = [ |
| 15 | ctx.file.kernel, |
| 16 | ctx.file.system, |
| 17 | ], |
| 18 | outputs = [img_file], |
| 19 | ) |
| 20 | |
| 21 | return [DefaultInfo(files = depset([img_file]), runfiles = ctx.runfiles(files = [img_file]))] |
| 22 | |
| 23 | node_image = rule( |
| 24 | implementation = _node_image_impl, |
| 25 | doc = """ |
| 26 | Build a disk image from an EFI kernel payload and system partition |
| 27 | contents. See //metropolis/node/build/mkimage for more information. |
| 28 | """, |
| 29 | attrs = { |
| 30 | "kernel": attr.label( |
| 31 | doc = "EFI binary containing a kernel.", |
| 32 | mandatory = True, |
| 33 | allow_single_file = True, |
| 34 | ), |
| 35 | "system": attr.label( |
| 36 | doc = "Contents of the system partition.", |
| 37 | mandatory = True, |
| 38 | allow_single_file = True, |
| 39 | ), |
| 40 | "_mkimage": attr.label( |
| 41 | doc = "The mkimage executable.", |
| 42 | default = "//metropolis/node/build/mkimage", |
| 43 | allow_single_file = True, |
| 44 | executable = True, |
| 45 | cfg = "exec", |
| 46 | ), |
| 47 | }, |
| 48 | ) |