| 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, |
| Tim Windelschmidt | 272c830 | 2024-11-05 05:17:44 +0100 | [diff] [blame^] | 11 | "-abloader", |
| 12 | ctx.file.abloader.path, |
| Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame] | 13 | "-out", |
| 14 | img_file.path, |
| 15 | ], |
| 16 | inputs = [ |
| 17 | ctx.file.kernel, |
| 18 | ctx.file.system, |
| Tim Windelschmidt | 272c830 | 2024-11-05 05:17:44 +0100 | [diff] [blame^] | 19 | ctx.file.abloader, |
| Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame] | 20 | ], |
| 21 | outputs = [img_file], |
| 22 | ) |
| 23 | |
| 24 | return [DefaultInfo(files = depset([img_file]), runfiles = ctx.runfiles(files = [img_file]))] |
| 25 | |
| 26 | node_image = rule( |
| 27 | implementation = _node_image_impl, |
| 28 | doc = """ |
| Tim Windelschmidt | 272c830 | 2024-11-05 05:17:44 +0100 | [diff] [blame^] | 29 | Build a disk image from an EFI kernel payload, ABLoader and system partition |
| Tim Windelschmidt | c2290c2 | 2024-08-15 19:56:00 +0200 | [diff] [blame] | 30 | contents. See //osbase/build/mkimage for more information. |
| Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame] | 31 | """, |
| 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 Windelschmidt | 272c830 | 2024-11-05 05:17:44 +0100 | [diff] [blame^] | 43 | "abloader": attr.label( |
| 44 | doc = "ABLoader binary", |
| 45 | mandatory = True, |
| 46 | allow_single_file = True, |
| 47 | ), |
| Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame] | 48 | "_mkimage": attr.label( |
| 49 | doc = "The mkimage executable.", |
| Tim Windelschmidt | c2290c2 | 2024-08-15 19:56:00 +0200 | [diff] [blame] | 50 | default = "//osbase/build/mkimage", |
| Lorenz Brun | 1dc60af | 2023-10-03 15:40:09 +0200 | [diff] [blame] | 51 | allow_single_file = True, |
| 52 | executable = True, |
| 53 | cfg = "exec", |
| 54 | ), |
| 55 | }, |
| 56 | ) |